2020-05-28 06:42 AM
Hello,
I am currently working on a project with the CR95HF chip. The chip has to be controlled over UART (by a STM32L4S7ZITx) and I would like a library which provides basic functions, such as being able to read a presented tag's UID and be able to read from and write to the presented tag.
Does the X-CUBE-NFC3 library provide this functionality?
If so, how exactly do I integrate it into my existing STM32CubeIDE project? I am aware it cannot be added through STM32CubeMx so of the whole download provided at https://www.st.com/en/embedded-software/x-cube-nfc3.html#overview what part needs integrated into my project to get the functionality described above and how do I do this?
Thanks!
Amy
Solved! Go to Solution.
2020-06-01 02:53 AM
Hi,
/* USER CODE BEGIN 4 */
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART1)
{
st25r95UartTxCpltCallback();
}
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART1)
{
st25r95UartRxCpltCallback();
}
}
void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
{
if (huart->Instance == USART1)
{
st25r95UartErrorCallback();
}
}
/* USER CODE END 4 */
Rgds
BT
2020-05-29 01:16 AM
Hi Amy,
X-CUBE-NFC3 provides
For you application, you can use the polling application as a starting point and you can open STM32CubeExpansion_NFC3_V2.1.0\Projects\STM32L476RG-Nucleo\Applications\PollingTagDetect\STM32CubeIDE\STM32L476RG-Nucleo_PollingTagDetect project to have an example.The files you need to integrate in your own project are:
In you main.c, you need to add the code from the main.c from the polling example:
In you Inc folder, copy the platform.h from the example and update the pin assignment accordingly.
i would suggest you first start to integrate in SPI mode and then follow the instruction in https://community.st.com/s/question/0D50X0000B7YwL7SQK/how-to-use-uart-interface-instead-of-spi-with-xnucleonfc03a1-and-xcubenfc3-polling-demo to add the support of UART.
By the way, just for my information why do you prefer to use UART communication rather than SPI?
Rgds
BT
2020-05-29 06:44 AM
Hi BT,
Thank you very much for your response!
Unfortunately the way our board has been designed means that we only have the UART lines of communication between our STM and CR95HF so that's why I can't use SPI.
I have started trying to test the library using the M24LR discovery board though as this gives me access to trying the library with SPI. My hope is that once I know how to use the library with SPI then it will be easier for me to convert it and work with UART on my final board.
Unfortunately though I cannot get past initialisation using this board. I have used the STM32F103RB-Nucleo project as a basis for the discovery board as this was the closest match and have changed the values defined in platform.h to match the connections shown in the M24LR discovery board schematic. I have set the interface pin high too so SPI should be selected on the CR95HF. Is there something else I'm missing?
Otherwise I may just have to convert the library to use UART and try it straight away on my other board. What all is involved in changing the library to use UART instead of SPI?
Thanks again!
Amy
2020-05-29 07:17 AM
Hi Amy
" M24LR discovery board" ==> do you mean RF Transceiver demonstration board MB1054B?
Have you properly reassigned the IRQ_IN/UART_RX pin to PA3 and and IRQ _OUT/UART_TX pin to PA2? IRQ_IN is needed as part of the startup sequence (see CR95HF datasheet §3.2)
Rgds
BT
2020-05-29 07:40 AM
Hi BT,
Yes sorry I mean the RF Transceiver demonstration board MB1054B.
Yes I have reassigned the IRQ_IN/UART_RX and IRQ_OUT/UART_TX pins. Should IRQ_IN/UART_RX pin not be reassigned to PA2 and IRQ_OUT/UART_TX pin to PA3? I have tried the pins either way round anyway and unfortunately neither way works so is there anything else I should try?
Thanks!
Amy
2020-05-29 08:14 AM
Hi,
I guess you have already checked that the board is functional with the default FW (STSW-M24LR007)? STSW-M24LR007 also includes the source code so that you can check the proper pin assignment or reuse the MCU initialisation part for your tests
Can you check the board is properly powered? Can you blink the LED1 through PB5? Is your JTAG asserting NRESET?
Rgds
BT
2020-05-29 08:45 AM
Hello,
Yes I have checked the board is functional with the default FW and checked the pin assignment.
The board must be powered properly as when I run the demo LED1 blinks on and off to show the STM has been unable to initialise the CR95HF chip. I am unsure about JTAG asserting NRESET, I will double check this as well but the board does seem to be programmed ok and I can step through the code using the debugger.
Thanks.
Amy
2020-06-01 12:52 AM
Hi,
can you step into rfalInitialize() and investigate to find whether the failure comes from st25r95Initialize(), st25r95CheckChipID or st25r95CalibrateTagDetector()?
Rgds
BT
2020-06-01 01:18 AM
Yes, it appears to be st25r95Initialize(). When I step through it appears to be a timeout error due to the STM not receiving a response from sending the ECHO command.
The exact line which returns ERR_TIMEOUT is "retCode = st25r95SPIPollRead(ST25R95_CONTROL_POLL_TIMEOUT);" - line 246 in st25r95_com_spi.c.
Thanks.
Amy
2020-06-01 02:33 AM
Hello Brian,
I am unsure why but when I programmed my STM32 with another program then reprogrammed it again with the demo software it now works!
The initialisation works and I can see tags being detected. Sorry to have wasted your time!
Could you please tell me how I can alter the library so as to use it with UART instead of SPI?
Thanks again for all your help.
Amy