cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F1:How to change the I2C address when program running

YZhan.14
Associate

I'm trying to change the I2C address by using HAL_Deinit & HAL_Init, but it doesn't seem to work. The function below is what I wrote myself to change the address:

0693W00000Y9p1OQAR.pngIf I try to change the address,the register shows that the I2C address has been changed,but when I use another stm32 to send IIC address to it, it doesn't ACK anyway. Even though I have called the HAL_I2C_EnableListen_IT ()0693W00000Y9p1JQAR.pngif Clock Stretch ​been enabled, The SCL will stays low after I called the slave STM32, I don't konw what the Slave STM32 is waiting for.

0693W00000Y9p7HQAR.pngI tried setting breakpoints to track the progress of the program, it seemd that the slave STM32 can't call HAL_I2C_AddrCallback() anymore after I changed it's I2C address.

0693W00000Y9p8AQAR.pngI wonder how can I change the I2C address in my program and use it normally afterwards.

0 REPLIES 0