I2C implementation for STM32

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C implementation for STM32

Postby Giovanni » Wed May 16, 2012 3:36 pm

Hi,

It is far from being complete but any software I2C implementation could be easily adapted using PAL for I/O and GPT/RTCounters for delays. If you are in a hurry it would be a good idea to search some open source implementation and just adapt it.

Giovanni

User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Location: Minsk, Belarus
Been thanked: 7 times

Re: I2C implementation for STM32

Postby barthess » Fri Jul 06, 2012 2:23 pm

Trunk has been updated with additional checks of clock divider for I2C bus.
If your PCLK1 frequency is 36MHz and I2C clock is 400kHz and duty cycle is 16/9 than you will get assertion error if compiled with CH_DBG_ENABLE_ASSERTS TRUE. Fast solving of problem:
set I2C clock to 360kHz
or
set duty cycle to 2/1

More information you can found in this topic https://my.st.com/public/STe2ecommuniti ... tviews=105

genosensor
Posts: 65
Joined: Thu Oct 03, 2013 1:06 am
Location: Santa Cruz, California
Has thanked: 1 time
Been thanked: 1 time

Re: I2C implementation for STM32

Postby genosensor » Fri Nov 08, 2013 7:35 am

Just finished reading this whole 35 page thread. It brought back not-so-fond memories...

I developed an I2C driver for the TI MSP430169 when it was first released.
It was the first MSP430 with I2C support. The silicon was very buggy.
Five months of debug before it worked well in master and slave modes. Endless corner cases.
Fortunately, we could put our own logic around the MSP430 to work around problems without resorting to busy waiting.
TI did, to their credit, completely redesign the I2C block in the MSP4302xxx parts, but we stuck with the '169.

Now, we need I2C slave support in a project involving many peer-to-peer networked STM32L1xx chips.

Questions:
It appears we could avoid the busy waits for STOP before beginning each new transaction by wiring SDA and SCL to two GPIOs configured as inputs. Interrupt on raising SDA while SCL is high signals STOP. Is this viable?
Has anyone already tried this?

I'd need to work on adding slave mode capability. The user "Z80" submitted a patch that might be a starting point.
Is there a high-level driver API for Slave Mode yet defined? Should I propose one?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C implementation for STM32

Postby Giovanni » Fri Nov 08, 2013 10:30 am

Hi,

I answered in the other thread, there are no plans currently and it would have to be a separate driver, not an extension of the current one.

Giovanni

kalpesh
Posts: 19
Joined: Mon Dec 09, 2019 11:53 am

Re: I2C implementation for STM32

Postby kalpesh » Mon Dec 09, 2019 1:17 pm

Hi,

I am getting an error for I2C stating acknowledgement failure. Any ideas to solve it. I have checked the voltage on my SDA and SCL pin also, which is fine. Also according to my sensor it can be operated at 100k and 400k , and I am operating it at 400k.

Please help me in case i am doing any mistake.

Thanks
Kalpesh

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: I2C implementation for STM32

Postby Giovanni » Mon Dec 09, 2019 1:24 pm

Make sure that you are passing the correct address, which is the value of the upper 7 bits without the RW bit.

Giovanni

kalpesh
Posts: 19
Joined: Mon Dec 09, 2019 11:53 am

Re: I2C implementation for STM32

Postby kalpesh » Mon Dec 09, 2019 2:20 pm

Giovanni wrote:Make sure that you are passing the correct address, which is the value of the upper 7 bits without the RW bit.

Giovanni

So It means , I should pass the slave address directly(i.e. only 7 bits to be transmitted) without the read/ write bit (Read -1, Write -0).


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 8 guests