I2C issue on STM32F103

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

Moderator: RoccoMarco

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

I2C issue on STM32F103

Post by scttnlsn »

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: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: I2C issue on STM32F103

Post by steved »

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

Post by scttnlsn »

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: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C issue on STM32F103

Post by Giovanni »

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

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

Re: I2C issue on STM32F103

Post by DrTon »

I have the same issue on STM32F103RC. Any official solution for this?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: I2C issue on STM32F103

Post by Giovanni »

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
Post Reply