cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Hard Crashes with I2C

joesnyder
Associate II
Posted on March 06, 2017 at 16:22

I'm having a problem where I2C is hard crashing my STM32F446RET6 (programmed in EWARM with CubeMX as a starting point).  When I2C devices are enabled, at random amounts of time (couple hours to overnight), a .25 second 'heartbeat' indicator LED (in the main while loop) slows to ~1 second, and I2C communication on I2C1 & I2C2 stops.  Resetting from the NRST pin does nothing.  You have to physically remove power to get it to reset - it's as crashed as can be. 

I am using STM32CubeF4, Version 1.14.0, and I'm experiencing the exact same thing as this post:

https://community.st.com/thread/34172-i2c-bug-in-stm32cubef2-firmware-package-v140&sharpcomments

 

That post has not been updated to say the problem was resolved.  I searched through my stm32f2xx_hal_i2c.c, and sure enough, the flawed code is present in mine too.  To fix it, that person reverted to STM32CubeF2 Version 1.3.0, but did not post what changes to the code made it right.

So, I've identified that the Cube generated code has a problem that causes the symptoms I'm observing...my question is, how do I know what revision of CubeF4 software to revert to?  At what point did this flaw occur?  Ideally, I'd just like to get a copy of a proper stm32f2xx_hal_i2c.c, and insert that into my project without rebuilding from Cube. 

null
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on March 06, 2017 at 16:32

Specific file attached, or pull the mirror and diff/merge

https://drive.google.com/open?id=0B7OY5pub_GfIRGlQZEljWjNFS3c

________________

Attachments :

stm32f2xx_hal_i2c.c.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyqM&d=%2Fa%2F0X0000000bD6%2FoTwD22V_q2TkH5wNfSJNnZ1UHcelPNjH.crpizQff58&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
Posted on March 06, 2017 at 16:32

Specific file attached, or pull the mirror and diff/merge

https://drive.google.com/open?id=0B7OY5pub_GfIRGlQZEljWjNFS3c

________________

Attachments :

stm32f2xx_hal_i2c.c.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyqM&d=%2Fa%2F0X0000000bD6%2FoTwD22V_q2TkH5wNfSJNnZ1UHcelPNjH.crpizQff58&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
joesnyder
Associate II
Posted on March 06, 2017 at 16:55

To clarify the last part, I made a mistake and wrongly put 'stm2f2xx_hal_i2c.c', it should read:

So, I've identified that the Cube generated code has a problem that causes the symptoms I'm observing...my question is, how do I know what revision of CubeF4 software to revert to?  At what point did this flaw occur?  Ideally, I'd just like to get a copy of a proper stm32f4xx_hal_i2c.c, and insert that into my project without rebuilding from Cube. 

joesnyder
Associate II
Posted on March 06, 2017 at 20:11

It appears to be working.  I'll let it run for a day or so to make sure.  To reiterate what I did for anyone else with the same problem:

Cut/pasted entire (older, known good) version of the stm32F4xx_hal_i2c.c

Compiled -> got a ton of errors (corresponding header file has to be changed too).

Cut/pasted entire (older, known good) version of the stm32F4xx_hal_i2c.h

Everything compiles and runs fine.  I have high hopes that it's fixed!

Thanks to Clive One for the input.