User Tools

Site Tools


tutorials:products:rfidnfc:faqs.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:products:rfidnfc:faqs.html [2012/07/25 16:10]
ktownsend
tutorials:products:rfidnfc:faqs.html [2016/01/28 18:05] (current)
Line 1: Line 1:
-====== ​Frequently Asked Questions  ​======+====== ​Moved! ​======
  
-Some of the more common questions on the forums related ​to the [[http://www.adafruit.com/​products/​364|PN532 NFC/RFID Breakout]] and [[http://www.adafruit.com/​products/​789|NFC Shield]]. +This tutorial has moved to [[http://learn.adafruit.com/​adafruit-pn532-rfid-nfc|http://learn.adafruit.com/​adafruit-pn532-rfid-nfc]]
- +
-===== Can I set a delay calling readPassiveTargetID() ?  ===== +
- +
-**Note:** This question only applies to the [[https://​github.com/​adafruit/​Adafruit_NFCShield_I2C|I2C Library]]. ​ The [[https://​github.com/​adafruit/​Adafruit-PN532|SPI library]] doesn'​t handle the timing the same way. +
- +
-readPassiveTargetID() intentionally waits around in a blocking delay until a card enters the magnetic field. ​ The reason for this blocking delay is to ensure a well-understood command/​response flow.  Once the magnetic field is activated and a read request is sent via readPassiveTargetID,​ you can keep sending new commands to the PN532, but the moment a card or tag enters the field, the PN532 will send a response to the initial read request, even if it's in the middle of some other response or activity. ​ To avoid having to debug this in SW, a blocking delay was implemented to keep the command/​response pattern as clear as possible. +
- +
-As a workaround to this blocking-delay limitation, **setPassiveActivationRetries(maxRetries)** was added to the latest NFC libraries to allow you to set a specific timeout after read requests. +
- +
-By default, the PN532 will wait forever for a card to enter the field. ​ By specifying a fixed number of retries via **MxRtyPassiveActivation** (see UM section 7.3.1 describing the **RFConfiguration** register, specifically CfgItem 5) the PN532 will abort the read request after specified number of attempts, and you can safely send new commands without worrying about mixing up response frames. ​ To wait forever, set MxRtyPassiveActivation to 0xFF.  To timeout after a fixed number of retries, set MxRtyPassiveActivation to anything less than 0xFF. +
- +
-Example Sketch: +
- +
-<​code>​ +
-#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(115200);​ +
-  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); +
-   +
-  // Set the max number of retry attempts to read from a card +
-  // This prevents us from waiting forever for a card, which is +
-  // the default behaviour of the PN532. +
-  nfc.setPassiveActivationRetries(0xFF);​ +
-   +
-  // configure board to read RFID tags +
-  nfc.SAMConfig();​ +
-     +
-  Serial.println("​Waiting for an ISO14443A card"​);​ +
-+
- +
-void loop(void) { +
-  boolean 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[0], &​uidLength);​ +
-   +
-  if (success) { +
-    Serial.println("​Found a card!"​);​ +
-    Serial.print("​UID Length: "​);​Serial.print(uidLength,​ DEC);​Serial.println("​ bytes"​);​ +
-    Serial.print("​UID Value: "); +
-    for (uint8_t i=0; i < uidLength; i++)  +
-    { +
-      Serial.print("​ 0x"​);​Serial.print(uid[i],​ HEX);  +
-    } +
-    Serial.println(""​);​ +
-    // Wait 1 second before continuing +
-    delay(1000);​ +
-  } +
-  else +
-  { +
-    // PN532 probably timed out waiting for a card +
-    Serial.println("​Timed out waiting for a card"​);​ +
-  } +
-+
-</​code>​ +
- +
-===== Hey wait ... is there something funny with the SVDD pin? ===== +
- +
-Indeed, good eye!  Unfortunately,​ both v1.0 and v1.3 of the breakout boards have a problem on the schematic. ​ SVDD is connected directly to 3.3V, but should be left floating since it is used to power secure modules. ​ This has no effect on the functionality of the boards, but does can some extra current consumption. ​ It will be fixed on the next revision of the board, but if you require the use of the secure modules (rare), you can simply cut the trace to the left of C22, which is the cap connected to SVDD (just follow the trace straight up from pin 37).+
/home/ladyada/public_html/wiki/data/attic/tutorials/products/rfidnfc/faqs.html.1343232604.txt.gz · Last modified: 2016/01/28 18:05 (external edit)