How do I set and manage interrupt priorities in FreeRTOS?

@Middleware & OS How do I set and manage interrupt priorities in FreeRTOS? My higher priority interrupts are not preempting lower priority ones. Here's my NVIC configuration:
HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
HAL_NVIC_SetPriority(EXTI0_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
What could be causing this issue?
Solution:
Hi @Boss lady , you can try this ```cpp #include "FreeRTOSConfig.h" #include "stm32f4xx_hal.h" ...
Jump to solution
3 Replies
barafael
barafael7mo ago
Can you rule out priority inversion? Do you have locks in your system?
Solution
Enthernet Code
Enthernet Code7mo ago
Hi @Boss lady , you can try this
#include "FreeRTOSConfig.h"
#include "stm32f4xx_hal.h"

void HAL_NVIC_Setup(void) {
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);

HAL_NVIC_SetPriority(EXTI0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
}

void EXTI0_IRQHandler(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;

// Clear the interrupt
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);

// Perform your interrupt processing here

// Notify FreeRTOS about the ISR
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
#include "FreeRTOSConfig.h"
#include "stm32f4xx_hal.h"

void HAL_NVIC_Setup(void) {
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);

HAL_NVIC_SetPriority(EXTI0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
}

void EXTI0_IRQHandler(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;

// Clear the interrupt
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);

// Perform your interrupt processing here

// Notify FreeRTOS about the ISR
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
Boss lady
Boss lady6mo ago
Yes @barafael
Want results from more Discord servers?
Add your server