2025-02-28 4:17 AM
err = rfalNfcDiscover( &discParam );
if( err != RFAL_ERR_NONE )
{
printf("Err %d!\n\r", (int)err);
return false;
}
state = DEMO_ST_START_DISCOVERY;
void rfalNfcWorker( void )
{
ReturnCode err;
rfalWorker(); /* Execute RFAL process */
printf("State %d\n\r", (int)gNfcDev.state);
switch( gNfcDev.state )
{
Solved! Go to Solution.
2025-02-28 4:49 AM
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.
2025-02-28 4:43 AM
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
2025-02-28 4:49 AM
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.
2025-02-28 4:52 AM
I changed rfalworker to run at every loops. Now reading is about 1 second. Thanks!
2025-02-28 4:53 AM
Typically Logic analyzer trace let's one see multiple potential reasons. Here the reason is already obvious: You need to call the rfalNfcWorker() much more frequently. E.g. once every 1ms or even in a dense loop - could also be done depending on the state the RFAL is in.
Br, Ulysses