cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F412 I2C2 Busy flag keeps set

sanju
Senior

Hi all,

i am facing issue with STM32F412's i2c. i am using i2c2 on PB9/PB10 pins. Two i2c slaves are connected on this bus. one is 24AA02E48 eeprom and second is M41T00S RTC.

SDA is pulled up is 10K resistor and SCL is pulled up with 4.7K resistor.

STM32F412 is working as i2c master.

firmware is able to write data to eeprom and read time from RTC.

but suddenly after a random time few minutes to hour , i2c stops to work i.e. HAL_I2C_Mem_Read and HAL_I2C_Mem_Write doesn't returns HAL_OK.

at this time, i2c busy flag becomes set and SCL pin remains low (checked with oscilloscope).

after getting the point that slave is keeping the SCL pin low., i tried below code.

 

i made a change in code as 

if (HAL_I2C_Mem_Read() != HAL_OK )

{

HAL_I2C_DeInit(&hi2c2);
MX_I2C2_Init();

}

and found that with this code when oscilloscope is connected to SCL pin i2c starts working.

till oscilloscope is not connected on SCL pin i2c doesn't work

when oscilloscope is connected then i2c starts to work.

please help me what more steps should be added in code.

 

 

0 REPLIES 0