cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L433RC - Hardfault when using SPI Flash if interruption occurs on UART

Charles Blanchard
Associate III

Hello,

Context:

  • I'm using a Nucleo board based on STM32L433RC.
  • FreeRTOS is running on the target.
  • I'm using IAR and my project is configured with STM32CubeMX V5.6.0 and STM32Cube_FW_V1.15.1.
  • I have an interruption on USART1 RX (1200 or 9600bps) and I'm also using SPI1 to interface an external SPI Flash. I'm also using this with interruption on SPI1 RX and TX.

Problem:

When no data is received on UART, SPI is working properly. If one of my task is using SPI to write to the flash (for example), while data is received through UART (and so the UART interruption called), an Hardfault is generated.

Also, I'm forced to use SPI at less than 8Mbits/s (doesn't work at 16Mbit/s) and I don't know why..

I've already checked stacks (of the mcu and freeRTOS tasks) and they seemed alright.

I noticed that SPI1 and USART1 share the same peripheral bus (I don't know if it is revelant)

Do you have any idea of where does it could come from?

Thank you,

Charles B.

3 REPLIES 3
Uwe Bonnes
Principal II

Perhasp FreeRTOS has some mean to get a backtrace in the hardfault handler. Try to activate to get more information.

hs2
Senior

Is USART1 working without SPI activity ?

I guess you have nested interrupts enabled. Did you reserve enough main stack (usually defined by linker script) for potentially nested ISRs ?

Did you define some of the very helpful FreeRTOS debug support macros like configASSERT, configCHECK_FOR_STACK_OVERFLOW including vApplicationOverflowHook, etc. ?

Charles Blanchard
Associate III

USART1 is working without SPI activity.

I have tried to use SPI polling instead of SPI IT and it still doesn't work.

It seems that my UART interrupt callback is too long (but I'm just filling one charactere in a buffer, so that's sad.. :( )

I've enabled freeRTOS debug support and there is no stack overflow.

I need to work on my UART interruption to avoid nested calls.

Thank you for your help!

Charles