cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RE crashes when I2C2 and UART4 used simultaneously.

jaredmuirhead
Associate
Posted on April 11, 2016 at 19:07

I am an engineer at a startup developing a new flight controller for hobby aerial vehicles.  We are using the STM32F103RET6 microcontroller.  I am currently having an issue using I2C2 and UART4 simultaneously.

We receive battery charge info from I2C2 (pins PB10, PB11) and GPS data from UART4 (PC10, PC11).  When both are used simultaneously, the microcontroller will crash after a few minutes of operation, though the exact time varies from trial to trial.  Using a logic analyzer shows that the crash occurs only if an I2C2 read occurred at the same time as a UART4 message.  This condition appears necessary, but not sufficient.  That is, I2C2 often reads at the same time as UART4 receives without any issue, but the crash always occurs in that scenario.

Using either device on it's own not produce a crash.  The only workaround I have found is by disabling all USART/UART interrupts from I2C2 start condition to I2C2 stop condition, though this is obviously less than ideal.

I cannot find anything in the datasheet or errata about this phenomenon.  Any advice is appreciated.  Thank you.

#st32-f103-i2c-i2c2-uart-uart4
3 REPLIES 3
Posted on April 11, 2016 at 20:18

I cannot find anything in the datasheet or errata about this phenomenon. 

I think that's because it sounds like a coding/priority issue. I know it's easy to point at a hardware issue, but it very rarely is, and you're talking about an 8+ year old design.

Look very carefully at structures and buffers, and variables that need to be volatile, and functions that need to be thread-safe. Adequate stacking to handle preemption.

Get some decent fault handling, and log what the processor is telling you about the internal state and faulting condition.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
andre239955_st
Associate II
Posted on April 12, 2016 at 12:22

I have done some serious testing on the i2c of the STM32F1 family and I also ran against the hang up. In some cases an event does not come and there is no way to get this from the status. My solution was to generate the i2c signals with software, I don't use the i2c peripheral at all.

Posted on April 12, 2016 at 16:07

My solution was to generate the i2c signals with software, I don't use the i2c peripheral at all.

I'm not a fan of ST's I2C implementation, I'd recommend anyone with prior experience of the protocol, just manage it via software (bit-bang), as it is likely to be less frustrating.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..