Enthernet Code
DIIDevHeads IoT Integration Server
•Created by Marvee Amasi on 5/26/2024 in #✅-code-review
Modifying FreeRTOS Interrupt Priorities After Scheduler Initialization
To debug this issue further, you can add more logging before and after setting the priority within your task to confirm if the priority is being changed as expected. Here’s an updated version of your code snippet with additional logging:
#include <FreeRTOS.h>
#include <queue.h>
#include <task.h>
#include "stm32f4xx_hal.h"
static void vTest_NVIC(void *pvParameters) {
tprintf("\r\nTask Started...");
while (1) {
taskENTER_CRITICAL();
uint32_t priority = NVIC_GetPriority(DMA1_Channel4_IRQn);
tprintf("\r\nCurrent priority: %d", (int)priority);
// Modify the priority to test if changes take effect
NVIC_SetPriority(DMA1_Channel4_IRQn, 5);
priority = NVIC_GetPriority(DMA1_Channel4_IRQn);
tprintf("\r\nModified priority: %d", (int)priority);
taskEXIT_CRITICAL();
vTaskDelay(pdMS_TO_TICKS(3000));
}
}
int main(void) {
HAL_Init(); // Ensure the HAL is initialized
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 11, 0);
tprintf("\r\nInitial priority: %d", (int)NVIC_GetPriority(DMA1_Channel4_IRQn));
// Create a task
xTaskCreate(vTest_NVIC, "Test_NVIC", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
// Start the scheduler
vTaskStartScheduler();
// Infinite loop while (1) { } } This code ensures the initial priority is logged, then the priority is modified within the task, and the modified priority is logged again. This should help you identify if the priority changes are being applied correctly after the scheduler starts.
// Infinite loop while (1) { } } This code ensures the initial priority is logged, then the priority is modified within the task, and the modified priority is logged again. This should help you identify if the priority changes are being applied correctly after the scheduler starts.
4 replies