FreeRTOS context switch problem

jvgediya wrote on Wednesday, September 27, 2017:

I am using FreeRTOS for my high traffic network application on CM4 without FPU. I am using CM3 port because there is no FPU on CM4.

I have configASSERT defined in FreeRTOS. My controller supports 3 Priority bits and I have defined below priority related macros which should be proper.

/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
    /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
    #define configPRIO_BITS               __NVIC_PRIO_BITS
#else
    #define configPRIO_BITS               4        /* 15 priority levels */
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY         0x7

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY    1

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY    (configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))

/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
#define configASSERT(x) if((x) == 0) {taskDISABLE_INTERRUPTS(); for(;;);}


NVIC_PRIO_BITS is defined as 3. I am setting priority of my interrupt as 3 which is higher(logically lower) than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY so it should be fine too for using FreeRTOS(ISR) APIs from ISR.

I am using FreeRTOS V9.0.0.

Problem statement:
I am using FreeRTOS queues for commmunication between ISR and Tasks. When i use portYIELD_FROM_ISR() inside ISR, Even if item is posted successfully to the Queue, Task which is blocking on QueueReceive is not getting unblocked. Everything works for sometime but suddenly this issue appears.

I tried stack overflow hooks but it is not hitting and i have provided enough stack for tasks and interrupts.

This issue appears only when i do YIELD from ISR otherwise everything works fine.

Anyone have any idea about the possible issue?

rtel wrote on Wednesday, September 27, 2017:

Can you post the code that sets the priority of the interrupt, and the ISR code, thanks.

Which version of FreeRTOS are you using?

jvgediya wrote on Thursday, September 28, 2017: