AnsweredAssumed Answered

STM4Cube+FreeRTOS: xTaskIncrementTick() could be called when pxCurrentTCB == NULL

Question asked by popov.dmitry on Jul 20, 2014
Latest reply on Aug 24, 2014 by dobromyslov.viachesl
I’m running code, generated by STM32Cube and have dropped to HardFault_Handler() on start of execution.
By debugging I have found this issue:
STM32Cube code generator placed xPortSysTickHandler() into SysTick_Handler() for 1 ms tick counting.
xPortSysTickHandler() calls xTaskIncrementTick(), which execute follow code:
...
if( listCURRENT_LIST_LENGTH( &( pxReadyTasksLists[ pxCurrentTCB->uxPriority ] ) ) > ( UBaseType_t ) 1 )
...
But, clock system had initialized before any tasks have been created. 
And interrupt SysTick_Handler() may occurs when no tasks and even scheduler is not running yet.
So, pointer pxCurrentTCB equal to zero at this moment and [pxCurrentTCB -> uxPriority] indicates some random value.
It caused system exception.
As temporary solution I just have added one of task creation procedure before clock initialization. That is not good coding, but works.

And... by the way, when latest version of FreeRTOS will be implemented into Cube?

Outcomes