This is for FreeRTOS 7.5.2 for ARM Cortex M3 device. This check is not performed in FreeRTOS 7.4.0.
I have some code for a high baud rate UART which is deliberately at a higher priority than FreeRTOS critical sections. When fired, it checks if it is in an RTOS critical section using IARs __get_BASE_PRI() function, and if not it makes a call to xSemaphoreGiveFromISR(). If it IS in a critical section, it queues some information and makes the call when the critical section is left.
This code works fine on 7.4.0, and I have configASSERT enabled. On 7.5.2 if fails checks made in vPortValidateInterruptPriority (in port.c):
/* Is the interrupt number a user defined interrupt? */
if( ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
{
I don't believe what I am doing is fundamentally wrong, and believe that the check here SHOULD at least check if the ISR is calling from a critical section:
/* Is the interrupt number a user defined interrupt? */
if( uxCriticalNesting > 0 && ulCurrentInterrupt >= portFIRST_USER_INTERRUPT_NUMBER )
{
Or even further, the interrupt details are irrelevant, and just check that an ISR API call is not being made from within a critical section. The whole function I think should read:
void vPortValidateInterruptPriority( void )
{
configASSERT( uxCriticalNesting == 0 );
}
And the assert check on portAIRCR_REG performed once only at FreeRTOS startup.
In fact, I would like to have that as an API function, something like:
which I could use to make calls at safe times. That would be less of a hack than my use of __get_BASE_PRI to guess when FreeRTOS is in a critical section.
Last edit: ilgitano 2015-03-30
Not going to implement for the reasons mentioned in the following forum post:
https://sourceforge.net/p/freertos/discussion/382005/thread/936d91c9/#325f