你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

ST25R3912/3911 读写ISO15693卡片的扇区报错

[复制链接]
逐梦 提问时间:2023-8-23 17:51 / 未解决

使用ST25R3912/3911 读写ISO15693卡片扇区的报错,卡片ID可以正常读出

以下是串口打印的内容:

错误ID为21(ERR_CRC CRC错误)

ISO15693/NFC-V card found. UID: E007A40003BCD511
Read Block: FAIL Data: C4A5DC68
err = 21

下面是移植的例程


bool demoPollNFCV( void )
{
  ReturnCode            err;
  rfalNfcvListenDevice  nfcvDev;
  bool                  found = false;
  uint8_t               devCnt = 0;
  uint8_t               devUID[RFAL_NFCV_UID_LEN];
  uint16_t              rcvLen;
  uint8_t               blockNum = 1;
  uint8_t               rxBuf[ 1 + DEMO_NFCV_BLOCK_LEN + RFAL_CRC_LEN ];                        /* Flags + Block Data + CRC */
  uint8_t               wrData[DEMO_NFCV_BLOCK_LEN] = { 0x11, 0x22, 0x33, 0x99 };             /* Write block example */

        uint8_t               reqFlag;

  /*******************************************************************************/
  /* ISO15693/NFC_V_PASSIVE_POLL_MODE                                            */
  /*******************************************************************************/

  rfalNfcvPollerInitialize();           /* Initialize for NFC-V */
  rfalFieldOnAndStartGT();              /* Turns the Field On if not already and start GT timer */

  err = rfalNfcvPollerCollisionResolution(1, &nfcvDev, &devCnt);
  if( (err == ERR_NONE) && (devCnt > 0) )
  {
    /******************************************************/
    /* NFC-V card found                                   */
    /* NFCID/UID is contained in: invRes.UID */

    ST_MEMCPY(devUID, nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN);   /* Copy the UID into local var */
    REVERSE_BYTES(devUID, RFAL_NFCV_UID_LEN);                   /* Reverse the UID for display purposes */

    found = true;
    printf("ISO15693/NFC-V card found. UID: %s\r\n", hex2Str(devUID, RFAL_NFCV_UID_LEN));


#if 1 /*寻址模式  *///RFAL_NFCV_REQ_FLAG_DEFAULT

      err = rfalNfcvPollerReadSingleBlock((RFAL_NFCV_REQ_FLAG_DEFAULT | RFAL_NFCV_REQ_FLAG_SELECT), nfcvDev.InvRes.UID, blockNum, rxBuf, sizeof(rxBuf), &rcvLen);
    //  printf(" Read Block: %s Data: %s \r\n", (err != ERR_NONE) ? "FAIL": "OK", (err != ERR_NONE) ? "" : hex2Str( &rxBuf[1], DEMO_NFCV_BLOCK_LEN) );
         printf(" Read Block: %s Data: %s \r\n", (err != ERR_NONE) ? "FAIL": "OK", hex2Str( &rxBuf[1], DEMO_NFCV_BLOCK_LEN) );

  #if 0 /* 写*/
      err = rfalNfcvPollerWriteSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, blockNum, wrData, sizeof(wrData));
      platformLog(" Write Block: %s Data: %s\r\n", (err != ERR_NONE) ? "FAIL": "OK", hex2Str( wrData, DEMO_NFCV_BLOCK_LEN) );
      err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, blockNum, rxBuf, sizeof(rxBuf), &rcvLen);
      platformLog(" Read Block: %s Data: %s\r\n", (err != ERR_NONE) ? "FAIL": "OK", (err != ERR_NONE) ? "" : hex2Str( &rxBuf[1], DEMO_NFCV_BLOCK_LEN) );
  #endif

#else  /* Using Select mode */

  printf("rfalNfcvPollerSelect\r\n");

        reqFlag = RFAL_NFCV_REQ_FLAG_DEFAULT;
                err = rfalNfcvPollerSelect( reqFlag,  nfcvDev.InvRes.UID);
        printf(" Select %s \r\n", (err != ERR_NONE) ? "FAIL (revert to addressed mode)": "OK" );
        if( err == ERR_NONE )
        {
            reqFlag = (RFAL_NFCV_REQ_FLAG_DEFAULT | RFAL_NFCV_REQ_FLAG_SELECT);
        }

      err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, blockNum, rxBuf, sizeof(rxBuf), &rcvLen);
      printf(" Read Block: %s Data: %s\r\n", (err != ERR_NONE) ? "FAIL": "OK", hex2Str( &rxBuf[0], rcvLen) );


            if(err != ERR_NONE)
                 printf("err = %d\r\n",err);
  #if 0 /* Writing example */
      err = rfalNfcvPollerWriteSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, blockNum, wrData, sizeof(wrData));
      platformLog(" Write Block: %s Data: %s\r\n", (err != ERR_NONE) ? "FAIL": "OK", hex2Str( wrData, DEMO_NFCV_BLOCK_LEN) );
      err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, blockNum, rxBuf, sizeof(rxBuf), &rcvLen);
      platformLog(" Read Block: %s Data: %s\r\n", (err != ERR_NONE) ? "FAIL": "OK", (err != ERR_NONE) ? "" : hex2Str( &rxBuf[1], DEMO_NFCV_BLOCK_LEN) );
  #endif

#endif

  }

  return found;
}
收藏 评论1 发布时间:2023-8-23 17:51

举报

1个回答
Mason MEI 回答时间:2023-10-24 16:49:20

暂不能定位问题点,建议联系代理商来提供技术支持

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版