STM32: which "Generate IRQ Handler" checkboxes shall we tick in MX?

I am trying to use the latest FreeRTOS distribution instead of one shipped with CubeMX and wrapped around CMSIS.

I read the freertos guides and I understood how non-trivial is to deal with interrupts, and I think I followed all the steps (e.g. use 0 bits for sub-priority, don’t leave the default priority to 0 which is the higher, and so on) but here is yet another questions.

It seems that from CubeMX in the tab NVIC/Code Generation some tick boxes under the column “Generate IRQ Handler” shall be disable, otherwise one may incur in some double “already defined” error like the following:

C:/Users/yt75534/Documents/embedded/stm32_platform/Hello_World/freertos/portable/GCC/ARM_CM4F/port.c:252: multiple definition of `SVC_Handler’; build/stm32f4xx_it.o:C:/Users/yt75534/Documents/embedded/stm32_platform/Hello_World/Core/Src/stm32f4xx_it.c:154: first defined here

That is, by selecting “Generate IRQ Handler” a placeholder like the following (assume that I checked the box relative to EXTI10_15 interrupt):

void EXTI15_10_IRQHandler(void)
{
/* USER CODE BEGIN EXTI15_10_IRQn 0 */

/* USER CODE END EXTI15_10_IRQn 0 /
HAL_GPIO_EXTI_IRQHandler(B1_Pin);
/
USER CODE BEGIN EXTI15_10_IRQn 1 */

/* USER CODE END EXTI15_10_IRQn 1 */
}

is automatically added to Core/Src/stmf4xx_it.c.

Now my question are

  1. how do we know which tick boxes under the column “Generate IRQ Handler” shall be disabled to be able to work with freertos and avoid the errors of above?

  2. Shall we set the preemptive priorities >0 for ALL the listed interrupts?

  1. On STM32, the three interrupts handlers provided by FreeRTOS are SysTick, PendSV, and SVCall (aka SVC). You should tell CubeMX not to generate handlers for those three.

  2. As for other interrupts, you need to divide them into two categories: those with ISRs that make FreeRTOS API calls, and those with ISRs that do not make FreeRTOS API calls.
    An ISR that makes API calls must use a lower priority (numerically higher) than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. An ISR that does not make API calls can use any interrupt priority.

1 Like