NxpNci_WaitForDiscoveryNotification function is not working with ISO15693 on SW6705 nfc_example_RW

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NxpNci_WaitForDiscoveryNotification function is not working with ISO15693 on SW6705 nfc_example_RW

1,015 Views
takshpatel
Contributor II

Hello Devlopers,

We are currently developing a product where we are looking to interface PN7160 NFC reader with STM32WL micro controller to communicate with ST25DV04KC dynamic tag for sending and receiving data between NFC reader and ST25DV tag using the mailbox feature of ST25DV.

For this purpose i am using your example of SW6705 with ISO15693 protocol and nfc_example_RW function for read and write.

From this example i am able to connect the NxpNci_Connect,NxpNci_ConfigureSettings and in NxpNci_ConfigureMode i am using the NXPNCI_MODE_RW.

After that NxpNci_StartDiscovery can be done and im waiting for the NxpNci_WaitForDiscoveryNotification but i am not getting the notification and my code will stop at the while loop, 

my code snipet is given below,

 

bool NxpNci_WaitForDiscoveryNotification(NxpNci_RfIntf_t *pRfIntf)
{
    uint8_t NCIRfDiscoverSelect[] = {0x21, 0x04, 0x03, 0x01, PROT_ISODEP, INTF_ISODEP};
    uint8_t Answer[MAX_NCI_FRAME_SIZE];
    uint16_t AnswerSize;

#ifndef REMOVE_P2P_SUPPORT
    uint8_t NCIStopDiscovery[] = {0x21, 0x06, 0x01, 0x00};
    uint8_t NCIRestartDiscovery[] = {0x21, 0x06, 0x01, 0x03};
    uint8_t saved_NTF[7];
wait:
#endif //#ifndef REMOVE_P2P_SUPPORT
    do
    {
        if(NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_INFINITE) == NXPNCI_ERROR) return NXPNCI_ERROR;
    }while ((Answer[0] != 0x61) || ((Answer[1] != 0x05) && (Answer[1] != 0x03)));

    gNextTag_Protocol = PROT_UNDETERMINED;

    /* Is RF_INTF_ACTIVATED_NTF ? */
    if (Answer[1] == 0x05)
    {
        pRfIntf->Interface = Answer[4];
        pRfIntf->Protocol = Answer[5];
        pRfIntf->ModeTech = Answer[6];
        pRfIntf->MoreTags = false;
        NxpNci_FillInterfaceInfo(pRfIntf, &Answer[10]);

#ifndef REMOVE_P2P_SUPPORT
        /* Verifying if not a P2P device also presenting T4T emulation */
        if ((pRfIntf->Interface == INTF_ISODEP) && (pRfIntf->Protocol == PROT_ISODEP) && ((pRfIntf->ModeTech & MODE_LISTEN) != MODE_LISTEN))
        {
            memcpy(saved_NTF, Answer, sizeof(saved_NTF));
            while(1)
            {
                /* Restart the discovery loop */ 
                NxpNci_HostTransceive(NCIRestartDiscovery, sizeof(NCIRestartDiscovery), Answer, sizeof(Answer), &AnswerSize);
                NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS);

                /* Wait for discovery */
                do NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_1S);
                while ((AnswerSize == 4) && (Answer[0] == 0x60) && (Answer[1] == 0x07));

                if ((AnswerSize != 0) && (Answer[0] == 0x61) && (Answer[1] == 0x05))
                {
                    /* Is same device detected ? */
                    if (memcmp(saved_NTF, Answer, sizeof(saved_NTF)) == 0) break;
                    /* Is P2P detected ? */
                    if (Answer[5] == PROT_NFCDEP)
                    {
                        pRfIntf->Interface = Answer[4];
                        pRfIntf->Protocol = Answer[5];
                        pRfIntf->ModeTech = Answer[6];
                        pRfIntf->MoreTags = false;
                        NxpNci_FillInterfaceInfo(pRfIntf, &Answer[10]);
                        break;
                    }
                }
                else
                {
                    if (AnswerSize != 0)
                    {
                        /* Flush any other notification  */
                        while(Answer != 0) NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS);
                        /* Restart the discovery loop */ 
                        NxpNci_HostTransceive(NCIRestartDiscovery, sizeof(NCIRestartDiscovery), Answer, sizeof(Answer), &AnswerSize);
                        NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS);
                    }
                    goto wait;
                }
            }
        }
#endif //#ifndef REMOVE_P2P_SUPPORT
    }
    else /* RF_DISCOVER_NTF */
    {
        pRfIntf->Interface = INTF_UNDETERMINED;
        pRfIntf->Protocol = Answer[4];
        pRfIntf->ModeTech = Answer[5];
        pRfIntf->MoreTags = true;

        /* Get next NTF for further activation */
        do {
            if(NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS) == NXPNCI_ERROR)    return NXPNCI_ERROR;
        } while ((Answer[0] != 0x61) || (Answer[1] != 0x03));
        gNextTag_Protocol = Answer[4];

        /* Remaining NTF ? */
        while(Answer[AnswerSize-1] == 0x02) NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS);

        /* In case of multiple cards, select the first one */
        NCIRfDiscoverSelect[4] = pRfIntf->Protocol;
        if (pRfIntf->Protocol == PROT_ISODEP) NCIRfDiscoverSelect[5] = INTF_ISODEP;
        else if (pRfIntf->Protocol == PROT_NFCDEP) NCIRfDiscoverSelect[5] = INTF_NFCDEP;
        else if (pRfIntf->Protocol == PROT_MIFARE) NCIRfDiscoverSelect[5] = INTF_TAGCMD;
        else NCIRfDiscoverSelect[5] = INTF_FRAME;
        NxpNci_HostTransceive(NCIRfDiscoverSelect, sizeof(NCIRfDiscoverSelect), Answer, sizeof(Answer), &AnswerSize);
        if ((Answer[0] == 0x41) || (Answer[1] == 0x04) || (Answer[3] == 0x00))
        {
            NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS);
            if ((Answer[0] == 0x61) || (Answer[1] == 0x05))
            {
                pRfIntf->Interface = Answer[4];
                pRfIntf->Protocol = Answer[5];
                pRfIntf->ModeTech = Answer[6];
                NxpNci_FillInterfaceInfo(pRfIntf, &Answer[10]);
            }
#ifndef REMOVE_P2P_SUPPORT
            /* In case of P2P target detected but lost, inform application to restart discovery */
            else if (pRfIntf->Protocol == PROT_NFCDEP)
            {
                /* Restart the discovery loop */
                NxpNci_HostTransceive(NCIStopDiscovery, sizeof(NCIStopDiscovery), Answer, sizeof(Answer), &AnswerSize);
                NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_100MS);
                NxpNci_HostTransceive(NCIStartDiscovery, NCIStartDiscovery_length, Answer, sizeof(Answer), &AnswerSize);
                goto wait;
            }
#endif //#ifndef REMOVE_P2P_SUPPORT
        }
    }

    /* In case of unknown target align protocol information */
    if (pRfIntf->Interface == INTF_UNDETERMINED) pRfIntf->Protocol = PROT_UNDETERMINED;

    return NXPNCI_SUCCESS;
}

 

 At this line my code is stop continously poll the discovery notification

 

    do
    {
        if(NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_INFINITE) == NXPNCI_ERROR) return NXPNCI_ERROR;
    }while ((Answer[0] != 0x61) || ((Answer[1] != 0x05) && (Answer[1] != 0x03)));

 

 

The Answer is received is,

Answer[0] = 0x61,

Answer[1]=0x23,

 

Actually Answer[1] is received 0x05 or 0x03 but i get ox23,

So please suggest me i am doing Right or wrong configurations or not. 

 

0 Kudos
6 Replies

963 Views
takshpatel
Contributor II

Thank you Daniel for response.

Below i have given the NCI Debug logs:

 

[15:05:50:666] PN7160 interfacing code
[15:05:50:925] Scanning I2C bus:
[15:05:50:974] ---------------------------------------0x28-----------------------------------------------------------------------------------0x7C---
[15:05:57:750] NCI >> 20 00 01 01 
[15:05:57:805] NCI << 40 00 01 00 
[15:05:57:811] NCI << 60 00 09 02 01 20 04 04 71 12 50 05 
[15:05:57:816] Firmware Version: 12.50.5
[15:05:57:829] NCI >> 20 01 02 00 00 
[15:05:57:849] NCI << 40 01 1e 00 1a 7e 06 03 01 d0 02 ff ff 01 ff 00 08 00 00 01 00 02 00 03 00 80 00 82 00 83 ...
[15:05:58:706] NCI >> 2f 00 01 00 
[15:05:58:721] NCI << 4f 00 01 00 
[15:05:58:735] NCI >> 20 02 05 01 00 02 fe 01 
[15:05:58:751] NCI << 40 02 02 00 00 
[15:05:58:765] NCI >> 20 03 03 01 a0 14 
[15:05:58:785] NCI << 40 03 25 00 01 a0 14 20 57 65 64 20 41 70 72 20 32 36 20 31 37 3a 31 35 3a 35 39 20 32 30 ...
[15:05:58:806] NCI >> 20 00 01 00 
[15:05:58:821] NCI << 40 00 01 00 
[15:05:58:827] NCI << 60 00 09 02 00 20 04 04 71 12 50 05 
[15:05:58:842] NCI >> 20 01 02 00 00 
[15:05:58:861] NCI << 40 01 1e 00 1a 7e 06 03 01 d0 02 ff ff 01 ff 00 08 00 00 01 00 02 00 03 00 80 00 82 00 83 ...
[15:05:59:721] NCI >> 2f 02 00 
[15:05:59:736] NCI << 4f 02 05 00 00 01 aa dd 
[15:05:59:753] NCI >> 21 00 10 05 01 01 01 02 01 01 03 01 01 04 01 02 80 01 80 
[15:05:59:772] NCI << 41 00 01 00 
[15:06:00:719] NCI >> 21 03 03 01 06 01 
[15:06:00:733] NCI << 41 03 01 00 
[15:06:00:735] 
[15:06:00:746] WAITING FOR DEVICE DISCOVERY
[15:06:02:616] NCI << 61 23 00 
[15:06:02:630] NCI << 61 23 00 

 

In NxpNci_WaitForDiscoveryNotification we get stuck at the following code snippet, the response we are receiving is 0x61 0x23 0x00 but it requires first 2nd byte to be 0x03.

    do
    {
        if(NxpNci_WaitForReception(Answer, sizeof(Answer), &AnswerSize, TIMEOUT_INFINITE) == NXPNCI_ERROR) return NXPNCI_ERROR;
    }while ((Answer[0] != 0x61) || ((Answer[1] != 0x05) && (Answer[1] != 0x03)));

 

Please help me with this issue  of unable to discover ISO15693 based NFC tags in RW mode.

 

0 Kudos

944 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi @takshpatel 

 

I would suggest you check power supply and settings in Nfc_settings.h.

Error you are getting is this one.

danielchen_0-1683191804060.png

 

Regards

Daniel

 

0 Kudos

924 Views
takshpatel
Contributor II

Hello Daniel,

Thanks for the response @danielchen 

Below is the NFC settings we are using for our NFC example: 

I have just changed the the NXP_TVDD_CONF to 1 as the VDD is 3.3V. 

So please check the below settings and update me wheather i am doing right or wrong settings?

/***** NFC dedicated setting ****************************************/

/* Following definitions specifies which settings will apply when NxpNci_ConfigureSettings()
 * API is called from the application
 */
#define NXP_CORE_CONF        1
#define NXP_CORE_STANDBY     1
#define NXP_CORE_CONF_EXTN   1
#define NXP_CLK_CONF         1 // 1=Xtal, 2=PLL
#define NXP_TVDD_CONF        1 // 1=3.3V, 2=4.75V
#define NXP_RF_CONF          1

uint8_t NxpNci_SettingCurrentTS[32] = __TIMESTAMP__;

#if NXP_CORE_CONF
/* NCI standard dedicated settings
 * Refer to NFC Forum NCI standard for more details
 */
uint8_t NxpNci_CORE_CONF[]={0x20, 0x02, 0x05, 0x01,         /* CORE_SET_CONFIG_CMD */
    0x00, 0x02, 0xFE, 0x01                                  /* TOTAL_DURATION */
};
#endif

#if NXP_CORE_CONF_EXTN
/* NXP-NCI extension dedicated setting
 * Refer to NFC controller User Manual for more details
 */
uint8_t NxpNci_CORE_CONF_EXTN[]={0x20, 0x02, 0x05, 0x01,    /* CORE_SET_CONFIG_CMD */
    0xA0, 0x40, 0x01, 0x00                                  /* TAG_DETECTOR_CFG */
};
#endif

#if NXP_CORE_STANDBY
/* NXP-NCI standby enable setting
 * Refer to NFC controller User Manual for more details
 */
uint8_t NxpNci_CORE_STANDBY[]={0x2F, 0x00, 0x01, 0x00};    /* last byte indicates enable/disable */
#endif

#if NXP_CLK_CONF
/* NXP-NCI CLOCK configuration
 * Refer to NFC controller Hardware Design Guide document for more details
 */
 #if (NXP_CLK_CONF == 1)
 /* Xtal configuration */
 uint8_t NxpNci_CLK_CONF[]={0x20, 0x02, 0x05, 0x01,        /* CORE_SET_CONFIG_CMD */
   0xA0, 0x03, 0x01, 0x08                                  /* CLOCK_SEL_CFG */
 };
 #else
 /* PLL configuration */
 uint8_t NxpNci_CLK_CONF[]={0x20, 0x02, 0x09, 0x02,        /* CORE_SET_CONFIG_CMD */
   0xA0, 0x03, 0x01, 0x11,                                 /* CLOCK_SEL_CFG */
   0xA0, 0x04, 0x01, 0x01                                  /* CLOCK_TO_CFG */
 };
 #endif
#endif

#if NXP_TVDD_CONF
/* NXP-NCI TVDD configuration
 * Refer to NFC controller Hardware Design Guide document for more details
 */
 #if (NXP_TVDD_CONF == 1)
 /* TXLDO output voltage set to 3.3V */
 uint8_t NxpNci_TVDD_CONF[]={0x20, 0x02, 0x0F, 0x01, 0xA0, 0x0E, 0x0B, 0x11, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0xD0, 0x0C};
 #else
 /* TXLDO output voltage set to 4.75V */
 uint8_t NxpNci_TVDD_CONF[]={0x20, 0x02, 0x0F, 0x01, 0xA0, 0x0E, 0x0B, 0x11, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0xD0, 0x0C};
 #endif
#endif

#if NXP_RF_CONF
/* NXP-NCI RF configuration
 * Refer to NFC controller Antenna Design and Tuning Guidelines document for more details
 */
/* Following configuration relates to performance optimization of OM27160 NFC Controller demo kit */
uint8_t NxpNci_RF_CONF[]={0x20, 0x02, 0x4C, 0x09,
  0xA0, 0x0D, 0x03, 0x78, 0x0D, 0x02,
  0xA0, 0x0D, 0x03, 0x78, 0x14, 0x02,
  0xA0, 0x0D, 0x06, 0x4C, 0x44, 0x65, 0x09, 0x00, 0x00,
  0xA0, 0x0D, 0x06, 0x4C, 0x2D, 0x05, 0x35, 0x1E, 0x01,
  0xA0, 0x0D, 0x06, 0x82, 0x4A, 0x55, 0x07, 0x00, 0x07,
  0xA0, 0x0D, 0x06, 0x44, 0x44, 0x03, 0x04, 0xC4, 0x00,
  0xA0, 0x0D, 0x06, 0x46, 0x30, 0x50, 0x00, 0x18, 0x00,
  0xA0, 0x0D, 0x06, 0x48, 0x30, 0x50, 0x00, 0x18, 0x00,
  0xA0, 0x0D, 0x06, 0x4A, 0x30, 0x50, 0x00, 0x08, 0x00
};
#endif

 

Thanks & Regards

Taksh Patel.

0 Kudos

814 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi @takshpatel 

I would suggest you refer to AN13892,   chapter 9

 https://www.nxp.com/docs/en/application-note/AN13892.pdf

 

Regards

Daniel

0 Kudos

873 Views
takshpatel
Contributor II

Hello Daniel,

Thanks for response @danielchen 

I have just changed the the NXP_TVDD_CONF to 1 as the VDD is 3.3V.

Below is the NFC settings we are using for our NFC example: 

Please verify my NFC settings here, and update me wheather I am making any mistake or not?

 

 

/***** NFC dedicated setting ****************************************/

/* Following definitions specifies which settings will apply when NxpNci_ConfigureSettings()
 * API is called from the application
 */
#define NXP_CORE_CONF        1
#define NXP_CORE_STANDBY     1
#define NXP_CORE_CONF_EXTN   1
#define NXP_CLK_CONF         1 // 1=Xtal, 2=PLL
#define NXP_TVDD_CONF        1 // 1=3.3V, 2=4.75V
#define NXP_RF_CONF          1

uint8_t NxpNci_SettingCurrentTS[32] = __TIMESTAMP__;

#if NXP_CORE_CONF
/* NCI standard dedicated settings
 * Refer to NFC Forum NCI standard for more details
 */
uint8_t NxpNci_CORE_CONF[]={0x20, 0x02, 0x05, 0x01,         /* CORE_SET_CONFIG_CMD */
    0x00, 0x02, 0xFE, 0x01                                  /* TOTAL_DURATION */
};
#endif

#if NXP_CORE_CONF_EXTN
/* NXP-NCI extension dedicated setting
 * Refer to NFC controller User Manual for more details
 */
uint8_t NxpNci_CORE_CONF_EXTN[]={0x20, 0x02, 0x05, 0x01,    /* CORE_SET_CONFIG_CMD */
    0xA0, 0x40, 0x01, 0x00                                  /* TAG_DETECTOR_CFG */
};
#endif

#if NXP_CORE_STANDBY
/* NXP-NCI standby enable setting
 * Refer to NFC controller User Manual for more details
 */
uint8_t NxpNci_CORE_STANDBY[]={0x2F, 0x00, 0x01, 0x00};    /* last byte indicates enable/disable */
#endif

#if NXP_CLK_CONF
/* NXP-NCI CLOCK configuration
 * Refer to NFC controller Hardware Design Guide document for more details
 */
 #if (NXP_CLK_CONF == 1)
 /* Xtal configuration */
 uint8_t NxpNci_CLK_CONF[]={0x20, 0x02, 0x05, 0x01,        /* CORE_SET_CONFIG_CMD */
   0xA0, 0x03, 0x01, 0x08                                  /* CLOCK_SEL_CFG */
 };
 #else
 /* PLL configuration */
 uint8_t NxpNci_CLK_CONF[]={0x20, 0x02, 0x09, 0x02,        /* CORE_SET_CONFIG_CMD */
   0xA0, 0x03, 0x01, 0x11,                                 /* CLOCK_SEL_CFG */
   0xA0, 0x04, 0x01, 0x01                                  /* CLOCK_TO_CFG */
 };
 #endif
#endif

#if NXP_TVDD_CONF
/* NXP-NCI TVDD configuration
 * Refer to NFC controller Hardware Design Guide document for more details
 */
 #if (NXP_TVDD_CONF == 1)
 /* TXLDO output voltage set to 3.3V */
 uint8_t NxpNci_TVDD_CONF[]={0x20, 0x02, 0x0F, 0x01, 0xA0, 0x0E, 0x0B, 0x11, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0xD0, 0x0C};
 #else
 /* TXLDO output voltage set to 4.75V */
 uint8_t NxpNci_TVDD_CONF[]={0x20, 0x02, 0x0F, 0x01, 0xA0, 0x0E, 0x0B, 0x11, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0xD0, 0x0C};
 #endif
#endif

#if NXP_RF_CONF
/* NXP-NCI RF configuration
 * Refer to NFC controller Antenna Design and Tuning Guidelines document for more details
 */
/* Following configuration relates to performance optimization of OM27160 NFC Controller demo kit */
uint8_t NxpNci_RF_CONF[]={0x20, 0x02, 0x4C, 0x09,
  0xA0, 0x0D, 0x03, 0x78, 0x0D, 0x02,
  0xA0, 0x0D, 0x03, 0x78, 0x14, 0x02,
  0xA0, 0x0D, 0x06, 0x4C, 0x44, 0x65, 0x09, 0x00, 0x00,
  0xA0, 0x0D, 0x06, 0x4C, 0x2D, 0x05, 0x35, 0x1E, 0x01,
  0xA0, 0x0D, 0x06, 0x82, 0x4A, 0x55, 0x07, 0x00, 0x07,
  0xA0, 0x0D, 0x06, 0x44, 0x44, 0x03, 0x04, 0xC4, 0x00,
  0xA0, 0x0D, 0x06, 0x46, 0x30, 0x50, 0x00, 0x18, 0x00,
  0xA0, 0x0D, 0x06, 0x48, 0x30, 0x50, 0x00, 0x18, 0x00,
  0xA0, 0x0D, 0x06, 0x4A, 0x30, 0x50, 0x00, 0x08, 0x00
};
#endif

 

 

 

Thanks & Regards

Taksh Patel.

0 Kudos

965 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi @takshpatel 

 

unfortunately I can not reproduce your issue on my side.  could you please share the NCI logs with us?

 

Regards

Daniel

0 Kudos