cancel
Showing results for 
Search instead for 
Did you mean: 

How to use UART interface instead of SPI with X-NUCLEO-NFC03A1 and X-CUBE-NFC3 polling demo

abrantigan
Associate

I have the X-NUCLEO-NFC03A1 expansion board connected to the NUCLEO-F401RE, successfully running the demo polling code from X-CUBE-NFC3. I would like to modify the code to allow the two boards to communicate using UART alone (no SPI pins necessary). The X-CUBE-NFC3 user guide suggests that this is possible at the end of the document when it says:

" [The X-NUCLEO-NFC03A1] capable of interfacing with the external STM32 microcontroller on STM32 Nucleo board using SPI/UART transport layer. By default it will run using SPI interface. The user can choose to compile with one of the two interfaces by selecting the right target under Projects properties."

https://www.st.com/content/ccc/resource/technical/document/user_manual/group0/da/8c/85/ce/ed/4d/43/98/DM00282095/files/DM00282095.pdf/jcr:content/translations/en.DM00282095.pdf

I'm using the IAR Embedded Workbench IDE, and can't find anything like Projects -> properties that would allow me to change the default interface. Could anyone outline the steps I should take to make this change?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

​Hi

#include "st25r95_com.h" has to be added in main.c as HAL_UART_TxCpltCallback (resp.  HAL_UART_RxCpltCallback and HAL_UART_ErrorCallback) calls st25r95UartTxCpltCallback (resp. st25r95UartRxCpltCallback, st25r95UartErrorCallback).

Make sure to diff each file provided in the zip with the original files to have all the needed modifications

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.

View solution in original post

3 REPLIES 3
Brian TIDAL
ST Employee

Hi,

since X-CUBE-NFC3 v2.0.0, only SPI support is delivered by default. UM2045 §5.3.3 needs to be updated as no UART target is provided.

Anyway, it is possible to use UART for CR95HF with X-CUBE-NFC3 v2.0.0

  • in your project, replace st25r95_com_spi.c by st25r95_com_uart.c
  • add #define ST25R95_INTERFACE_UART  true in platform.h
  • initialize the UART in main.c and stm32f4xx_hal_msp.c, make sure to have the UART interrup being enabled
  • populate HAL_UART_TxCpltCallback, HAL_UART_RxCpltCallback and HAL_UART_ErrorCallback to call st25r95UartTxCpltCallback (resp. st25r95UartRxCpltCallback, st25r95UartErrorCallback)

As an example, I've attached in a Zip the various modified files (example based on NUCLEO-L476RG + MDK-ARM, beware that the file location in uvprojx may differs from the one in the cube package). Make sure to power cycle the X-NUCLEO-NFC03A1 the first time after you have donwloaded the FW with UART support. You may use STM32CubeMX to generate the proper UART initialisation (ioc file attached in the zip for NUCLEO-L476RG, can be used as template for porting to NUCLEO-F401RE).

Personally, I would rather recommend to use SPI. Feel free to share more information about your application in particular why UART is prefered

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.

Hi Brian,

Thank you for your detailed response! I've followed your instructions, but when I try to build the code, I get errors that the functions st25r95UartTxCpltCallback. st25r95UartRxCpltCallback, and st25r95UartErrorCallback, are not defined. I see that they are defined in st25r95_com_uart.c, so I'm not sure why these errors are happening. Any ideas?

Thanks!

Brian TIDAL
ST Employee

​Hi

#include "st25r95_com.h" has to be added in main.c as HAL_UART_TxCpltCallback (resp.  HAL_UART_RxCpltCallback and HAL_UART_ErrorCallback) calls st25r95UartTxCpltCallback (resp. st25r95UartRxCpltCallback, st25r95UartErrorCallback).

Make sure to diff each file provided in the zip with the original files to have all the needed modifications

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.