Skip to main content
Visitor II
February 26, 2021
Solved

Problem with detection NFC-V tags on ST25R3916 (X-NUXLEO-NFC06A1 board)

  • February 26, 2021
  • 12 replies
  • 3798 views

In project based on exampleRfalPoller.c from library ST25NFC_Embedded_Lib_ST25R3916 and X-NUXLEO-NFC06A1 board I have problem with detection NFC-V tags.

After

 rfalNfcvPollerInitialize();                                        /* Initialize RFAL for NFC-V */

 rfalFieldOnAndStartGT();                                       /* As field is already On only starts GT timer */

 err = rfalNfcvPollerCheckPresence( &invRes );                                    /* Poll for NFC-V devices */

I always get err=4 (ERR_TIMEOUT)

Error is detected in file rfal_rfst25r3916.c, line 2190:

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) )

           {

//here this error is set               

               gRFAL.TxRx.status = ERR_TIMEOUT;

               gRFAL.TxRx.state = RFAL_TXRX_STATE_RX_FAIL;

               break;

           }

Tags NFC-A are detected correctly, so communication with ST25R3916 should be OK.

What can I do, to detect this tags correctly?

Sorry for may English - it's not my native language :)

    This topic has been closed for replies.
    Best answer by PHein.2

    Finally found the cause of the problem:

    In rfal_iso15693_2.c compiler didn't initialize stream_config structure. I added few lines, and now NFC-V tags are recognizes correctly.

    ReturnCode iso15693PhyConfigure(const iso15693PhyConfig_t* config, const struct iso15693StreamConfig ** needed_stream_config )
    {
     static struct iso15693StreamConfig stream_config = { /* MISRA 8.9 */
     .useBPSK = 0, /* 0: subcarrier, 1:BPSK */
     .din = 5, /* 2^5*fc = 423750 Hz: divider for the in subcarrier frequency */
     .dout = 7, /*!< 2^7*fc = 105937 : divider for the in subcarrier frequency */
     .report_period_length = 3, /*!< 8=2^3 the length of the reporting period */
     };
     
    /* added lines: */
     stream_config.useBPSK = 0;
     stream_config.din = 5;
     stream_config.dout = 7;
     stream_config.report_period_length = 3;
     
     /* make a copy of the configuration */
     ST_MEMCPY( (uint8_t*)&iso15693PhyConfig, (const uint8_t*)config, sizeof(iso15693PhyConfig_t));
     
     if ( config->speedMode <= 3U)
     { /* If valid speed mode adjust report period accordingly */
     stream_config.report_period_length = (3U - (uint8_t)config->speedMode);
     }
     else
     { /* If invalid default to normal (high) speed */
     stream_config.report_period_length = 3;
     }
     
     *needed_stream_config = &stream_config;
     
     return ERR_NONE;
    }

    Now I have to check in compiler manual why this behavior happen, and check if there are other places in code which can be affected by this problem.

    Thank you for your help and commitment!

    Regards,

    Piotr

    12 replies

    PHein.2Author
    Visitor II
    March 11, 2021

    It's XC32 Compiler v2.50 from Microchip.

    Code works properly also if this structure IS NOT declared as static:

    ReturnCode iso15693PhyConfigure(const iso15693PhyConfig_t* config, const struct iso15693StreamConfig ** needed_stream_config )
    {
     struct iso15693StreamConfig stream_config = { /* MISRA 8.9 */
     .useBPSK = 0, /* 0: subcarrier, 1:BPSK */
     .din = 5, /* 2^5*fc = 423750 Hz: divider for the in subcarrier frequency */
     .dout = 7, /*!< 2^7*fc = 105937 : divider for the in subcarrier frequency */
     .report_period_length = 3, /*!< 8=2^3 the length of the reporting period */
     };
     
     /* make a copy of the configuration */
     ST_MEMCPY( (uint8_t*)&iso15693PhyConfig, (const uint8_t*)config, sizeof(iso15693PhyConfig_t));
     
     if ( config->speedMode <= 3U)
     { /* If valid speed mode adjust report period accordingly */
     stream_config.report_period_length = (3U - (uint8_t)config->speedMode);
     }
     else
     { /* If invalid default to normal (high) speed */
     stream_config.report_period_length = 3;
     }
     
     *needed_stream_config = &stream_config;
     
     return ERR_NONE;
    }

    By the way - why this struct was declared as static?

    Regards,

    Piotr

    Technical Moderator
    March 11, 2021

    Hi Piotr,

    defining it as static saves a bit of stack and a bit of code. But no hard reason why it must be static. As a pointer to this struct is returned it must not be on the stack. Instead of function static it could also be global.

    This struct in its original version should end up in R/W section - please check if your startup code correctly copies the R/W ROM section to RAM?

    Regards, Ulysses

    Technical Moderator
    March 11, 2021

    Hi Piotr,

     MPLAB XC32 C/C++ Compiler conforms to C89 standard (see user guide §7). "Some features from the later standard, C99, are also supported. " Designated initializers in arrays or structures is a C99 feature. Therefore the support of this feature in this compiler may be limited. I would suggest to contact the provider of this compiler to report this problem.

    if you remove the static qualifier, I would suggest to make sure to have this structure as a global (as a pointer to this structure is used).

    Rgds

    BT