Skip to main content
Visitor II
February 28, 2025
Solved

ST25R3911 Long time to read tag

  • February 28, 2025
  • 1 reply
  • 614 views
I want to trigger a RFID reading at certain intervals using ST25R3911 and from this I want a RFID reading to be done within 1 second.
 
When I try this in RFAL (using democode for polling):

 

err = rfalNfcDiscover( &discParam );
if( err != RFAL_ERR_NONE )
{
printf("Err %d!\n\r", (int)err);
return false;
}
state = DEMO_ST_START_DISCOVERY;

 

 
 
It takes about 10 second to do a RFID reading which is way too long.
 
When analyzing what RFAL is doing this is what I see when checking gNfcDev.state in rfalNfcWorker:

 

void rfalNfcWorker( void )
{
 ReturnCode err;
 
 rfalWorker(); /* Execute RFAL process */
 
 printf("State %d\n\r", (int)gNfcDev.state);
 switch( gNfcDev.state )
 { 

 

 
RFAL_NFC_STATE_POLL_TECHDETECT - about 5 seconds
RFAL_NFC_STATE_POLL_COLAVOIDANCE - about 4 seconds
 
Which is obvisously too long for a user to hold an RFID card in front of the reader. What is RFAL doing and how can I reduce time from request reading to reading done within 1 second? I see several timers are created in state 10 = RFAL_NFC_STATE_POLL_TECHDETECT 
 
.State 10
Timer 30 ms
.State 10
Timer 1154 ms
#Timer# 154 ms
.State 10
Timer 30 ms
.State 10
Timer 5 ms
.State 10
Timer 1000 ms
T#imer 1 ms
.Timer 1001 ms
Stat#e 10
#.State 10
.State 10
 
And in state 11 = RFAL_NFC_STATE_POLL_COLAVOIDANCE  several timers of 1000 ms are created:
.State 11
Timer 5 ms
.State 11
Timer 1000 ms
T#imer 1 ms
.State 11
Timer 1000 ms
##.State 11
.State 11
.State 11
.State 11
Timer 1000 ms
#.State 11
.State 11
.State 11
.State 11
Timer 1000 ms
##.State 11
.State 11
.State 11
.State 11
Timer 1000 ms
#.State 11
    This topic has been closed for replies.
    Best answer by RFlod.2

    Total duration is as in example 1000

     if( err == RFAL_ERR_NONE )
     {
     rfalNfcDefaultDiscParams( &discParam );
     
     discParam.devLimit = 1U;
     
     ST_MEMCPY( &discParam.nfcid3, NFCID3, sizeof(NFCID3) );
     ST_MEMCPY( &discParam.GB, GB, sizeof(GB) );
     discParam.GBLen = sizeof(GB);
     discParam.p2pNfcaPrio = true;
    
     discParam.notifyCb = demoNotif;
     discParam.totalDuration = 1000U;
     discParam.techs2Find = RFAL_NFC_TECH_NONE; 

     

    Timing in platform

    #define platformTimerCreate( t ) timerCalculateTimer(t) /*!< Create a timer with the given time (ms) */
    #define platformTimerIsExpired( timer ) timerIsExpired(timer) /*!< Checks if the given timer is expired */
    #define platformTimerDestroy( timer ) /*!< Stop and release the given timer */
    #define platformDelay( t ) HW_TIM_Delay( t ) /*!< Performs a delay for the given time (ms) */
    
    #define platformGetSysTick() HW_TIM_GetTick() /*!< Get System Tick ( 1 tick = 1 ms) */

     

    My functions HW_TIM_Delay and HW_TIM_GetTick works in 1 ms resolution.

    rfalworker is exectued every 200 ms.

     

    I do not think it is SPI speed which is the problem.

     

     

    1 reply

    Technical Moderator
    February 28, 2025

    Hi,

    the timing should be defined by parameters inside discParam. What is the totalDuration set in there?

    On our demos if you set reasonable values for totalDuration, maybe >100ms then the demo will achieve that timing pretty accurately.

    If you wish for a certain value then also the frequency of rfalWorker(), SPI speed and accuracy of platformTimer()/Delay() will affect the actual timing. Maybe some issue here in your implementation. Best if you could share a logic analyzer trace of SPI lines + IRQ line.

    BR, Ulysses

    RFlod.2AuthorAnswer
    Visitor II
    February 28, 2025

    Total duration is as in example 1000

     if( err == RFAL_ERR_NONE )
     {
     rfalNfcDefaultDiscParams( &discParam );
     
     discParam.devLimit = 1U;
     
     ST_MEMCPY( &discParam.nfcid3, NFCID3, sizeof(NFCID3) );
     ST_MEMCPY( &discParam.GB, GB, sizeof(GB) );
     discParam.GBLen = sizeof(GB);
     discParam.p2pNfcaPrio = true;
    
     discParam.notifyCb = demoNotif;
     discParam.totalDuration = 1000U;
     discParam.techs2Find = RFAL_NFC_TECH_NONE; 

     

    Timing in platform

    #define platformTimerCreate( t ) timerCalculateTimer(t) /*!< Create a timer with the given time (ms) */
    #define platformTimerIsExpired( timer ) timerIsExpired(timer) /*!< Checks if the given timer is expired */
    #define platformTimerDestroy( timer ) /*!< Stop and release the given timer */
    #define platformDelay( t ) HW_TIM_Delay( t ) /*!< Performs a delay for the given time (ms) */
    
    #define platformGetSysTick() HW_TIM_GetTick() /*!< Get System Tick ( 1 tick = 1 ms) */

     

    My functions HW_TIM_Delay and HW_TIM_GetTick works in 1 ms resolution.

    rfalworker is exectued every 200 ms.

     

    I do not think it is SPI speed which is the problem.

     

     

    RFlod.2Author
    Visitor II
    February 28, 2025

    I changed rfalworker to run at every loops. Now reading is about 1 second. Thanks!