I2C issue on STM32F103

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

scttnlsn
Posts: 3
Joined: Sat Jun 17, 2017 2:37 pm

I2C issue on STM32F103

Postby scttnlsn » Sat Jun 24, 2017 3:01 pm

I'm trying to port some code to ChibiOS and running into some issues with I2C running on an STM32F103. Here's a scope capture of trying to read a single byte from the 0x0B register of slave device 0x08: http://imgur.com/a/NQ4FL I expect to receive 0x19 but an extra byte (0xFF) is being read mistakenly. Here's a scope capture from my own I2C implementation (outside of ChibiOS) showing the correct sequence: http://imgur.com/a/xHgnk

I recall the I2C peripheral on STM32F103 was a bit of a nuisance to use and I had to handle various special cases when implementing my own I2C driver for this MCU. The approach for reading 1, 2 and 3+ bytes are outlined on pages 767-769 of the RM0008 Reference Manual from ST. I was looking through the STM32 I2C LLDs in ChibiOS and didn't see anything handling these special cases. Is I2C "officially" supported by ChibiOS on STM32F103s? Has anyone else here run into this issue? Just want to make sure I'm not doing something wrong before trying to port my driver to ChibiOS.

steved
Posts: 733
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 10 times
Been thanked: 108 times

Re: I2C issue on STM32F103

Postby steved » Sat Jun 24, 2017 6:07 pm

The Chibi I2C driver doesn't support reading 1 byte currently, although I believe its OK for 2 bytes, and definitely for 3 and more. (If you have debug assertions enabled, the driver traps an attempt to read 1 byte).

I think there's an open item to address this

scttnlsn
Posts: 3
Joined: Sat Jun 17, 2017 2:37 pm

Re: I2C issue on STM32F103

Postby scttnlsn » Sat Jun 24, 2017 6:55 pm

OK, thanks. Found the open issue you're referring to: https://sourceforge.net/p/chibios/bugs/727/ I've give that patch a try.

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

Re: I2C issue on STM32F103

Postby Giovanni » Sat Jun 24, 2017 8:16 pm

The 2 bytes problem is specific of the F1s, newer devices fixed it.

Giovanni

DrTon
Posts: 5
Joined: Sat Oct 22, 2016 9:30 pm

Re: I2C issue on STM32F103

Postby DrTon » Mon Aug 10, 2020 10:27 pm

I have the same issue on STM32F103RC. Any official solution for this?

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

Re: I2C issue on STM32F103

Postby Giovanni » Tue Aug 11, 2020 6:26 am

No, you still need to read 2 bytes.

ChibiOS includes a SW I2C implementation under ./os/hal/lib/fallback/I2C, you may try that one.

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 1 guest