Skip to main content
Associate II
June 23, 2026
Solved

ST25R100 always ends up in error handler

  • June 23, 2026
  • 3 replies
  • 32 views

Hello, 

I have a STM32F401RCT connected to a ST25R100.

In the ioc file I enabled the X-CUBE-NFC9 library with all the necesary dependencies.

All the IOs also have pins assigned to them.

Plus Pull ups enabled on the IRQ (open drain) and NFC_Reset.
Currently I have found out that it crashes somewhere after MX_X_CUBE_NFC9_Init();

ret code: 0
NFC BSP COM = 100
Welcome to X-NUCLEO-NFC09A1

entered error handler

This is what I get in my console. I added some printfs in the code already.

When I run it in debug mode to check were it calls the error handler it for some reason does not hit the error handler but it gets stuck in stm32F4xx_il_usb.c; when I click pauze, this seems rather odd.

HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num)
{
__IO uint32_t count = 0U;

/* Wait for AHB master IDLE state. */
do
{
count++;

if (count > HAL_USB_TIMEOUT)
{
return HAL_TIMEOUT;
}
} while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_AHBIDL) == 0U);

/* Flush TX Fifo */
count = 0U;
USBx->GRSTCTL = (USB_OTG_GRSTCTL_TXFFLSH | (num << 6));

do
{
count++;

if (count > HAL_USB_TIMEOUT)
{
return HAL_TIMEOUT;
}
} while ((USBx->GRSTCTL & USB_OTG_GRSTCTL_TXFFLSH) == USB_OTG_GRSTCTL_TXFFLSH);

return HAL_OK;
}

Are there any debugging tips on what I can do next to figure this issue out?

 

Best answer by Brian TIDAL

Hi,

Could you check the SPI:

Baud rate is exceeding the max (6Mbit/s) and CPHA should be 2 edges.

 

Rgds

BT

3 replies

Ulysses HERNIOSUS
ST Technical Moderator
June 23, 2026

Hi,

my first steps would be: Put only one breakpoint: At the place where the “entered error handler“ gets printed. This should then not change the code execution and hit. Then you can look at the call stack to see which function jumped to this error handler.

The calls to USB_FlushTxFifo() might be normal, maybe executed periodically by some handler. Again, you can put a breakpoint and inspect the call stack.

BR, Ulysses

Associate II
June 23, 2026

Hi,

Thread #1 [main] 1 [core: 0] (Suspended : Breakpoint)	
Error_Handler() at main.c:652 0x8003794
st25r200Initialize() at st25r200.c:135 0x8006008
rfalInitialize() at rfal_rfst25r200.c:364 0x8003e92
rfalNfcInitialize() at rfal_nfc.c:155 0x8014cc8
demoIni() at demo_polling.c:266 0x80197da
MX_NFC9_PollingDemo_Init() at app_x-cube-nfcx.c:105 0x801964a
MX_X_CUBE_NFC9_Init() at app_x-cube-nfcx.c:63 0x80195e8
main() at main.c:167 0x800318a

Allright this is my call stack now.

So it fails in here
 

ReturnCode st25r200Initialize( void )
{
ReturnCode ret;

/* Ensure a defined chip select state */
platformSpiDeselect();

#ifdef ST25R_RESET_PIN
/* Reset the ST25R200 using the RESET pin */
platformGpioSet( ST25R_RESET_PORT, ST25R_RESET_PIN );
platformDelay( ST25R200_RESET_DUR );
platformGpioClear( ST25R_RESET_PORT, ST25R_RESET_PIN );
platformDelay( ST25R200_RESET_DUR );
#endif /* ST25R_RESET_PIN */

/* Set default state on the ST25R200 */
st25r200ExecuteCommand( ST25R200_CMD_SET_DEFAULT );
if( !st25r200CheckChipID( NULL ) )
{
platformErrorHandle(); <--
return RFAL_ERR_HW_MISMATCH;
}

st25r200InitInterrupts();
st25r200ledInit();

gST25R200NRT_64fcs = 0;

...


So something with my SPI than probably?

Kind regards, 

William
 

Brian TIDAL
ST Technical Moderator
June 23, 2026

Hi,

Check the SPI:

Baud rate is exceeding the max (6Mbit/s) and CPHA should be 2 edges.

 

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.
Associate II
June 23, 2026

Hi, 

Oh that’s a handy file.

Normally there should be enough space.

 

Kind regards, 

William

Brian TIDAL
Brian TIDALBest answer
ST Technical Moderator
June 23, 2026

Hi,

Could you check the SPI:

Baud rate is exceeding the max (6Mbit/s) and CPHA should be 2 edges.

 

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.
Associate II
June 23, 2026

Hi, 

I found the issue, I forgot to enable NVIC for the interrupt handler.

*facepalm*.

Thank you for your help!

Kind regards, 

William