cancel
Showing results for 
Search instead for 
Did you mean: 

Sometime HAL_I2C_IsDeviceReady present in stm32l4xx_hal_i2c.c returns HAL_TIMEOUT

horairajilani
Associate II
Posted on January 02, 2017 at 13:31

We are using I2C1 in STM32L486 and occasionally we are seeing timeout while calling HAL_I2C_IsDeviceReady,

this we are calling before call to HAL_I2C_Master_Transmit_IT

This is happening when USART0 is in use and data transfer is happening on that.

We are digging into it and in parallel posted here , so that if anyone faced these kind of issue might provide direction in which to look.

#stm32l4-hal-i2c
2 REPLIES 2
Seb
ST Employee
Posted on January 02, 2017 at 13:46

Make sure that there is no conflict, I2C transactions should always come from a single source.

See some general advice here:

https://community.st.com/0D50X00009XkW1mSAF

If I2C traffic is generated from interrupt and other main loop or other interrupt sources, the I2C communication might break and stall. Also if it is a data flowing from one peripheral to another, interrupt priority and making sure the buffer are not under/over run is important. When debugging, stop the code outside an I2C on-going transaction.

You can also (if slave devices are not MCU based) try first with SW I2C implementation with bus error recovery to track down the rootcause.

Good luck!

Posted on January 03, 2017 at 09:26

Hi

marsanne.sebastien

,

Thanks for quick response,

What would happen if HAL_I2C_IsDeviceReady functions get interrupted by Higher priority Interrupt or task,

Will it break ? because this is the only scenario we are seeing here to happen, one task we see has higher priority than this might preempt it.

Our use case is reading data in interrupt mode from one of slave device(sensor device) connected to I2C bus. ie master has to first write the memory address to slave then reads it.