Enthernet Code
Enthernet Code
DIIDevHeads IoT Integration Server
Created by Boss lady on 6/21/2024 in #middleware-and-os
How do I set and manage interrupt priorities in FreeRTOS?
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);
}
5 replies