From 2f57235c875570bb173f62ce8badb93c90ff2d7a Mon Sep 17 00:00:00 2001 From: gpancot Date: Sat, 9 Apr 2016 19:00:12 +0200 Subject: [PATCH] Added files via upload avoid spourious interrupt --- examples/MinimalInterrupt/MinimalInterrupt.ino | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/MinimalInterrupt/MinimalInterrupt.ino b/examples/MinimalInterrupt/MinimalInterrupt.ino index 480fe0a..38ff9eb 100644 --- a/examples/MinimalInterrupt/MinimalInterrupt.ino +++ b/examples/MinimalInterrupt/MinimalInterrupt.ino @@ -30,7 +30,7 @@ #include #define RST_PIN 9 // Configurable, see typical pin layout above -#define SS_PIN 3 // Configurable, see typical pin layout above +#define SS_PIN 10 // Configurable, see typical pin layout above #define IRQ_PIN 2 MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. @@ -71,13 +71,13 @@ void setup() { /*Activate the interrupt*/ attachInterrupt(digitalPinToInterrupt(IRQ_PIN), readCard, FALLING); - - Serial.println("End setup"); - + do{ //clear a spourious interrupt at start ; }while(!bNewInt); bNewInt = false; + + Serial.println("End setup"); } /** @@ -86,7 +86,6 @@ void setup() { void loop() { if(bNewInt){ //new read interrupt - bNewInt = false; Serial.print("Interrupt. "); mfrc522.PICC_ReadCardSerial(); //read the tag data // Show some details of the PICC (that is: the tag/card) @@ -95,6 +94,8 @@ void loop() { Serial.println(); clearInt(mfrc522); + mfrc522.PICC_HaltA(); + bNewInt = false; } // The receiving block needs regular retriggering (tell the tag it should transmit??) @@ -135,3 +136,4 @@ void clearInt(MFRC522 mfrc522){ mfrc522.PCD_WriteRegister(mfrc522.ComIrqReg,0x7F); } +