Skip to main content
Charles Blanchard
Associate III
June 30, 2020
Question

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

  • June 30, 2020
  • 3 replies
  • 982 views

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.

This topic has been closed for replies.

3 replies

Uwe Bonnes
Chief
June 30, 2020

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

hs2
Visitor II
June 30, 2020

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
June 30, 2020

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