NxpNfcRdLib - How to halt a mifare classic card

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

NxpNfcRdLib - How to halt a mifare classic card

1,909 Views
breezeto
Contributor I

Hi All,

I have tested the NxpNfcRdLib and tried to read a Mifare Classic card without any problem.

But I don't know why the phacDiscLoop_Run function will detect the card again, even it called the "phpalI14443p3a_HaltA" function after read the card successfully.

I want to halt the card and don't want to detect it again.

 

Would you share your any idea with me?

Thanks so much~

Labels (1)
0 Kudos
3 Replies

1,311 Views
mostafah
Contributor I

I have same problem with mfrc531.

After halt command card will answer standard request :smileysad:

0 Kudos

1,311 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Breeze,

Would you please provide more details on this issue? For example, which sample code are you running for test? Which NFC reader are you using for test?

Thanks for your patience!


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,311 Views
breezeto
Contributor I

Hi Kan,

Thanks for your help~

I'm using the PNEV5180 board for development.
I have faced a problem that the Mifare card will be detected again after I read the Mifare card and call the phpalI14443p3a_HaltA function successfully.

Would you have any advice for me?

Thanks ~

My code:

phStatus_t status = 0;
uint16_t wTagsDetected = 0;
uint8_t bUid[PHAC_DISCLOOP_I3P3A_MAX_UID_LENGTH];
uint8_t bUidSize;

status = phhalHw_Wait(sDiscLoop.pHalDataParams,PHHAL_HW_TIME_MICROSECONDS, 5100);
CHECK_STATUS(status);

/* Configure Discovery loop for Poll Mode */
status = phacDiscLoop_SetConfig(&sDiscLoop, PHAC_DISCLOOP_CONFIG_NEXT_POLL_STATE, PHAC_DISCLOOP_POLL_STATE_DETECTION);
CHECK_STATUS(status);

/* Run Discovery loop */
status = phacDiscLoop_Run(&sDiscLoop, PHAC_DISCLOOP_ENTRY_POINT_POLL);
if ((status & PH_ERR_MASK) == PHAC_DISCLOOP_DEVICE_ACTIVATED)
{
      /* Card detected */
      /* Get the tag types detected info */
      status = phacDiscLoop_GetConfig(&sDiscLoop, PHAC_DISCLOOP_CONFIG_TECH_DETECTED,       &wTagsDetected);

      /* Check for Status */


      if ((status & PH_ERR_MASK) == PH_ERR_SUCCESS)
      {
         /* Check for Type A tag detection */
         if (PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_POS_BIT_MASK_A))
         {
         /* Check for MIFARE Classic */
         if (0x08 == (sDiscLoop.sTypeATargetInfo.aTypeA_I3P3[0].aSak & 0x08))
         {
               do
               {
                     /* Send authentication for block 6 */
                      status = phalMfc_Authenticate(&salMFC, 6, PHHAL_HW_MFC_KEYA, 1, 0, bUid, bUidSize);

                     /* Check for Status */
                     if ((status & PH_ERR_MASK) != PH_ERR_SUCCESS)
                           break;
         

                     /* Read data from block 4 */
                     status = phalMfc_Read(&salMFC, 4, bDataBuffer);

                     /* Check for Status */
                     if (status != PH_ERR_SUCCESS)      
                           break; /* Break from the loop*/
       
                     DEBUG_PRINTF("\nRead Success");
                     DEBUG_PRINTF("\nThe content of Block 4 is:\n");
                     phApp_Print_Buff(&bDataBuffer[0], MFC_BLOCK_DATA_SIZE);
                     DEBUG_PRINTF("\n\n --- End of Read Operation --- \n");
               }while(0);

               /* Send HaltA */
               status = phpalI14443p3a_HaltA(sDiscLoop.pPal1443p3aDataParams);
               CHECK_STATUS(status);
              }
         }
      }
   }

0 Kudos