How to set Interrupt(IRQ) in RC522

Hai,
We are trying to develop RFID with GPS,we want to block all other processes while reading the RFID card.

We tried the below code for interrupt handling, but the card reading interrupt is not working.

basicinterruptCheck.ino (1.26 KB)

Please remember to use code tags when posting code.

#include “SPI.h”
#include “MFRC522.h”
#include <SoftwareSerial.h>
#include <String.h>

#define RST_PIN 9
#define SS_PIN 10
#define IRQ_PIN 2

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance

volatile bool cardPresent = false;

void setup()
{

Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
mfrc522.PCD_WriteRegister(MFRC522::ComIrqReg, 0x80); //Clear interrupts
mfrc522.PCD_WriteRegister(MFRC522::ComIEnReg, 0x7F); //Enable all interrupts
mfrc522.PCD_WriteRegister(MFRC522::DivIEnReg, 0x14);
/* setup the IRQ pin*/
// pinMode(IRQ_PIN, INPUT_PULLUP);
//pinMode(IRQ_PIN, INPUT);
pinMode(IRQ_PIN, INPUT);
digitalWrite(IRQ_PIN, HIGH);
Serial.println(F(“Ready…”));
attachInterrupt(digitalPinToInterrupt(IRQ_PIN),isr,CHANGE);
}

void loop()
{
if (cardPresent)
{
Serial.println(F(“Interrupt fOUND”));
mfrc522.PCD_WriteRegister(MFRC522::ComIrqReg, 0x80); //Clear interrupts
cardPresent = false;
}

}

void isr()
{
cardPresent = true;
Serial.println(F("INSIDE Interrupt "));
}