cancel
Showing results for 
Search instead for 
Did you mean: 

I2C BUSY

Djain.1
Associate II

I am using STM32F407 Discovery Board and I'm generating my project using MX Cube

 

I'm doing testing on I2C sensor that is MLX 640 which is used for taking thermal image , so basically we are are reading frames of thermal image via I2C on every 1 second and doing some processing on it. Basically some floating operations on each frames

The data sheet of MLX 640 -https://www.melexis.com/-/media/files/documents/datasheets/mlx90614-datasheet-melexis.pdf

 

So while doing this initially all floating operations are done by STM for few frames , but after few frames we are getting HAL I2C error that is 0x02  i.e HAL_BUSY  

HAL_OK    = 0x00U,

 HAL_ERROR  = 0x01U,

 HAL_BUSY   = 0x02U,

 HAL_TIMEOUT = 0x03U

and it's getting stuck every single time

What type of thing should I do for I2C to not get busy and it works properly for each frame with all floating operations.

Should I try to reset I2C after each frame? If yes, then how am I suppose to do that?

And If no, then what is the way to do it?

 

1 REPLY 1
TDK
Guru

HAL_BUSY means either the peripheral isn't ready because you're using it somewhere else, or the line is busy. If it's the former, fix your code. If it's the latter, a device may be holding down the SCL line, or the STM32 I2C peripheral is just in a bad state. You can try to reset the peripheral to see if it frees up. You can reset the peripheral with the I2C_CR1_SWRST bit.

In either case, it shouldn't be happening and you should figure out the cause. I would attach a logic analyzer and see if I could spot the issue and go from there.

If you feel a post has answered your question, please click "Accept as Solution".