cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Communication Protocol

dhirrajsharma
Associate II

I am currently working on I2C communication with the STM32G030F6P6 microcontroller and developing a library for slave mode. I encountered an issue where, after the master transmits a command, the slave receives and processes the data, responding accordingly. However, when the command doesn't match the expected input and the master sends a receive request, clock stretching occurs. If anyone has insights on how to handle or resolve this, I would appreciate your suggestions

4 REPLIES 4
Imen.D
ST Employee

Hello @dhirrajsharma

Did you check the Errata sheet related to your device?

Try enable the I2C listen mode to handle address match events.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
dhirrajsharma
Associate II

What will happen if the master requests data from the slave, but the slave does not have a function for transmission? In the transfer direction for transmission, I have enabled the listen mode, which results in a NACK and pulls up both the SDA and SCL lines. If the master attempts to transmit or request data again, the status shows HAL_BUSY, or the master gets stuck in the transmitting state.

 
 

What you can try to to implement a reply as "no info available" equivalent reply, so that i2c bus is  happy and the master knows that particular slave do not have that functionality implemented.

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