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.
I2C issue on STM32F103
Moderator: RoccoMarco
Re: I2C issue on STM32F103
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
I think there's an open item to address this
Re: I2C issue on STM32F103
OK, thanks. Found the open issue you're referring to: https://sourceforge.net/p/chibios/bugs/727/ I've give that patch a try.
- 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
The 2 bytes problem is specific of the F1s, newer devices fixed it.
Giovanni
Giovanni
- 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
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
ChibiOS includes a SW I2C implementation under ./os/hal/lib/fallback/I2C, you may try that one.
Giovanni