使用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;
}
暂不能定位问题点,建议联系代理商来提供技术支持