Skip to main content
dennisvantienhoven
Associate II
January 6, 2012
Question

A NACK by the SR1 register and a ACK by the logic analyzer.

  • January 6, 2012
  • 2 replies
  • 719 views
Posted on January 06, 2012 at 13:33

Hello I've got an issue with I²C.

My problem:

on the logic analyzer I receive an ACK and by the SR1 register a NACK

my checking code:

-------------------------------------------------------------------

/* Clearing SR1 and SR2 */

iTemp = I2C2->SR1;

if((I2C2->SR1 & 0x0002) == 0x0002)

    iTemp = I2C2->SR2;

/* Send Register adres */

I2C_SendData(I2C2, 0x0A);

/* Wait until ADDR is set */

Timeout = 0xFFFF;

while((I2C2->SR1 & 0x0002) != 0x0002){

    if (Timeout-- == 0)

    return Error;

}

-------------------------------------------------------------------

now I got stuck at the while loop because there is no ACK received.

The weird thing is: the SR1 register receives a ACK when I call the slave with his slaveaddress.

0690X00000603EFQAY.jpg
    This topic has been closed for replies.

    2 replies

    dennisvantienhoven
    Associate II
    January 9, 2012
    Posted on January 09, 2012 at 16:41

    I've made an delay between the two transmit conditions, didn't work.

    I've set the SWRST in CR1 register and that cleared all my I²C registers so that didn't work either..

    Is it an option to check if TxE bit from the SR1 register is high in stead off checking the SR1 register for the ADDR bit to be high? because the TxE bit (0x0080) is high after the slave has been called.

    Greets,

    Dennis

    dennisvantienhoven
    Associate II
    January 10, 2012
    Posted on January 10, 2012 at 11:10

    Well found out what my problem exactly was...

    The ADDR bit is only set when the slave ACK's his slave addres.

    When the slave receives data and ACK's on that data then the TxE bit will be set.

    men... I had to know that..