2018-05-17 04:14 PM
As
previously reported on another post I can
do an
'inventory' and get a tag ID back successfully. I did that by getting
the example
application
for
STM32F401RE-Nucleo
and X-NUCLEO
-NFC0A1 boards ==>> code is STM32CubeExpansion_NFC5_V1.2.0
I am now trying to read and write to the tag. Unfortunately the above example code stops at getting an 'inventory'.
After getting the inventory here:
rfalNfcvPollerInitialize(); /* Initialize for NFC-F */
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 */
REVERSE_BYTES(nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN);
found = true;
}
I am continuing with this:
uint8_t rxBuf[1] = {0x55}, wrData = 0xAA;
uint16_t rcvLen = 1;
uint8_t flags = RFAL_NFCV_REQ_FLAG_DEFAULT;
err = rfalNfvReadSingleBlock( flags, nfcvDev.InvRes.UID, 1, rxBuf, 1, &rcvLen );
err = rfalNfvWriteSingleBlock( flags, nfcvDev.InvRes.UID, 1, &wrData, 1 );
err = rfalNfvReadSingleBlock( flags, nfcvDev.InvRes.UID, 1, rxBuf, 1, &rcvLen );
if (rxBuf[1] == wrData)
{
sys_delay_ms(100);
}
else
{
sys_delay_ms(200);
}
But the calls to read/write always return a timeout error.
Is it OK to just continue after getting the ID from a tag?
Should I have to turn the antenna off, then back on first?
Are there additional steps after rfalNfcvPollerCollisionResolution()
and before rfalNfvReadSingleBlock()
?
Maybe the flags value has to be more than just the default?
Etc...
Is there an example SW that actually does read/write operations and does not stop at getting inventory?
Thanks and regards,
Gil
#st25r3911b #iso15693Solved! Go to Solution.
2018-05-24 06:20 AM
Hi Guilherme,
Indeed, thelast versionreleasedhas a mismatch between declaration (on rfal_nfcv.h) and the implementation(on rfal_nfcv.c).
This will be fixed in the next release. Please align these to make use of the APIs.
Also, as mentioned previously there's an issue on these commands for using theAdressed mode.
Therefore, until a new version gets released please make use of the Select Mode as bellow (in the previous comment the Select cmd was not copied in - edited)
#define NFCV_BLOCK_LEN 4
...
found = true;
...
{
uint8_t rxBuf[1 + NFCV_BLOCK_LEN + 2], wrData[NFCV_BLOCK_LEN] = { 0x11, 0x22, 0x33, 0x44 };
uint16_t rcvLen = 1;
#if 0 /* Addressed mode */
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, 1, rxBuf, sizeof(rxBuf), &rcvLen);
err = rfalNfcvPollerWriteSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, 1, wrData, sizeof(wrData));
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, 1, rxBuf, sizeof(rxBuf), &rcvLen);
#else /* Select mode */
err = rfalNfvPollerSelect(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID);
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, rxBuf, sizeof(rxBuf), &rcvLen);
err = rfalNfcvPollerWriteSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, wrData, sizeof(wrData));
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, rxBuf, sizeof(rxBuf), &rcvLen);
#endif
}
REVERSE_BYTES(nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN);
...�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Kind regards
GP
2018-05-23 06:05 AM
Dear Guilherme,
As sent via email, the code bellow has the following issues:
STM32CubeExpansion_NFC5_V1.2.0
but from the APIs it seems thatyou are using an older version.The new APIs are:
rfalNfcvPollerReadSingleBlock
rfalNfcvPollerWriteSingleBlock
There’s an issue on these commands when communicating with the tag in the addressed mode (with UID).
A new release is still being prepared, so currently there’s no published release available with the fix, but we can share thediff/patch if needed.
That is currently performed for human readability only, but to make use of the UID on the following commands it must not be reversed.
//REVERSE_BYTES(nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN);
If the addressed mode is not required, just use NULL for the UID parameter.
ISO15693 tags usually have blocks of 4 bytes each, but can be as big as 32 bytes.
Please increase the rxBuf accordingly, and also pass a full block when writing the block as well.
The following code should work for you:
#define NFCV_BLOCK_LEN 4
...
/******************************************************/
/* NFC-V card found */
/* NFCID/UID is contained in: invRes.UID */
found = true;
{
uint8_t rxBuf[1 + NFCV_BLOCK_LEN + 2], wrData[NFCV_BLOCK_LEN] = { 0x11, 0x22, 0x33, 0x44 };
uint16_t rcvLen = 1;
err = rfalNfvPollerSelect(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID);
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, rxBuf, sizeof(rxBuf), &rcvLen);
err = rfalNfcvPollerWriteSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, wrData, sizeof(wrData));
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, rxBuf, sizeof(rxBuf), &rcvLen);
}
REVERSE_BYTES(nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN);�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Kind regards
GP
EDIT: code snippet edited
Updated
2018-05-23 11:04 AM
,
,
Hi Gr
é
goire,Thank you for the information. , I tried it but I still get a timeout error.
I suspected that the problem was on our HW ,side (antenna power, etc), so I also added that code to the ,
STM32CubeExpansion_NFC5_V1.2.0 ,
code and used the ST development boards (NUCLEO-F401RE and X-NUCLEO-NFC05A1) to test. , It also returns a timeout error. , So maybe there is more to it.
,
I also noticed one thing:
,
rfal_nfcv.h names the functions '
rfalNfv
Poller
ReadSingleBlock', etc
,
... but ...
,
rfal_nfcv.c names them '
rfalNfv
ReadSingleBlock', etc (without the ,
Poller
,
in the name),
To be able to call them I needed to rename them in the .h file, but I'm afraid that for some reason rfal_nfcv.c is an older version of the file, inadvertently included in the new SDK.
,
Could you check this on your side?
,
Here's how my code looks like now:
,
♯ define NFCV_BLOCK_LEN , ,4
, , ,
uint8_t rxBuf[1 + NFCV_BLOCK_LEN + 2], wrData[NFCV_BLOCK_LEN] = { 0x11, 0x22, 0x33, 0x44 },
uint16_t rcvLen = 1, // or ,sizeof(rxBuf)
uint8_t flags = RFAL_NFCV_REQ_FLAG_DEFAULT,
, , ,
, , err = rfalNfvPollerReadSingleBlock( flags, NULL, 1, rxBuf, sizeof(rxBuf), &,rcvLen ),
,
, , err = rfalNfvPollerWriteSingleBlock( flags, NULL, 1, wrData, sizeof(wrData) ),
,
, , err = rfalNfvPollerReadSingleBlock( flags, NULL, 1, rxBuf, sizeof(rxBuf), &,rcvLen ),
,
, , if (rxBuf[1] == wrData[0]) ,
// Just a place to set a breakpoint
, , {
, , , , wrData[2]++, // Just a place to set a breakpoint
, , }
, , else
, , {
, , , , wrData[3]++, // Just a place to set a breakpoint
, , }
,
Thanks and regards,
Gil
2018-05-24 06:20 AM
Hi Guilherme,
Indeed, thelast versionreleasedhas a mismatch between declaration (on rfal_nfcv.h) and the implementation(on rfal_nfcv.c).
This will be fixed in the next release. Please align these to make use of the APIs.
Also, as mentioned previously there's an issue on these commands for using theAdressed mode.
Therefore, until a new version gets released please make use of the Select Mode as bellow (in the previous comment the Select cmd was not copied in - edited)
#define NFCV_BLOCK_LEN 4
...
found = true;
...
{
uint8_t rxBuf[1 + NFCV_BLOCK_LEN + 2], wrData[NFCV_BLOCK_LEN] = { 0x11, 0x22, 0x33, 0x44 };
uint16_t rcvLen = 1;
#if 0 /* Addressed mode */
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, 1, rxBuf, sizeof(rxBuf), &rcvLen);
err = rfalNfcvPollerWriteSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, 1, wrData, sizeof(wrData));
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID, 1, rxBuf, sizeof(rxBuf), &rcvLen);
#else /* Select mode */
err = rfalNfvPollerSelect(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID);
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, rxBuf, sizeof(rxBuf), &rcvLen);
err = rfalNfcvPollerWriteSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, wrData, sizeof(wrData));
err = rfalNfcvPollerReadSingleBlock(RFAL_NFCV_REQ_FLAG_DEFAULT, NULL, 1, rxBuf, sizeof(rxBuf), &rcvLen);
#endif
}
REVERSE_BYTES(nfcvDev.InvRes.UID, RFAL_NFCV_UID_LEN);
...�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Kind regards
GP
2018-05-24 05:54 PM
Hi Gr
é
goire,It works with:
err = rfalNfvPollerSelect(RFAL_NFCV_REQ_FLAG_DEFAULT, nfcvDev.InvRes.UID);
Thank you!
Cheers,
Gil
2018-08-16 01:23 AM
Hi,
I am also working on an RFID reader system using STM32l031, I imported the rfal library from the NFC demo board with Nucleo and managed to detect the tag and now I need to develop the read and write functions.
So far, thanks to your post I can read the block 0 of my ISO15693 tag.
however, I fail to read any other blocks using the rfalNfvPollerReadSingleBlock function and setting the parameter blockNum to the desired block address.
I tried to use the help file but I can't open any article.
I laso can't find documentation about the flags (only using RFAL_NFCV_REQ_FLAG_DEFAULT which value is equal to RFAL_NFCV_REQ_FLAG_DATA_RATE).
kind regards,
Yves
2018-08-16 02:26 AM
ok found the problem, need to comment / remove the line as shown:
/* Check if request is to be sent in Addressed or Selected mode */
if( uid != NULL )
{
req.REQ_FLAG |= RFAL_NFCV_REQ_FLAG_ADDRESS;
ST_MEMCPY( req.payload.UID, uid, RFAL_NFCV_UID_LEN );
msgIt += RFAL_NFCV_UID_LEN;
req.payload.data[ (/*RFAL_NFCV_UID_LEN + */msgIt++) ] = blockNum; // comment or remove RFAL_NFCV_UID_LEN
}
else
{
req.REQ_FLAG |= RFAL_NFCV_REQ_FLAG_SELECT;
req.payload.data[msgIt++] = blockNum;
}
regards,
Yves