CM7, xTaskResumeFromISR, vPortValidateInterruptPriority

Hello,
I am new in FreeRTOS. Im using ATSAME70 and atmel studio.

I have problem with returning from interupt - xTaskResumeFromISR call ASSERT in port.c and lag on line 744.
configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );
ucCurrentPriority = 0, ucMaxSysCallPriority=128

If I comment this line, it’s all good, but I don’t think it’s a good way.

Thanks for reply :slight_smile:

It seems the interrupt priority assigned to your interrupt (0 in your case) is too high. But in Cortex M, that means the number is too low. Priority numbers are inverted as described here:

If you have a call to NVIC_SetPriority() for your interrupt, you’ll need to change the priority value you are passing it. The value of 0 is the highest priority. That priority is too high to make calls to the FreeRTOS API. Only lower priority ISRs are allowed to make FreeRTOS API calls.

1 Like

Want to make sure you realise xTaskResumeFromISR() is not a safe function to use to synchronize tasks with interrupts (as described on its documentation page) - if that is your use case then consider a direct to task notification instead.

1 Like

Pardon me,sir,
if official side alreday be aware of the demerit like above.why does someone wanna fix this,maybe by removing this API from new version ago.
I remember some where :“FreeRTOS is designed to be:• Simple
• Portable
• Concise”
I wish many situation like above to be more Simple ,more Concise.

While there are some common mis-use pattern of suspend/resume, they are an ancient simple system. (Yes, now that we have the direct-to-task, many uses of it could be migrated, but why change working code).

The presence of this API, if unused is negligible (and complete disappear if you don’t have a #define INCLUDE_vTaskSuspend 1 statement in FreeRTOSConfig.h, so it is Simple, Portable, and Concise.

Ok, thanks. I must more read about FreeRTOS, becose I am stiil at start with using them.
For control, if I undestend this -> This is only save thing and I must set the priority to 4-7 (I have set configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY to 4) if I want call API function from interrupt. When I use higher priority (0-3), I must not use API function. It is so?

Basically correct. The concrete numbers are up to your FreeRTOS configuration.
This is well documented e.g. here configMAX_API_CALL_INTERRUPT_PRIORITY.

1 Like