cancel
Showing results for 
Search instead for 
Did you mean: 

Chipselect used as I2C reset

GioP
Associate II

Many ST mems sensors allow the user to select an I2C or SPI serial interface by controlling the chipsel (CS) pin.

My question is: in case a sensor, used as an I2C slave, gets stuck waiting for the master to acknowledge the read operation, does toggling CS pin low effectively reset the slave I2C interface?

Is it feasible as a workaround for this specific communication error?

3 REPLIES 3
S.Ma
Principal

Hmm, the slaves does not clock stretch, so it never waits.

As a general rule, when the STM32 wants to initiate an I2C transaction, first it should check both SDA and SCL are idle high level.

If not, I usually generate manually 9 STOP bits as bit bang to flush the bus.

GioP
Associate II

It occurs very rarely, but sometimes I have to force a STOP condition as well, so I was looking for a simpler solution. Anyway, how can this happen if there's only one master on the bus and the slave never waits?

Eleon BORLINI
ST Employee

​HI @GioP​ , it depends on which ST sensor you are using. Some of the most recent sensors allows not only the I2C or SPI on the same lines but also other protocols, enabling the selection acting on the same CS pin. However, supposing you are using a sensor with only I2C and SPI, and if the I2C communication issue comes from the slave, you can reset the slave I2C interface toggling the CS pin. If it is not working, please follow the above-suggested general solution. Regards