I am using FreeRTOS on STM32F4 MCU. And I am new to FreeRTOS, I have generated the configurations from STM32Cube IDE. Without any tasks, My board keeps rebooting, I don’t know what I am missing. Please help me to overcome this issue or is it normal behavior? Please explain.
/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
application must provide an implementation of vApplicationGetTimerTaskMemory()
to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer,
StackType_t **ppxTimerTaskStackBuffer,
uint32_t *pulTimerTaskStackSize )
{
/* If the buffers to be provided to the Timer task are declared inside this
function then they must be declared static – otherwise they will be allocated on
the stack and so not exists after this function exits. */
static StaticTask_t xTimerTaskTCB;
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
/* Pass out a pointer to the StaticTask_t structure in which the Timer
task’s state will be stored. */
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
/* Pass out the array that will be used as the Timer task’s stack. */
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
Note that, as the array is necessarily of type StackType_t,
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}
int main(void)
{
HAL_Init();
SystemClock_Config();
PheripheralsInitialization();
printf("Board Initialized\r\n");
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
osKernelStart();
while(1);
}
When running in debug mode, I am getting “Board Initialized” text continuously in serial monitor. I used a global variable and incremented it within main(), printed and checked, I am getting variable as 0 continuously.
Is this the default code generated by the IDE or did you make any change? Can you share the complete code - may be put it in GitHub and share link?
Are you using custom hardware or a dev board? Can you step through the code of osKernelStart and see where it fails?