cancel
Showing results for 
Search instead for 
Did you mean: 

I2C/FMPI2C lockup/error handling

Rolf Welde Skeie
Associate
Posted on February 27, 2017 at 09:40

Hi,

I've got two STM32F410 communicating over I2C using HAL FMPI2C library (v 1.14.0).

Both initially enables FMPI2C listen with interrupt.

When one of the STMs wants to send data, it:

  - disables FMPI2C interrupt listen (HAL_FMPI2C_DisableListen_IT())

  - waits for FMPI2C to become ready

  - then transmits the data with FMPI2C_Master_Transmit

  - It re-enables FMPI2C listen with interrupt once done(HAL_FMPI2C_EnableListen_IT()).

Write-read operations also do a Master_Receive before returning to listen state.

The receiving party enters HAL_FMPI2C_AddrCallback() based on interrupt which:

  - disables FMPI2C interrupt listen (HAL_FMPI2C_DisableListen_IT())

  - does a HAL_FMPI2C_Slave_Receive()

  - 

re-enables FMPI2C listen with interrupt once done(HAL_FMPI2C_EnableListen_IT()).

All of this works just fine until I put some pressure on the STMs and I get error callbacks (HAL_FMPI2C_ErrorCallback()) with various error codes (ARLO, BERR), eventually causing all transfers to fail due to timeout. Line monitoring reveals usually that SCL is stuck in low, but SDA have also been stuck at low. I need to reset one of the STMs, sometimes multiple times, in order to release the lines once this condition occur.

Anyone got any ideas why this happens and what I'm doing wrong?

Are there any special calls I need to do to clean up after an error condition has occured?

Thank you for your time.
3 REPLIES 3
S.Ma
Principal
Posted on February 27, 2017 at 11:24

Before doing a regular Start bit (not restart), check for the SDA and SCL level.

If both are not high level, generate by SW 9 stop bits (no clock stretching) to see if both lines goes up (bus free mode)

Posted on February 27, 2017 at 16:32

I thought the HAL libraries would take care of this type of low-level bus management, or do you know how I can use the HAL library to accomplish this?

Posted on February 27, 2017 at 22:12

Don't know for the HAL. Maybe there would be various ways to implement one. 9 stop bits worked for me in many cases, especially for hot plug and play of memories on I2C bus in the past (computer display plug and play with VGA connector is using I2C EEPROM!)