2021-10-08 06:00 AM
Hello,
I am using the X-NUCLEO-NFC06A1 board to test the NFC functions, and to develop our prototyp NFC reader. I write the Firmware with other micro controller, and find it is really difficult to understand the ST25 Embeeded NFC library (STSW-ST25R16_v1.3.0). The codes are complicate and are not possible to use in my controller.
So read some other Q&A and try to use direct commands and set the registers and to realize the NFC read and write. The following is the current code. ST25R3916 can read and transmit some bytes, because the main interrupt register shows start of receive, end of receive and end of transmission. But it can only receive 2 Bytes like 0x0008.
My question is How can I read the UID and complete data of tag? and how to write data to the tag correctly. Can anyone give a help? Thank you very much.
ST25R3916_Init(void)
{
ST25R3916_Set_CMD(0xC1);//Set default
ST25R3916_Set_CMD(0xDF);//Measure power supply
ST25R3916_Set_Register(0x00,0x07);//Differential, SPI and MCU_CLK disabled
ST25R3916_Set_Register(0x01,0x1C);
ST25R3916_Set_Register(0x02,0xCF);//enable oscillator
/*Wait until the interrupt shows that the oscillator is stable (IRQ when oscillator frequency is stable)*/
ST25R3916_Set_Register(0x03,0x08);
ST25R3916_Set_Register(0x08,0x50);
//ST25R3916_Set_Register(0x0A,0x10);
ST25R3916_Set_Register(0x0B, 0x08);
ST25R3916_Set_Register(0x0F, 0x0E);
ST25R3916_Set_Register(0x11, 0x23);
ST25R3916_Set_Register(0x12, 0x20);
ST25R3916_Set_Register(0x13, 0x02);
ST25R3916_Set_Register(0x14, 0xC8);
ST25R3916_Set_Register(0x15, 0x80);
ST25R3916_Set_Register(0x16, 0x83);
ST25R3916_Set_Register(0x17, 0xBF);
ST25R3916_Set_Register(0x18, 0x0F);
ST25R3916_Set_Register(0x19, 0xFB);
ST25R3916_Set_Register(0x23, 0x30);
ST25R3916_Set_Register(0x25, 0xDD);
ST25R3916_Set_Register(0x26, 0x82);
ST25R3916_Set_Register(0x27, 0x82);
ST25R3916_Set_Register(0x28, 0x70);
ST25R3916_Set_Register(0x29, 0x5F);
ST25R3916_Set_Register(0x2A, 0x11);
ST25R3916_Set_Register(0x31, 0x10);
ST25R3916_Set_Register(0x2A, 0x11);
}
while(1)
{
ST25R3916_FIFO_Write(); // write data to the fifo to send
Write_CMD(0xC2);// Stop all activities
Write_CMD(0xD5);//Reset RX gain
Write_CMD(0xC6);//Transmit REQA
delay_ms(500);
}
Solved! Go to Solution.
2021-10-08 03:00 PM
Hi,
If I am not wrong, TI CC2540 has 2 SPI so I would recommend to use SPI communication rather than I2C. Anyway, the platform.h has also wrapper macros for I2C configuration. Make sure to use RFAL_USE_I2C macro definition when compiling the ST25R3916 driver for I2C. On HW side, make sure to have the I2C_EN pin being properly configured for proper interface selection.
The flash size and RAM size needed for the RFAL depends on enabled features (e.g. do you need all NFC technologies or only NFC-A?). The selection of the various features is achieved through the platform .h file. Code for disabled features is removed at compile time and this reduce the RAM/Flash resources accordingly. The rfal.chm documentation file contains the size of each compiled module (based on STM32 MCU). This can give a first estimate of RAM/FLASH needed.
The rfal.chm documentation file also contain information about the configuration and the porting of the RFAL
Rgds
BT
2021-10-08 06:46 AM
Hi,
which MCU do you use?
The RFAL Firmware from the ST25 Embedded NFC lib is designed to be portable across different MCU. Wrapper macros are provided in platform.h so that you can adapt the SPI/GPIO/etc. management to your own MCU. If you already have a functional SPI communication between the MCU and the ST25R3916, porting the RFAL on your own MCU should be quite straightforward .
Rgds
BT
2021-10-08 07:07 AM
2021-10-08 03:00 PM
Hi,
If I am not wrong, TI CC2540 has 2 SPI so I would recommend to use SPI communication rather than I2C. Anyway, the platform.h has also wrapper macros for I2C configuration. Make sure to use RFAL_USE_I2C macro definition when compiling the ST25R3916 driver for I2C. On HW side, make sure to have the I2C_EN pin being properly configured for proper interface selection.
The flash size and RAM size needed for the RFAL depends on enabled features (e.g. do you need all NFC technologies or only NFC-A?). The selection of the various features is achieved through the platform .h file. Code for disabled features is removed at compile time and this reduce the RAM/Flash resources accordingly. The rfal.chm documentation file contains the size of each compiled module (based on STM32 MCU). This can give a first estimate of RAM/FLASH needed.
The rfal.chm documentation file also contain information about the configuration and the porting of the RFAL
Rgds
BT
2021-10-13 01:12 AM