2019-12-02 06:34 AM
I'm working with STM32L0 and use the I2C to read some registers of a bms by TEXAS.
I perform some I2C reading once every seconds using HAL_I2C_Master_Transmitand HAL_I2C_Master_Receive and everything work well maybe for hours. Then unexpectedly something goes wrong and I2c get stuck.
In these condition SCL is always LOW ( it rises no more ) and the the BUSY is ON. Every other reading fails and I don't know how to recover from this situation.
Anybody can help me?
Thanks
2019-12-02 07:23 AM
2019-12-03 01:57 AM
Thanks I'll try to put in action your suggestion.
I used lot of times the I2C and have never had such problems.
This is the 1st time I used I2C master with this uC: just transmit and wait for an answer with the HAL library. Very easy.
Pull up resistors are 4k7, cable length ise less than 20 cm and signal waves seem OK
I can't explain why after so many I2C transactions the bus get stuck. I disconnected the
cable and SCL remains low so I think it's just the master that is stuck
Many thanks
2019-12-03 02:32 AM
Are you using low power Stop mode in your application? Check the errata.
Anyway, pulsing the corresponding I2C reset bit in RCC should help.
2019-12-03 11:41 PM
Are you referring to the point: "I2C and USART cannot wake up he device from Stop mode" reported in the errata sheet?
Well my uC never enters the stop mode.
I reinitialized the I2C when some error occurs:
if (I2Cread() == OK)
{
// do something
}
else
{
MX_I2C1_Init(); // method provide by CubeMX to reinitialize the I2C
}
Yesterday it worked all day without stopping.
Thanks for your help. I will let you know