i am trying to read the block 0xA0, to know when i am able to access the SRAM via nfc. in this case I have set up the tag to go in passthrough mode i2c -> nfc. when reading the 10A0 register via i2c, when i2c is done writing, byte 0 is 0x23 and byte1 0xE5, which I think are corrrect?
I am trying to then access the 0xA0 session register to check when i2c is done writing and I can begin to read via NFC. this is my code: I dont understand why my response does not match what I am reading via i2c. what am i doing wrong? am i reading the single block correctly ? My IUD is correct since I have checked it using the nxp app on my phone.
Also, the first byte on my status_reg variable is always 0. is that correct?
My code:
Serial.println("[INFO] Reading STATUS_REG (A0h)...");
// Clear FIFO before sending a new command
writeRegister(0x02, 0xB0);
writeRegister(0x06, 0x7F);
writeRegister(0x07, 0x7F);
writeRegister(0x05, 0x02); // Standard Mode (no UID)
writeRegister(0x05, 0x20); // "Read Single Block" command
writeRegister(0x05, 0xA0); // Write the block address (A0h for STATUS_REG)
writeRegister(0x00, 0x07); // Execute command
// Wait for response
if (!waitForCardResponse()) {
Serial.println("[ERROR] No response from status register.");
return NULL;
}
// 7) Read FIFO length
uint8_t fifoLength = readRegister(0x04);
if (fifoLength < 2) {
Serial.println("[ERROR] FIFO response too short!");
return NULL;
}
//
static uint8_t status_reg[10]; // store up to 10 bytes for debug
for (int i = 0; i < fifoLength; i++) {
status_reg[i] = readRegister(0x05);
}
// Debug
Serial.print("[DEBUG] Raw FIFO Bytes: ");
for (int i = 0; i < fifoLength; i++) {
Serial.print("0x");
Serial.print(status_reg[i], HEX);
Serial.print(" ");
}
Serial.println();
// 9) Check response flag
uint8_t respFlag = status_reg[0];
if (respFlag & 0x01) {
// Error bit
if (fifoLength >= 2) {
uint8_t errCode = status_reg[1];
Serial.print("[ERROR] 15693 Error Code: 0x");
Serial.println(errCode, HEX);
} else {
Serial.println("[ERROR] 15693 error bit set, but no error code byte!");
}
return NULL;
}
// 10) Extract actual STATUS_REG bytes
// Typically Byte1 and Byte2 are your actual data if no error flag
uint8_t statusByte0 = status_reg[1];
uint8_t statusByte1 = (fifoLength > 2) ? status_reg[2] : 0x00;
Serial.print("[INFO] STATUS_REG Bytes: 0x");
Serial.print(statusByte0, HEX);
Serial.print(" 0x");
Serial.println(statusByte1, HEX);
return status_reg; // pointer to the first status byte
}
Thank you so much !
Hello @cateaz, Good Day!
Thank you very much for your interest in our products.
Unfortunately, providing support on a custom code or software is out of our support scope, I would suggest checking out our recommended software examples for NTAG 5 ''Pass-through'' mode which are meant to work with the LPCXpresso55S69 Board. You can find those along with a quick setup guide here: Guide for using NTAG 5 with LPC55S69 - NXP Community.
However, I would recommend checking out section 6 of the NTAG 5 - Bidirectional data exchange Application Note for a detailed description of the process that has to be followed, since there are some bits on the configuration register that need to be handled via I2C in order for the communication to work properly. You may find the name of those bits and their effects in section 8.1.4 and section 8.1.3.13 of the NTAG 5 Data Sheet. Keep in mind that the purpose of the reading of the status register is for the NFC Device to be able to write to the SRAM, so the important bits to check in the status register are SRAM_DATA_READY and I2C_IF_LOCKED.
My best regards,
Daniel.