2019-11-13 03:39 AM
We are currently experiencing a problem with the STM8AL3166, The I2C is set up as slave and when reading data from the STM8, first a sub-address is writtten to the STM8 whereafter a repeated start is issued. The I2C must be working in polling mode).
First we get the start condition with the slave address (ADDR set), this is detected OK and we enter slave receiver mode.
The problem occurs next since now we detect that the sub-address (to be read from) is detected as well as the repeated start condition, so RXNE, ADDR and TXE are all set at the same time. We do receive the correct sub-address from the data register, and then we try to write data in the DR to be transmitted.
However, looking at the scope, the STM8 does not seem to acknowledge the slave-address match. It seems that when the STM8 receives the sub-address, the repeated start is directly send by the master. However the slave address match is not acknowledged.
Any idea what might be wrong? What surprises me is that the BTF does not get set when receiving the sub-address data byte. I see it in the data register, but the BTF bit never gets set. Why is the clock not stretched?
Note that clock stretching and auto acknowledge are enabled, that means that I2C_CR1.NOSTRETCH=0 and I2C_CR2.ACK=1