NFC4 Click

General discussion on mikroElektronika development boards.
Post Reply
Author
Message
michaelw
Posts: 5
Joined: 19 Sep 2023 20:15

NFC4 Click

#1 Post by michaelw » 19 Sep 2023 20:27

Hello,

Has anyone been able to get one of these NFC4s to work? I took the code from Github and incorporated it into my STM32CubeIDE project so I had to change the SPI initialization and logging outputs, but not too much else. I can talk to the chip and using a logic analyzer, everything seems configured based on what the code is supposed to do. I've tried changing SPI modes and little things and that breaks the code so I believe I have it set up correctly. Here is the output from the logic analyzer for reference. Each line is the (MOSI/MISO) data in pairs.

0xC1/0x00
0x01/0x00 0x04/0x04
0x7F/0x01 0x00/0x15
0x41/0x00 0x00/0x02
0x01/0x00 0x1A/0x00
0xFC/0x00 0x44/0x00 0x00/0x00
0xFC/0x00 0x04/0x00 0x10/0x00
0x42/0x00 0x00/0x00
0x56/0x00 0x00/0x00 0x00/0x00 0x00/0x00 0x00/0x00
0x16/0x00 0x00/0x00
0x42/0x00 0x00/0x00
0x02/0x00 0x80/0x00
0x56/0x00 0x00/0x00 0x00/0x00 0x00/0x00 0x00/0x00
0x16/0x00 0x80/0x00
0x71/0x00 0x00/0x08
0x01/0x00 0x80/0x00
0x42/0x00 0x00/0x40
0x02/0x00 0x00/0x00
0x56/0x02 0x00/0x40 0x00/0x00 0x00/0x00 0x00/0x00
0x16/0x00 0xFF/0x04
0x17/0x04 0xFF/0x00
0x18/0x00 0xFF/0x20
0x19/0x00 0xFF/0x40
0x5A/0x00 0x00/0x40 0x00/0x00 0x00/0x00 0x00/0x00
0xFC/0x40 0x01/0x00 0x40/0x00
0x42/0x00 0x00/0x00
0x02/0x00 0x03/0x00
0x6C/0x00 0x00/0x00
0x6C/0x00 0x00/0x00
0x2C/0x00 0x80/0x00
0x6C/0x00 0x00/0x40
0x56/0x00 0x00/0x7F 0x00/0xFF 0x00/0xFF 0x00/0xFD
0x17/0x00 0x7F/0x08
0xD6/0x00
0x56/0x02 0x00/0x7F 0x00/0xBF 0x00/0xFF 0x00/0xFD
0x17/0x12 0xBF/0x11
0xFB/0x00 0x6C/0x04 0x00/0x00
0x5A/0x00 0x00/0x00 0x00/0x00 0x00/0x00 0x00/0x00
0x42/0x00 0x00/0x01
0x03/0x00 0x08/0x00
0x42/0x00 0x00/0x01
0x42/0x00 0x00/0x01
0x03/0x00 0x08/0x00
0x42/0x00 0x00/0x01
0x42/0x00 0x00/0x01
0x03/0x00 0x08/0x00
0x42/0x00 0x00/0x01


The 0x42 0x03 0x42 lines at the end are repeated forever as it is attempting to scan for a tag. I captured just a few here but it never changes when I run the tag over the antenna.

I even bought a couple of Mikroe's NFC tags MIKROE-1475 hoping for maximum compatibility. I also bought a MIKROE-2540 NFC reader that I have used to confirm that all my tags work. I am using the code with the default mode of NFC4_MODE_OM_ISO14443A and I just cannot get it to find any tag! Does anyone have advice or solutions based on your own experience with this module? Maybe I have a bad module. At this point I just don't know.


Thanks!

Michael

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: NFC4 Click

#2 Post by filip » 22 Sep 2023 07:18

Hi,

Can you please send me detailed photos of your hardware connections and software initialization ?

Regards,
Filip.

michaelw
Posts: 5
Joined: 19 Sep 2023 20:15

Re: NFC4 Click

#3 Post by michaelw » 25 Sep 2023 16:31

Hello,

I'm not sure about posting pictures because the hardware is owned by the company I work for but it's just a breakout board with lots of custom stuff, including four sets of inline sockets to plug in a number of Mikroe boards for testing. Buying these boards was the easiest way to get some parts during the parts shortage of 2022. I am using the SPI2 interface and the software was mostly generated by the IDE. I have also tried the NFC3 since this started and it initializes and does everything correctly, except never reads a tag when I scan it over the antenna either.

This is the SPI code:

hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; //60MHz clock
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 0x0;
hspi2.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
hspi2.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi2.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi2.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi2.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi2.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi2.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi2.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi2.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi2.Init.IOSwap = SPI_IO_SWAP_DISABLE;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI2_Init 2 */
__HAL_SPI_ENABLE(&hspi2);

The prescaler is divide by 16 for the NFC3 and divide by 8 for the NFC4. It works fine and initializes the chips just fine. I have logic analyzer outputs to confirm it. It gets to the periodic scan point (what you would call the application_task()) which I run once every 1000ms and it never finds anything. It has left me scratching my head because it gets through all of your initialization code, even the part where it reads the chip ID and has to match, but does absolutely nothing when I pass a tag over the antenna.

I've tried messing with the code by sending commands to enable the interrupts on the ST25R3916 chip at times when this driver doesn't normally do it, just to see if it would fire and nothing happens. I'm at a loss on how to proceed.


Michael

michaelw
Posts: 5
Joined: 19 Sep 2023 20:15

Re: NFC4 Click

#4 Post by michaelw » 06 Nov 2023 20:48

So have you tried your GIT code to prove that this code even works? I went so far as to get an NFC2 board and it doesn't work either. They all run. They all initialize. I can watch them do everything that is in your code on the logic analyzer but none of them actually response to an NFC tag placed near or on top of them. Has any of this code ever been tested lately? Maybe it got broken in an update and no one has tried it? I don't get why it runs so well but the result is it doing nothing with tags. I am hoping to not have to learn what every register in the datasheet does and if you are providing code, it really should work. I'm starting to work on this again after a long break to do other things and I really need to solve this now.


Thanks.

michaelw
Posts: 5
Joined: 19 Sep 2023 20:15

Re: NFC4 Click

#5 Post by michaelw » 07 Nov 2023 21:42

I was able to figure out the issue. The answer is right in the data I posted in my first post: 0x7F/0x01 0x00/0x15

The Chip ID is coming out as 0x15 instead of the 0x2A it should be. I had to change the SPI configuration to sample data on the trailing edge which is a first for me. Now I discover that only one type of NFC tag in my collection works because it is MiFare and the rest are T2T or T5T. I will have to work through the ST library to figure out support for other types unless you have other code resources that you can point me to.


Thanks

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: NFC4 Click

#6 Post by IvanJeremic » 09 Nov 2023 12:38

Hi,

The examples work, they are used to test the click board when they are made.

Can you tell me on what frequency do your tags work.

Regards,

Ivan.

michaelw
Posts: 5
Joined: 19 Sep 2023 20:15

Re: NFC4 Click

#7 Post by michaelw » 09 Nov 2023 19:52

Hello Ivan,

I was able to make this code work, although it has a very limited scope and so I have started porting the NFC6 code from ST into my project. Your code only reads MiFare tags (MIKROE-1475) and I was hoping for support with the NFC Forum types as well (T2T, T5T). I am using a MIKROE-2540 NFC reader to confirm that all of these other tags are working fine and everything is using the 13.56MHz band. Unless you have more advanced code for your boards, I think I will have to keep working with this NFC6 code.


Thanks.

User avatar
IvanJeremic
mikroElektronika team
Posts: 316
Joined: 05 Sep 2022 14:32

Re: NFC4 Click

#8 Post by IvanJeremic » 10 Nov 2023 08:39

Hi,

Unfortunately we have only one example for this click board.

I will see with the developers if we can make a new example for this click where you can choose which supported standard you want to use and not just ISO14443A/B.

Regards,

Ivan.

Post Reply

Return to “Development Boards”