Following is the code for arduino connected with RF430CL330H dynamic tag
#if ARDUINO >= 100 #include "Arduino.h" #else #include "WProgram.h" #endif #include <Wire.h> #include <RF430CL330H_Shield.h> #define IRQ (3) #define RESET (4) int led = 13; RF430CL330H_Shield nfc(IRQ, RESET); unsigned char NDEF_Application_Data[] = RF430_DEFAULT_DATA; volatile byte into_fired = 0; uint16_t flags = 0; byte ndefdata[1024]; uint16_t Tag4Length = 0; void setup(void) { Serial.begin(9600); pinMode(led, OUTPUT); digitalWrite(led, HIGH); //reset RF430 nfc.begin(); delay(1000); } void loop(void) { while(!(nfc.Read_Register(STATUS_REG) & READY)); //wait until READY bit has been set Serial.print("Fireware Version:"); Serial.println(nfc.Read_Register(VERSION_REG), HEX); //write NDEF memory with Capability Container + NDEF message nfc.Write_Continuous(0, NDEF_Application_Data, sizeof(NDEF_Application_Data)); //Enable interrupts for End of Read and End of Write nfc.Write_Register(INT_ENABLE_REG, EOW_INT_ENABLE + EOR_INT_ENABLE); //Configure INTO pin for active low and enable RF nfc.Write_Register(CONTROL_REG, INT_ENABLE + INTO_DRIVE + RF_ENABLE ); Serial.println(nfc.Read_Register(CONTROL_REG)); //prints 22 while(1){ } }
Following is the code for arduino connected with PN532 nfc reader/writer.
/**************************************************************************/ #include <Wire.h> #include <Adafruit_NFCShield_I2C.h> #define IRQ (2) #define RESET (3) // Not connected by default on the NFC Shield Adafruit_NFCShield_I2C nfc(IRQ, RESET); void setup(void) { Serial.begin(9600); Serial.println("Hello!"); 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); // configure board to read RFID tags nfc.SAMConfig(); Serial.println("Waiting for an ISO14443A Card ..."); } void loop(void) { uint8_t success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type) // Wait for an ISO14443A type cards (Mifare, etc.). When one is found // 'uid' will be populated with the UID, and uidLength will indicate // if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight) success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength); if (success) { // Display some basic information about the card Serial.println("Found an ISO14443A card"); Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes"); Serial.print(" UID Value: "); nfc.PrintHex(uid, uidLength); Serial.println(""); if (uidLength == 4) { // We probably have a Mifare Classic card ... Serial.println("Seems to be a Mifare Classic card (4 byte UID)"); // Now we need to try to authenticate it for read/write access // Try with the factory default KeyA: 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF Serial.println("Trying to authenticate block 4 with default KEYA value"); uint8_t keya[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // Start with block 4 (the first block of sector 1) since sector 0 // contains the manufacturer data and it's probably better just // to leave it alone unless you know what you're doing success = nfc.mifareclassic_AuthenticateBlock(uid, uidLength, 4, 0, keya); if (success) { Serial.println("Sector 1 (Blocks 4..7) has been authenticated"); uint8_t data[16]; // If you want to write something to block 4 to test with, uncomment // the following line and this text should be read back in a minute //memcpy(data, (const uint8_t[]){ 'a', 'd', 'a', 'f', 'r', 'u', 'i', 't', '.', 'c', 'o', 'm', 0, 0, 0, 0 }, sizeof data); //success = nfc.mifareclassic_WriteDataBlock (4, data); // Try to read the contents of block 4 success = nfc.mifareclassic_ReadDataBlock(4, data); if (success) { // Data seems to have been read ... spit it out Serial.println("Reading Block 4:"); nfc.PrintHexChar(data, 16); Serial.println(""); // Wait a bit before reading the card again delay(1000); } else { Serial.println("Ooops ... unable to read the requested block. Try another key?"); } } else { Serial.println("Ooops ... authentication failed: Try another key?"); } } if (uidLength == 7) { // We probably have a Mifare Ultralight card ... Serial.println("Seems to be a Mifare Ultralight tag (7 byte UID)"); // Try to read the first general-purpose user page (#4) Serial.println("Reading page 4"); uint8_t data[32]; success = nfc.mifareultralight_ReadPage (4, data); if (success) { // Data seems to have been read ... spit it out nfc.PrintHexChar(data, 4); Serial.println(""); // Wait a bit before reading the card again delay(1000); } else { Serial.println("Ooops ... unable to read the requested page!?"); } } } }
And the modification i made in the library is as follows:
boolean Adafruit_NFCShield_I2C::readPassiveTargetID(uint8_t cardbaudrate, uint8_t * uid, uint8_t * uidLength) { pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET; //4A pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2 later) pn532_packetbuffer[2] = 0x03; //This is for type B card according to manual pn532_packetbuffer[3] = 0x00; //AFI is set to 0x00 if (! sendCommandCheckAck(pn532_packetbuffer, 4)) { #ifdef PN532DEBUG Serial.println("No card(s) read"); #endif return 0x0; // no cards read } // Wait for a card to enter the field uint8_t status = PN532_I2C_BUSY; #ifdef PN532DEBUG Serial.println("Waiting for IRQ (indicates card presence)"); #endif while (wirereadstatus() != PN532_I2C_READY) { delay(10); } Serial.println("Found a card");
It should print Found a card when the dynamic tag is brought close to the PN532 reader writer but it doesnt detect the tag. I am pretty sure i have connected the circuit correctly as i can write to the control register correctly and PN532 can detect mifare cards but not TI dynamic tag. Is there anything else that i have to take care of in order to make this communication a success? Thanks for the help!