cancel
Showing results for 
Search instead for 
Did you mean: 

After initialization, I2C is always busy

AZube.2
Associate III

I am using the Nucelo board and communicating with an IKS02A1 trough I2C2 using PINs PA11 and PA12 with the following configuration:

0693W00000QL5xUQAT.png 

I have initializaed the I2C folowing the guidelines in "stm32wlxx_hal_i2c.c", and when I use "HAL_I2C_IsDeviceReady()" function I always get BUSY_ERROR.

The initialization is done through:

0693W00000QL6HAQA1.png 0693W00000QL6PhQAL.pngDMA and interrups are both initialized even though I am not still usign them. I tried not initializing them them and the results are the same.

If I do not check "HAL_I2C_IsDeviceReady()" function and I directly use "HAL_I2C_Mem_Read()" or "HAL_I2C_Mem_Write()", I get ERROR_PERIPH_FAILURE.

I can not fix this and I am going crazy please help!

6 REPLIES 6

What do the levels / signals look like on SDA and SCL ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
AZube.2
Associate III

Problem fixed finally, thanks.

Louis AUDOLY
ST Employee

Hi @AZube.2​ ,

Glad you manage to fix your issue.

Can you share your solution in case someone else encounter the same issue ?

Thank you

Best regards

AZube.2
Associate III

Hi @Louis AUDOLY​ ,

I am sorry to say that I did not strictly find a solution for the issue. What I did was to start a new project and trust the CubeMX initialization code (which was the same thing I did when I got the issue). For some reason that is unknown to me, this time the issue never appeared.

Hope this helps to someone :)

Best regards

S.Ma
Principal

It could be a io vs i2c init sequencd and timing marginality. If it happened once, it could reappear when compile option changes or else. Get ready, implement a sw bit bang gpio function that generates 9 stop bits. Use it if sda is low or busy is set prior starting bus transaction to flush the bus.

Typically happens when debugging, reading data from slave and reset the mcu [and not the slave] by restarting the code.

Real application test would be esd gun near pcb i2c lines. Old test was use a drilling machine near the board.... rugged sw ? Knowledge makes the difference in the long term....

Sounds interesting, I would like to try it @S.Ma​ . Do you know any example I could use?