cancel
Showing results for 
Search instead for 
Did you mean: 

X-NUCLEO-NFCC06A1: long time to read RFID Card Tag

FNana.1
Associate II

I using the Demo code for ST25R3916 It takes long time to read RFID Card Tag , what might be causing that ?

I am using X-NUCLEO-NFCC06A1 eval board with ST25R3916 CHIP

37 REPLIES 37
FNana.1
Associate II

Hi Ulysses ,

so in void* pthread_func()

  1. Sorry my mistake on this " ssize_t s = read(ST25R_INT_PORT, &event, sizeof(event)) " I was using the wrong file descriptor
  2. I don't have this library libgpiod built in our current linux image therefore struct gpioevent_data is not detected
  3. I have replaced struct gpioevent_data by a simple variable char event[512] given that it is not used at all in the code
  4. below is the final replacement
       /* poll interrupt line forever */
       while (true)
       {
           /* read() blocks the calling thread until some data becomes available */
           /* The port is used to contain the file descriptor of a given pin! */
          ssize_t s = read(fd_readGPIO, &event, sizeof(event));
           /* Call RFAL Isr */
           platformIsr();
 
           /* Unlock Semaphore */
           sem_post(&rfal_sem);
       }

FNana.1
Associate II

sorry i have clicked on answer too soon. this is the following .

      while (true)
       {
           /* read() blocks the calling thread until some data becomes available */
           /* The port is used to contain the file descriptor of a given pin! */
          ssize_t s = read(fd_readGPIO, &event, sizeof(event));
           /* Call RFAL Isr */
           platformIsr();
 
           /* Unlock Semaphore */
           sem_post(&rfal_sem);
       }

I think it still going to play the same role as the original one , what do you think please ?

We don't want for now to build the  libgpiod in our current image as we don't have time and we want to make a very minimal changes .

Many thanks

Hi Franklin,

Not sure, above code looks more like polling the GPIO state and not the events(interrupts) coming from it.

AFAIK we are not using the userspace libgpiod but are relying on low level ioctl for accessing the character device interface.

If you want to use the deprecated sysfs interface then I could send you the previous version of STSW-ST25R013. Just let me know.

Regards, Ulysses

FNana.1
Associate II

Hi Ulysses ,

Yes please that would be appreciated to send me the previous version of STSW-ST25R013 ( with deprecated sysfs) because we are currently using the sysfs we don't have libgpiod.

Many thanks

FNana.1
Associate II

Hi Ulysses ,

Here is the brief state of the issue

Case 1 :

  • When card is presented some it works normally ( detect presence of card - read ....etc fine )

Case 2 : ( Issue 1 )

  • Work fine ( detect card and read perfect
  • If you remove the card and present it again sometime it is still fine
  • If you remove the card and present it again several time by repeating sometime it takes several secs ( less than min ) to detect and read card. i falls into the case below in this function static void rfalTransceiveRx( void ) : if( ((irqs & ST25R3916_IRQ_MASK_NRE) != 0U) && ((irqs & ST25R3916_IRQ_MASK_RXS) == 0U) )
case RFAL_TXRX_STATE_RX_WAIT_RXS:
            
            /*******************************************************************************/
            irqs = st25r3916GetInterrupt( (ST25R3916_IRQ_MASK_RXS | ST25R3916_IRQ_MASK_NRE | ST25R3916_IRQ_MASK_EOF) );
            if( irqs == ST25R3916_IRQ_MASK_NONE )
            {
                break;  /* No interrupt to process */
            }
            
            /* Only raise Timeout if NRE is detected with no Rx Start (NRT EMV mode) */
            if( ((irqs & ST25R3916_IRQ_MASK_NRE) != 0U) && ((irqs & ST25R3916_IRQ_MASK_RXS) == 0U) )
            {
                gRFAL.TxRx.status = ERR_TIMEOUT;
                gRFAL.TxRx.state  = RFAL_TXRX_STATE_RX_FAIL;
                //<<< ISSUE IS HERE : Keeps falling into this althougth the card is presented in  the RF field 
                break;
            }
            
            /* Only raise Link Loss if EOF is detected with no Rx Start */
            if( ((irqs & ST25R3916_IRQ_MASK_EOF) != 0U) && ((irqs & ST25R3916_IRQ_MASK_RXS) == 0U) )
            {
                /* In AP2P a Field On has already occurred - treat this as timeout | mute */
                gRFAL.TxRx.status = ( rfalIsModeActiveComm( gRFAL.mode ) ? ERR_TIMEOUT : ERR_LINK_LOSS );
                gRFAL.TxRx.state  = RFAL_TXRX_STATE_RX_FAIL;
                break;
            }
            
            if( (irqs & ST25R3916_IRQ_MASK_RXS) != 0U )
            {
                /*******************************************************************************/
                /* REMARK: Silicon workaround ST25R3916 Errata #TBD                            */
                /* Rarely on corrupted frames I_rxs gets signaled but I_rxe is not signaled    */
                /* Use a SW timer to handle an eventual missing RXE                            */
                rfalTimerStart( gRFAL.tmr.RXE, RFAL_NORXE_TOUT );
                /*******************************************************************************/
                
                gRFAL.TxRx.state  = RFAL_TXRX_STATE_RX_WAIT_RXE;
            }
            else
            {
                gRFAL.TxRx.status = ERR_IO;
                gRFAL.TxRx.state  = RFAL_TXRX_STATE_RX_FAIL;
                break;
            }
            
            /* remove NRE that might appear together (NRT EMV mode), and remove RXS, but keep EOF if present for next state */
            irqs &= ~(ST25R3916_IRQ_MASK_RXS | ST25R3916_IRQ_MASK_NRE);
            
            /* fall through */
            

It can stay there for less than a minute before reading the card

Case 3: ( Issue 2 Maybe ?? )

  • Some time when card is presented in the RF field and removed quickly ( it is relative ) , it successfully detects the Technology  err = rfalNfcaPollerTechnologyDetection( gNfcDev.disc.compMode, &sensRes );/* Poll for NFC-A devices */ But doesn't find thE NFCA Passive ISO-DEP device UID

static ReturnCode rfalNfcPollTechDetetection( void )

 /*******************************************************************************/
    /* Passive NFC-A Technology Detection                                          */
    /*******************************************************************************/
    if( ((gNfcDev.disc.techs2Find & RFAL_NFC_POLL_TECH_A) != 0U) && ((gNfcDev.techs2do & RFAL_NFC_POLL_TECH_A) != 0U) )
    {
        
    #if RFAL_FEATURE_NFCA
        
        rfalNfcaSensRes sensRes;            
        
        if( !gNfcDev.isTechInit )
        {
            EXIT_ON_ERR( err, rfalNfcaPollerInitialize() );                            /* Initialize RFAL for NFC-A */
            EXIT_ON_ERR( err, rfalFieldOnAndStartGT() );                               /* Turns the Field On and starts GT timer */
            gNfcDev.isTechInit = true;
        }
        
        if( rfalIsGTExpired() )                                                        /* Wait until Guard Time is fulfilled */
        {
            err = rfalNfcaPollerTechnologyDetection( gNfcDev.disc.compMode, &sensRes );/* Poll for NFC-A devices */
            if( err == ERR_NONE )
            {
                gNfcDev.techsFound |= RFAL_NFC_POLL_TECH_A;
            }
            else //Testing added to be removed
            {
               // platformLog("rfalNfcPollTechDetetection error code :  %d errno %d\r\n", err, errno);
            }
            gNfcDev.isTechInit = false;
            gNfcDev.techs2do  &= ~RFAL_NFC_POLL_TECH_A;
        }
    
        return ERR_BUSY;
 
    #endif /* RFAL_FEATURE_NFCA */
    }

Case 3( GENERAL ) :

Is that normal that when it manage to detect and read the card UID successfully ( no delay ...) if fall into this case below

ReturnCode rfalISO14443ATransceiveShortFrame( rfal14443AShortFrameCmd txCmd, uint8_t* rxBuf, uint8_t rxBufLen, uint16_t* rxRcvdLen, uint32_t fwt )
{
 ---
---
/* Wait for TXE */
    if( st25r3916WaitForInterruptsTimed( ST25R3916_IRQ_MASK_TXE, static_cast<uint16_t>(MAX( rfalConv1fcToMs( fwt ), RFAL_ST25R3916_SW_TMR_MIN_1MS ) )) == 0U )
    {
         // HERE : it falls here sometime after card detected and read UID read successfully 
        ret = ERR_IO;
    }
    else
    {
        /*Check if Observation Mode is enabled and set it on ST25R391x */
        rfalCheckEnableObsModeRx();
        
        /* Jump into a transceive Rx state for reception (bypass Tx states) */
        gRFAL.state       = RFAL_STATE_TXRX;
        gRFAL.TxRx.state  = RFAL_TXRX_STATE_RX_IDLE;
        gRFAL.TxRx.status = ERR_BUSY;
        
        /* Execute Transceive Rx blocking */
 
        ret = rfalTransceiveBlockingRx();
         platformLog("rfal ISO14443ATransceiveShortFrame %d \r\n", ret);
    }
--
--
--
}

ps : I have used scope , everything looks OK ( data flowing as expected ....)

So far i can't resume the work like this : It is Randomly working still some stuffs ( see above cases ) to fix

Many thanks

FNana.1
Associate II

Hi

General questions please , there are 2 mode of detecting card :

  1. Polling : more CUP related issue : waste of CPU
  2. Wake-up

Is there any difference in term of response time to detect and read the card uid ?

How can we switch to configure the demo to be used with Wake up mode ?

Thanks

Hi,

ERR_IO is not normal and indicates an issue on SPI/IRQ. The other two cases you hinted are likely just different manifestations of the same problem.

As hinted before Logic Analyzer traces are key in such a case.

Regards, Ulysses

Hi,

Wake-up is completely different from Polling: Wake-up reacts just to detunings of the LC-tank. Cards, metal, temperature change may already trigger it. It is a way of saving power to not do polling unless there is indication that there may be a card.

Regards, Ulysses