haditj66 wrote on Saturday, August 10, 2019:
FreeRTOS V9.0.0
stm32f411
I am getting a hardfault after a while of calling the following simplified code within an ISR.
Am I getting the settings wrong in the config settings for ISR priorities? or am I calling the FROMISR API incorrectly?
the ISR:
void ISRCallback()
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
for (int i = 0; i < NUMOFACTIVEOBJECTS; i++)
{
if (EventSubscribers[evtId][i])
{
xQueueSendToBackFromISR(AEAO::AllAO[i]->queueExecuteForEvt, &AddingsubscriberArgs->Arg4, &xHigherPriorityTaskWoken);
}
}
if( xHigherPriorityTaskWoken )
{
/* Actual macro used here is port specific. */
portYIELD_FROM_ISR (xHigherPriorityTaskWoken);
}
it is sending an object to one or more queues. After this ISRcallback is executed exactly 31 times, a hardfault occurs at this line of code in the timers.c file at line 618
hardfault location:
if( xTaskResumeAll() == pdFALSE )
{
/* Yield to wait for either a command to arrive, or the
block time to expire. If a command arrived between the
critical section being exited and this yield then the yield
will not cause the task to block. */
portYIELD_WITHIN_API();
}
It must be something to do with the way I am calling the xQueueSendToBackFromISR API because when I remove all mentions of this, the hardfault does not happen anymore.
here are the relevant settings I have for the NVIC:
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
for the ISR:
HAL_NVIC_SetPriority(USART2_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(USART2_IRQn);
for the tasks that the queues the isr sends to :
PRIORITY 10
for the freertosconfig:
#define configMAX_PRIORITIES ( 16 )
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
#define configPRIO_BITS 4
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
#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) )