Skip to main content
DIvan.1
Associate III
July 27, 2020
Solved

Detection application for Tag Type-V with demo example

  • July 27, 2020
  • 39 replies
  • 8634 views

Hello, I'm trying to write a program which will detect the tag. I follow the demo example NFC05 and use a function from rfal_nfcv.h file.

I detect a Tag sucessfully. But the problem is when I want to use Collision avoidance "rfalNfcvPollerCollisionResolution()". In the codeat the picture above, the program never go into the if statement and the function for anticollision is not executed.

0693W000003BMBKQA4.png

Because of that I deleted the if statement and keep only the code inside. I get "HardFault_Handler" error.

I check the code step by step. The tag is detected, then anticollision function is executed, also the for statement at the end. Then program start againg (next cycle in while loop). When the program came to the Anticollision funtion, It gave me the error.

Here is the picture after first cycle:

0693W000003BMOOQA4.png

Here is the picture in the second cycle, just before Error (next step I get error):

0693W000003BMPRQA4.png

Do you have any idea what's wrong here. I was following the example program and check it, everything is almost the same.

Thank you for any advice.

all the best,

Domen

    This topic has been closed for replies.
    Best answer by Brian TIDAL

    Hi,

    the easiest way is to use the demo.c as a starting point. This does the basic technology detection activity, anti collision activity etc.

    Once a Type V tag has been discovered, the demoCycle calls demovNfcv(). This function demonstrates how to do a Read Single Block (it reads the block 0 and displays its content on the serial log). It demonstrates as well a Write Single Block.

    Rgds

    BT

    39 replies

    Brian TIDAL
    ST Technical Moderator
    August 7, 2020

    Hi,

    can you elaborate about " but It's not working."?

    Can you try with the original demo?

    On my side, ST253911B is able to communicate with many type V tags from different manufacturers

    Rgds

    BT

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    DIvan.1
    DIvan.1Author
    Associate III
    August 11, 2020

    Hi Brian,

    You have right. It's working normally. There was a problem with a Tag I was testing with. Today I got new tags and It's working.

    Regards,

    Domen

    DIvan.1
    DIvan.1Author
    Associate III
    September 3, 2020

    Hello Brian,

    These days I'm trying to save the Tag UID into a new variable so I can send it via UART to the other device.

    I made some small changes but the value is not the same. I think I have a problems with pointer/adresses.

    There is original code which is working correctly.

    0693W000003Qf8yQAC.png

    After that I just move "hex2Str(devUID, RFAL_NFCV_UID_LEN)" into a new variable but the value is not correct (receiving value: .H -ascii ). Have any idea why. The code is attached below:

    0693W000003QfAfQAK.png

    All the best,

    Domen

    Brian TIDAL
    ST Technical Moderator
    September 3, 2020

    Hi,

    how is declared uidTest?

    Rgds

    BT

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    DIvan.1
    DIvan.1Author
    Associate III
    September 4, 2020

    Hello,

    In "demo.c" is defined:

    uint8_t uidTest;

    In "demo.h" is defined:

    extern uint8_t	uidTest;

    It's defined like this because I need to use it in "main.c" file

    Regards,

    DomenI

    DIvan.1
    DIvan.1Author
    Associate III
    September 4, 2020

    I also try to define it like static: "static uint8_t uidTest;" but still not working.

    Best,

    Domen

    Brian TIDAL
    ST Technical Moderator
    September 4, 2020

    Hi

    hex2Str returns a string pointer i.e. "char *". As long as you store a pointer into a uint8_t, you will have inconsistant behaviors...

    Moreover, this pointer points to a buffer that will be modified by the next call to hex2Str. I would suggest you allocate a long enough buffer (e.g. 17 bytes) to store the string value of the UID and then memcpy the output of hex2Str into that buffer.

    Rgds

    BT

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    DIvan.1
    DIvan.1Author
    Associate III
    September 7, 2020

    HI, thank you for your reply. I'm trying this things you said but I don't understand you clearly what to do first and which values should be saved in which buffer. Can you please explain it again in a few steps.

    Thank you,

    Domen

    Brian TIDAL
    ST Technical Moderator
    September 7, 2020

    HI,

    allocate a buffer:

    char myUIDBuf[RFAL_NFCV_UID_LEN * 2 +1]; /* allocate 2 chars per byte plus room for \0 */

    copy the result of hex2Str into that buffer

    ST_MEMCPY(myUIDBuf, hex2Str(devUID, RFAL_NFCV_UID_LEN), RFAL_NFCV_UID_LEN * 2 +1 );

    Rgds

    BT

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    DIvan.1
    DIvan.1Author
    Associate III
    September 7, 2020

    Thank you for the code. I need to use UID in the "main.c" file. So I just declarate "myUIDBuf" as a global or need to do something else?

    Best regards,

    Domen

    Brian TIDAL
    ST Technical Moderator
    September 7, 2020

    Hi,

    global in one C file and extern char myUIDBuf[RFAL_NFCV_UID_LEN * 2 +1]; in .h file

    Rgds

    BT

    In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.