This is the only device I've come across which needs delays, so I suppose it is for specific slaves. But there may well be other devices out there that need delays.
An alternative could be to implement a more configurable soft i2c implementation. If such a driver were created, should it exist as a 'platform' of the existing driver, or as an entirely new I2CSoft, potentially with more options. Or we could have a software lld which would be compatible with the current i2c driver and also a more extensive one with delays etc.
I2C implementation for STM32
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: I2C implementation for STM32
I have a soft I2C half done, probably it could still be useful (see missing DMAs), probably it would be a good idea to finish it.
Giovanni
Giovanni
Re: I2C implementation for STM32
Hi Badger,
As described in I2C standard, if slave need some time to process data than it pulls SCL line down until all data will be processed. For example ADC MAX1236
Second behavior. In 24AA EEPROM chips 5 ms delays needs to write one page to storage. During this time the IC leaves SCL floating but not response the data on bus.
Both types of IC works fine in my board with ChibiOS driver.
Are there one of your case?
As described in I2C standard, if slave need some time to process data than it pulls SCL line down until all data will be processed. For example ADC MAX1236
While converting the analog input signal, the MAX1236–MAX1239 holds SCL
low (clock stretching). Once all conversions are complete, the
MAX1236–MAX1239 release SCL, allowing it to be pulled
high. The master can now clock the results out of the mem-
ory in the same order the scan conversion has been done
at a clock rate of up to 1.7MHz. SCL is stretched for a max-
imum of 8.3μs per channel
Second behavior. In 24AA EEPROM chips 5 ms delays needs to write one page to storage. During this time the IC leaves SCL floating but not response the data on bus.
Both types of IC works fine in my board with ChibiOS driver.
Are there one of your case?
Re: I2C implementation for STM32
The device is one of those which calls I2C something else (in this case SCCB), presumably to get around licensing. I can get around it by doing a separate write then a read, so I suppose it is probably just a bad implementation of the protocol on the part of the designers! Maybe for the soft I2C driver fancy options to do with timing could exist to get around these sorts of problems, but it doesn't look worth doing for the hardware driver.
Re: I2C implementation for STM32
I'm trying to make I2C works with my BMP085.
I have partial success.
The code is available on github https://github.com/trunet/TrunetCopter.
Look on src/main.c on lines 242, 243 and 244. If I comment 242, 243 and uncomment 244, the code does not work(it freezes the thread).
My I2C lines are pulled high with 4.7k resistors.
I have partial success.
The code is available on github https://github.com/trunet/TrunetCopter.
Look on src/main.c on lines 242, 243 and 244. If I comment 242, 243 and uncomment 244, the code does not work(it freezes the thread).
My I2C lines are pulled high with 4.7k resistors.
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: I2C implementation for STM32
Hi,
I recommend to enable all the debug options in chconf.h (always recommended during development) and increase the stack size of that thread, it is possible this is just a stack overflow.
Giovanni
I recommend to enable all the debug options in chconf.h (always recommended during development) and increase the stack size of that thread, it is possible this is just a stack overflow.
Giovanni
Re: I2C implementation for STM32
It works, thank you.
I'm just starting with RTOS systems with ChibiOS. What is the best way to determine stack size on threads to avoid this happening?
I'm just starting with RTOS systems with ChibiOS. What is the best way to determine stack size on threads to avoid this happening?
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: I2C implementation for STM32
Hi,
If you create an Eclipse environment and install the ChibiOS plugin you can see the stack usage directly while debugging, the plugin+debugging options allow to catch most common RTOS-related mistakes.
Giovanni
If you create an Eclipse environment and install the ChibiOS plugin you can see the stack usage directly while debugging, the plugin+debugging options allow to catch most common RTOS-related mistakes.
Giovanni
Re: I2C implementation for STM32
Giovanni wrote:I have a soft I2C half done, probably it could still be useful (see missing DMAs), probably it would be a good idea to finish it.
Giovanni
Hi Giovanni,
I'm currently writing software for a STM32-P103 Board, which has peripherals connected over SPI and I²C using ChibiOS.
As others have stated i'm running out of DMA streams, so I was wondering if you have an unstable version of your "soft I²C" available ?
(I wouldn't mind a stable one though