I am running FreeRTOS on a nrf52840
I have 2 interrupts running and my RTOS crashes if I enter in an interrupt while in another one
To avoid such case I added the critical region functions, I also added debug pins to see time spent in the two irqs
void my_irq (void)
{
BaseType_t xHigherPriorityTaskWoken;
UBaseType_t uxSavedInterruptStatus;
uxSavedInterruptStatus = taskENTER_CRITICAL_FROM_ISR();
d_set_pin();
xHigherPriorityTaskWoken = pdFALSE;
/* some code */
vTaskNotifyGiveFromISR(acq->task.handler, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
d_clear_pin();
taskEXIT_CRITICAL_FROM_ISR(uxSavedInterruptStatus);
}
It did not work so I tried disabling interrupts :
void my_irq (void)
{
BaseType_t xHigherPriorityTaskWoken;
taskDISABLE_INTERRUPTS();
d_set_pin();
xHigherPriorityTaskWoken = pdFALSE;
/* some code */
vTaskNotifyGiveFromISR(acq->task.handler, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
d_clear_pin();
taskENABLE_INTERRUPTS();
}
But still I get this and it crashes :
Do you have any ideas why my MCU leaves the interrupt routine ?
Your MCU is built around ARM Cortex-M4F kernel. I'm sorry, you didn't mention this in your question, did you set interrupt priorities correctly, according to this: https://www.freertos.org/RTOS-Cortex-M3-M4.html ?
Also I've found that you can't call FreeRTOS API functions from within critical section in the ISR. See this: https://www.freertos.org/taskENTER_CRITICAL_FROM_ISR_taskEXIT_CRITICAL_FROM_ISR.html
I'm sorry again if you've already checked these moments.