I want to use acknowledge polling method for 24LC64 EEPROM writing.
How can I use it in ADuCM360?
while( (I2cSta(MASTER) & I2CMSTA_NACKDATA_MSK) == I2CMSTA_NACKDATA)
Is it correct?
Thank you in advance.
Firstly, I would recommend that you use the interrupt handler - by using while() loops in the manner above, you risk your code getting stuck indefinitely in these while() loops.
If you do chose to use polling, i would suggest not polling the NACK bits but, to send the ADDR and first byte and then poll the Tx FIFO bits. The example below is used to create teh following sequence:
Start, ADDR+W, BYTE, Repeated Start, ADDR+READ, BYTE
while ((I2CMSTA & 0x3) != 0x0)
// Repeated Start Condition!
I tired to use interrupt to handle it, but it does not work. Then I switch to using polling.
But the code stuck in "while ((I2CMSTA & 0x3) != 0x0)" , if I send invoke Write_Byte function twice.
Just as showed in following:
Write_Byte();//This command will stuck
If you use an oscilloscope, can you see the address byte being Acknowledged by the slave device?
Is 0xA0 the expected address value for your EEPROM?
Retrieving data ...