0
0
FreeRTOSprogramming~5 mins

configMAX_SYSCALL_INTERRUPT_PRIORITY in FreeRTOS

Choose your learning style9 modes available
Introduction

This setting controls the highest interrupt priority that can safely call FreeRTOS system functions.

When you want to protect FreeRTOS API calls from being interrupted by higher priority interrupts.
When configuring interrupt priorities to ensure system stability.
When you need to balance interrupt responsiveness with safe FreeRTOS operations.
Syntax
FreeRTOS
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( <priority_value> )

The priority value depends on your microcontroller's priority scheme.

Interrupts with a higher priority number (lower urgency) than this can call FreeRTOS APIs.

Examples
Sets the max syscall interrupt priority to 5 (example value).
FreeRTOS
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 5
Sets the max syscall interrupt priority using a hex value, common in Cortex-M MCUs.
FreeRTOS
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 0x20
Sample Program

This example shows how to define configMAX_SYSCALL_INTERRUPT_PRIORITY and use an interrupt handler that safely calls FreeRTOS APIs.

FreeRTOS
#include "FreeRTOS.h"
#include "task.h"

#define configMAX_SYSCALL_INTERRUPT_PRIORITY 5

void vAnInterruptHandler(void) {
    /* This interrupt can safely call FreeRTOS API because its priority is 5 or lower */
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    vTaskNotifyGiveFromISR(NULL, &xHigherPriorityTaskWoken);
    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}

int main(void) {
    /* System and FreeRTOS initialization here */
    for(;;) {
        /* Main loop */
    }
    return 0;
}
OutputSuccess
Important Notes

Always set configMAX_SYSCALL_INTERRUPT_PRIORITY according to your MCU's priority scheme.

Interrupts with priority higher than this value must NOT call FreeRTOS API functions.

Incorrect settings can cause system crashes or unpredictable behavior.

Summary

configMAX_SYSCALL_INTERRUPT_PRIORITY limits which interrupts can safely use FreeRTOS APIs.

Set it carefully based on your hardware's interrupt priority levels.

Helps keep your system stable and responsive.