
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;
}
// Read FIFO data
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 !