This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

XC167 I2C problem

Hellow! I have a problem, whet i try to send a message to i2c like this example:

IIC_RTBL = (EEPROM_ADR << 1) | 0; // Write Slave Address and WR
while ((IIC_ST & 0x0020) == 0); // Wait for end of Tx (IRQD)
if (IIC_ST & 0x0008) goto noack; // Check for ACK (LRB)

This term while ((IIC_ST & 0x0020) == 0);, does not work. Fails to check the end of the transmission. Explain:

IIC_RTBL = (EEPROM_ADR << 1) | 0; // Write Slave Address and WR
while ((IIC_ST & 0x0020) == 0); // Wait for end of Tx (IRQD)
if (IIC_ST & 0x0008) goto noack; // Check for ACK (LRB)

if ((IIC_ST & 0x0020) != 0) printf("BUG\n");

Of course in the terminal i see: BUG

What's wrong whith i2c?