- Muchas notas - Fran Acién

20240418 - FreeRTOS STM32 and interrupts

Interrupts has a level, and in order to call from FreeRTOS

This reference is a really good one

Interrupt priority level

Source

The interrupt that are generated by the STM32 needs to be lower than the FreeRTOS system allowed interrupt. So when configuring interrupts, take into account this information.

The function HAL_ADC_ConvCpltCallback is configured by default to have a priority of 0,0, and the system 80. The priority is configure with HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0); but I am not sure how is the numering system.

  • HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 1, 0); -> Doesnt work
  • HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 4, 0); -> Doesnt work
  • HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0); -> Works
  • HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 6, 0); -> Works
  • HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 12, 0); -> Works

In the STM32F446 it is defined in the stm32f446xx.h the values:

  • __NVIC_PRIO_BITS 4 bits

In the FreeRTOS is defined:

  • #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
  • configMAX_SYSCALL_INTERRUPT_PRIORITY -> 80
  • configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY -> 5
  • configPRIO_BITS -> 4