I am trying to controll an I2C NTAG from an LPCXpresso54102. For that, I power the NTAG from the LPCXpresso and I connected the SDA and SCL lines. Connections seem to be right since I can issue an empty write operation and the NTAG acknowledges it.
The problem arises when I try to write a memory block in the NTAG. The NTAG acknowledges its own I2C address, it acknowledges the MEMA (memory block address) but then I receive a NACK when I try to transfer the payload. Sometimes, though very rarely, it succeeds on writing a memory block. Then it will fail if I try to write a second one.
From the screenshot you can see I am setting the I2C clock to 100kHz. The effective clock is about 105 kHz but I don't think that should be a problem provided the NTAG suports fast I2C. Also, you can notice that there seems to be some clock stretching when the NTAG sends the ACKs. That doesn't happen when using the I2C NTAG Explorer Kit.
Also, I based my program on the i2c_probe sample application in the LPC SDK. The only difference is that I don't ever make the LPC sleep by calling __WFI() or anything similar.
Any thoughts on that?
Hello Genis Aguilar,
Regarding your issue, I can think of next possible reasons for the NACK:
- Trying to write data before previous write command finishes. Between EEPROM writes make sure to have a delay so the EEPROM memory write is completed. You can poll the EEPROM_WR_BUSY flag in the NS_REG register to get the status of the write cycle.
- The NTAG I2C will not listen to read or write commands while the memory access is locked to the NFC interface. The bits I2C_LOCKED and RF_LOCKED in the NS_REG register reflect which interface currently has access to memory. One way to clear RF_LOCKED is to simply remove any NFC field from the NTAG I2C antenna.
Regards!
Jorge Gonzalez
The NTAG was sending the NACK because the command I was sending was wrongly formatted, so there was no issue at all.
Thanks,
Genis Aguilar
Hi Genis,
I am glad to know you found the root cause. Actually the frame you posted above seems correct to me. If you can share what was the exact issue it might be helpful for others :smileyhappy:.
Regards!
Jorge Gonzalez