2012-01-06 04:33 AM
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.2012-01-09 07:41 AM
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, Dennis2012-01-10 02:10 AM
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..