cancel
Showing results for 
Search instead for 
Did you mean: 

(rev) X-NUCLEO-NFC08A1 RF Field Control on STM32F401RE (with X-CUBE-NFC6 SPI Setup Issue)

yeji_jang
Associate

 

Hello ST Community,

I'm currently trying to implement a simple function: turning the RF field ON and OFF for a desired duration using the X-NUCLEO-NFC08A1 board.

Here is my current setup and progress:

I’m using the STM32F401RE Nucleo board as the host MCU.

I've referred to UM3007 (Getting Started with X-NUCLEO-NFC08A1) and “Getting started with the X-CUBE-NFC6” documents.

I have installed the required X-CUBE-NFC6 software pack in STM32CubeIDE.

SPI1 is configured as per the documentation in .ioc .

However, after code generation, no SPI-related code is generated (e.g., no MX_SPI1_Init() function).

In the .ioc file's System View, the Middleware section shows nothing loaded — I suspect this may be part of the issue.

Overall, it feels like the NFC board is not properly interfacing with the MCU, but I can’t identify what’s wrong.

Additionally, my goal is only to generate the 13.56 MHz RF field with desired strength and timing — no tag detection or NDEF handling is needed. From the datasheet, I understand that the driver’s output resistance can be configured to control the transmit power. I would appreciate any guidance on how to do this via code — especially through st25r3916 functions.

Since this is my first time working with this kind of system, even small suggestions or tips would be incredibly helpful.

Thank you very much in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi

The Clock Phase should be 2 Edges (see datasheet section 4.3.3 Serial peripheral interface (SPI))

BrianTIDAL_0-1751556072315.png

Also check the Prescaler to not exceed the maximum baud rate.

Ensure that you carefully test the return codes of the various calls (MX_SPI1_Init, etc.).

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

6 REPLIES 6
Brian TIDAL
ST Employee

Hi @yeji_jang

welcome to this community.

As your IOC project does not select the Device NFC Applications, the main() function does not call any initialization related to the NFC middleware or initialize the IPs used by the NFC middleware (for example, SPI).

BrianTIDAL_1-1751454331152.png

In this case, your application must call the initialization functions. For the SPI, the functions are available in custom_bus.c: just call SPI1_MspInit() followed by MX_SPI1_Init().

Next, your application must register st25r3916Isr() as the callback to the EXTI interrupt connected to the ST25R3916 IRQ pin. Alternatively, you can add a call to st25r3916Isr() in the USER CODE #1 section of the EXTI interrupt handler. If a NUCLEO-F401RE board is used, the ST25R3916 IRQ pin is likely connected to PA0, not PB13. I would suggest checking this point.

Then, rfalInitialize() must be called to initialize the ST25R3916. It is recommended to enable the ST25R_SELFTEST compilation flag (preprocessor define symbol) to add extra checks for SPI communication and interrupt handling.

As your application only needs to enable the RF field, it only needs to call rfalFieldOnAndStartGT().

Ensure that you carefully test the return codes of the various calls.

I also recommend moving to the latest version of STM32CubeMX.

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 @BT,

Thank you very much for your kind and detailed response — it has been incredibly helpful for someone like me who is just starting with STM32 and NFC development.

I carefully followed your suggestions and made the following changes:

  1. I enabled the "Device NFC Application" in STM32CubeMX.

  2. I configured SPI and EXTI interrupt settings correctly, and I also confirmed that the ST25R3916 IRQ pin is now connected to PA0 as advised.

  3. However, I’m currently facing an issue where rfalInitialize() doesn’t seem to execute properly.
    I suspect it may be related to a missing header file — although the rfalInitialize() function is defined (in rfal_rfst25r3916.c), I couldn’t find a corresponding .h file that declares it properly. This might be why the compiler doesn't fully recognize the function, even though no warning appears when I call it.

As a result, I believe that rfalFieldOnAndStartGT() isn’t being triggered either, and the RF field never gets turned on.

  1. I also defined the ST25R_SELFTEST compilation flag, but I’m not quite sure how to correctly use or verify it.
    Could you please explain how this flag is meant to help with SPI communication and interrupt handling checks?

  2. Finally, I have updated to the latest version of STM32CubeMX, as you suggested.

I’ve been trying to troubleshoot this all day, but I’m still not sure what’s going wrong.

I would deeply appreciate your guidance on what to check or fix next.

Thank you again for your patience and support.

Best regards,
Yeji

 

Additionally, I’ve attached revised part in the latest version.

I manually added st25r3916Isr(); to the EXTI0_IRQHandler() function as shown below:

void EXTI0_IRQHandler(void)
{
/* USER CODE BEGIN EXTI0_IRQn 0 */

/* USER CODE END EXTI0_IRQn 0 */
HAL_EXTI_IRQHandler(&H_EXTI_0);
/* USER CODE BEGIN EXTI0_IRQn 1 */
st25r3916Isr();
/* USER CODE END EXTI0_IRQn 1 */
}

 

 

I’m wondering if I may have misunderstood something about how EXTI is supposed to be configured — and if so, I would be very grateful for any advice or clarification on what I might be doing wrong.

Thank you again for your generous support!

Brian TIDAL
ST Employee

 

Hi Yeji,

The prototypes for rfalInitialize and rfalFieldOnAndStartGT are declared in rfal_rf.h.

ST25R_SELFTEST enables extra code in st25r3916Initialize():

  • It writes and reads back a register to check the SPI communication.
  • It triggers an interrupt from the ST25R3916B reader device to check the IRQ handling.

You can set a breakpoint in st25r3916Initialize() and run step by step to ensure the device initialization is correct.

Regards

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.

Thank you for your prompt reply.

I have already included "rfal_rf.h", and make breakpoint at st25r3916Initialize()

I found Initiatlization is failed, strongly assume that the ChipID is not properly read.

I’m currently seeing two related issues:

 

1.

ret = st25r3916ReadRegister(ST25R3916_REG_IC_IDENTITY, &chipID);

always returns chipID == 0x00

2. Inside demoIni(), rfalNfcInitialize() returns RFAL_ERR_HW_MISMATCH (–36), which indicates that the IC ID check failed.

yeji_jang_2-1751555009811.png

 

Would you mind taking a moment to review my SPI initialization and GPIO configurations to see if there’s anything I may have overlooked? I would greatly appreciate any guidance or suggestions you could offer.

 

Thank you very much for your help!

 

 

yeji_jang_1-1751554834610.png

yeji_jang_3-1751555224947.png

 

yeji_jang_4-1751555236263.png

yeji_jang_5-1751555246375.png

 

 

 

Brian TIDAL
ST Employee

Hi

The Clock Phase should be 2 Edges (see datasheet section 4.3.3 Serial peripheral interface (SPI))

BrianTIDAL_0-1751556072315.png

Also check the Prescaler to not exceed the maximum baud rate.

Ensure that you carefully test the return codes of the various calls (MX_SPI1_Init, etc.).

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.