0

I want to emulate Elechouse PN532 NFC Module V3 as ISO/IEC 1443-4A card. I use Arduino Uno as a development board. I also downloaded their library from Github and run some examples to check if NFC module is working fine (ISO card reading). After I checked the module, I got familiar with PN532 application note, how to emulate ISO/IEC 1443-4A card. So, I use tgInitAsTarget() function to set parameters and UID. But this function returns timeout error. Afer I enabled debug, I got following output:

write:  02
read:   03 32 01 06 07
Found chip PN532
Firmware ver. 1.6
write:  8C 00 00 00 00 00 00 40 01 FE 0F BB BA A6 C9 89 00 00 00 00 00 00 00 00 FF FF 01 FE 0F BB BA A6 C9 89 00 00 06 46 66 6D 01 01 10 00
0

My Arduino scratch:

#include <PN532_SPI.h>
#include "PN532.h"

PN532_SPI pn532spi(SPI, 10);
PN532 nfc(pn532spi);

void setup(){    
  Serial.begin(115200);

  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }

  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);

  Serial.println(nfc.tgInitAsTarget(1000));
}

void loop()
{}

If I pass no argument to tgInitAsTarget(), it stucks in readResponse() function.

Any thoughts?


1)PN532 module is working - because I'm able to get firmware version (in this example too) or do other things.
2)On output in terminal the last line is write frame of tgInitAsTarget() function. But in application note on page 57 all parameters are given. And they differ from those, which are in library function. I've tried to paste parameters from this application note, but it doesn't solve the problem
3)In my opinion, the problem is, that after MCU sent data (wrote frame) to PN532 chip, it is unable to read RDY register - or PN532 doesn't set it to 1 when got this command. And that's why it stucks on readResponse() function

P.C - according to reference manual, RDY register is specifi register "which allow the host controller to know if the PN532 is ready to receive or to send data back".

1 Answers1

0

Check the maximum message size supported by the Arduino libraries that you are using to communicate with the PN532. I was in a similar situation recently - using I2C to communicate between an Arduino Uno and PN532. When I tried to send the tgInitAsTarget command I got a timeout because the Arduino "Wire" library has a 32-byte buffer size for I2C communcation, therefore it could not send the full command to the PN532 (even though the debug output from the Adafruit/Seeed PN532 libraries printed out the entire command on the debug serial port, which is confusing).

You may need to hack the Wire/SPI Arduino library to increase the buffer size, or write your own I2C/SPI driver.