Hi
We face the issue that from time to time, freertos keeps being stuck in idle. The situation is as follows:
- suddenly just idle task and tick are running, even if there are other active tasks waiting to execute, but the scheduler wont switch into the tasks for some unknown reason. this means the firmware is executing ok for some time, then suddenly, just tick IRQ handler and the idle task keep running. other interrupts sometimes work, sometimes not.
- the rtos is configured for tickless idle
- mcu is efm32gg380f1024 (cortex m3)
i suspect a configuration issue with the rtos, havent found it yet though.
can someone who has experience with the tickless idle mode have a look at it?
note:
please review especially those values:
-
configUSE_TICKLESS_IDLE
-
configUSE_PREEMPTION
-
configUSE_PORT_OPTIMISED_TASK_SELECTION
-
configMAX_PRIORITIES
-
configIDLE_SHOULD_YIELD
-
configTIMER_TASK_PRIORITY
-
configPRIO_BITS
-
configLIBRARY_LOWEST_INTERRUPT_PRIORITY
-
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY
-
configKERNEL_INTERRUPT_PRIORITY
-
configMAX_SYSCALL_INTERRUPT_PRIORITY
-
scheduler_init()
#define configUSE_NEWLIB_REENTRANT ( 1 )
#define configTICK_RATE_HZ ( 100 ) // 100 Hz (instead of the default 1kHz)#define configUSE_TICKLESS_IDLE ( 1 )
#define configEXPECTED_IDLE_TIME_BEFORE_SLEEP ( 2 )#define configUSE_TICK_HOOK ( 1 )
#define configCHECK_FOR_STACK_OVERFLOW ( 2 )
#define configUSE_MALLOC_FAILED_HOOK ( 1 )
#define configUSE_IDLE_HOOK ( 0 )
#define configUSE_DAEMON_TASK_STARTUP_HOOK ( 1 )#define configUSE_PREEMPTION ( 1 )
#define configUSE_PORT_OPTIMISED_TASK_SELECTION ( 1 )
#define configSUPPORT_STATIC_ALLOCATION ( 1 )
#define configSUPPORT_DYNAMIC_ALLOCATION ( 0 )
#define configCPU_CLOCK_HZ ( (unsigned long)28000000 )
#define configMAX_PRIORITIES ( 6 )
#define configMINIMAL_STACK_SIZE ( (unsigned short)1024 )
#define configTOTAL_HEAP_SIZE ( (size_t)(64000) )
#define configMAX_TASK_NAME_LEN ( 32 )
#define configUSE_TRACE_FACILITY ( 1 )
#define configUSE_16_BIT_TICKS ( 0 )
#define configIDLE_SHOULD_YIELD ( 0 )
#define configUSE_MUTEXES ( 1 )
#define configUSE_RECURSIVE_MUTEXES ( 1 )
#define configUSE_COUNTING_SEMAPHORES ( 1 )
#define configUSE_ALTERNATIVE_API ( 0 )
#define configQUEUE_REGISTRY_SIZE ( 32 )
#define configUSE_QUEUE_SETS ( 0 )#define configGENERATE_RUN_TIME_STATS ( 0 )
#define configUSE_CO_ROUTINES ( 1 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 1 )#define configUSE_TIMERS ( 1 )
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) // Highest priority
#define configTIMER_QUEUE_LENGTH ( 10 )
#define configTIMER_TASK_STACK_DEPTH ( 256 )#ifdef __NVIC_PRIO_BITS
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS ( 3 ) // 7 priority levels given by mcu cm3
#endif#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY ( 0x07 )
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ( 0x5 )#define configKERNEL_INTERRUPT_PRIORITY
( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )#define configMAX_SYSCALL_INTERRUPT_PRIORITY
( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )#define INCLUDE_vTaskPrioritySet ( 1 )
#define INCLUDE_uxTaskPriorityGet ( 1 )
#define INCLUDE_vTaskDelete ( 1 )
#define INCLUDE_vTaskSuspend ( 1 )
#define INCLUDE_xResumeFromISR ( 1 )
#define INCLUDE_vTaskDelayUntil ( 1 )
#define INCLUDE_vTaskDelay ( 1 )
#define INCLUDE_xTaskGetSchedulerState ( 1 )
#define INCLUDE_xTaskGetCurrentTaskHandle ( 1 )
#define INCLUDE_uxTaskGetStackHighWaterMark ( 0 )
#define INCLUDE_xTaskGetIdleTaskHandle ( 1 )
#define INCLUDE_xTimerGetTimerDaemonTaskHandle ( 1 )
#define INCLUDE_eTaskGetState ( 1 )
#define INCLUDE_xTimerPendFunctionCall ( 1 )
#define INCLUDE_xSemaphoreGetMutexHolder INCLUDE_xQueueGetMutexHolder
#define INCLUDE_xQueueGetMutexHolder ( 1 )
#define INCLUDE_xTaskGetHandle ( 0 )
#define INCLUDE_xTaskAbortDelay ( 1 )
#define INCLUDE_pxTaskGetStackStart ( 0 )
#define INCLUDE_xTaskResumeFromISR ( 1 )#define configASSERT(x) assert_check(FILENAME,LINE,FUNCTION,(x))
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler FreeRTOS_SysTick_Handler //BURTC#define fabs __builtin_fabs
// simplified function for discussion, not the real deal,…
void scheduler_init()
{
// initially set all interrupt handlers to lowest prio
for(int a=0, a<IRQn_device_nbrOf+1; a++)
{
NVIC_SetPriority(static_cast<IRQn_Type>(j-1), 7);
}// then set selected irq handlers higher (lower value) NVIC_SetPriority(USART0_RX_IRQn, 5); NVIC_SetPriority(USART1_RX_IRQn, 5); NVIC_SetPriority(USART2_RX_IRQn, 5); NVIC_SetPriority(UART0_RX_IRQn, 5); NVIC_SetPriority(UART1_RX_IRQn, 5); NVIC_SetPriority(LEUART0_IRQn, 5); NVIC_SetPriority(LEUART1_IRQn, 5); NVIC_SetPriority(USB_IRQn, 5); NVIC_SetPriority(GPIO_ODD_IRQn, 5); NVIC_SetPriority(GPIO_EVEN_IRQn, 5); NVIC_SetPriority(RTC_IRQn, 5); NVIC_SetPriority(BURTC_IRQn, 5); NVIC_SetPriority(TIMER0_IRQn, 6); NVIC_SetPriority(TIMER1_IRQn, 6); NVIC_SetPriority(TIMER2_IRQn, 6); NVIC_SetPriority(TIMER3_IRQn, 6); NVIC_SetPriority(LETIMER0_IRQn, 6); NVIC_SetPriority(USART0_TX_IRQn, 6); NVIC_SetPriority(USART1_TX_IRQn, 6); NVIC_SetPriority(USART2_TX_IRQn, 6); NVIC_SetPriority(UART0_TX_IRQn, 6); NVIC_SetPriority(UART1_TX_IRQn, 6);
}