Programming NFC (PN352) in timer interrupt


I bought this NFC card:

Had no problem to use it with basic functions of reading and writing data.
The problem began once I put the NFC commands in a interrupt function.

I noticed that all the problems begin with this command:
nfc.InListPassiveTarget (which read basic information like ID of NFC tag).

Once this command exist in the interrupt function, void setup gets stuck right when the timer is declared.

any ideas why?

How to use this forum

Read this before posting a programming question

Where is your code?

There are some things you can't do in interrupt functions (and have them work).

Sorry about that. Here is the code:

#include "TimerFive.h"
#include "nfc.h"    

NFC_Module nfc;

#define dt 0.1
#define timerInterval dt*1000000

void(* resetFunc) (void) = 0;                               //declare reset function

void setup(){
 nfc.begin();                                                    //begin NFC
  uint32_t versiondata = nfc.get_version();            //get NFC version
  if (! versiondata) {                                          //not found. something's wrong
     resetFunc();                                                //reset Arduino 
      while (1); 
  Serial.println("check 0 - NFC OK");
   nfc.SAMConfiguration();                                  //set NFC Configuration
  Serial.println("check 1 - NFC Configured");
  Timer5.initialize(timerInterval);                         // initialize timer5
  Serial.println("check 2 - Timer Initialized");
  Timer5.attachInterrupt(inter);                           // attach inter  
  Serial.println("check 3 - inter attached");

void inter(){
  u8 buf[32];
  if (millis() >10000)
  Serial.println("check 4 - read success");

I tried several codes. This code is after some changes.
Before I added the delays between the Serial Prints, the program froze after printing check 1.
With the delays - check 2 was printed and then froze.

In the last change, I added the " if (millis() >10000) ".
The result was that check 3 was also printed before program froze.

check 4 was never printed.

I suspect that there is an interrupt in the command "nfc.InListPassiveTarget" that conflict with Timer5 interrupt. Is that right? and if so, what can I do about it?

Don't do serial prints inside an ISR.