I have STM32F746ZG Nucleo-144pin board and generated the codes using STMCubeMx. I chose the FreeRTOS which is version 10.0.0 offered by CubeMx and the toolchain is SW4STM32.
I made two tasks and the following is my function. My code here:
void led1_task(void)
{
while(1)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7);
HAL_Delay(1000);
}
}
void led2_task(void)
{
while(1)
{
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
HAL_Delay(4100);
}
}
- Task priority.
I found that if two tasks have the same task priority, the two tasks work fine, but if they have different priority of task, the low task does not work.
xTaskCreate(led1_task, "led1_task", 1024, NULL, 2, NULL); ==> Works fine.
xTaskCreate(led2_task, "led2_task", 1024, NULL, 2, NULL); ==> Works fine.
----------------------------------------------------------------------------
xTaskCreate(led1_task, "led1_task", 1024, NULL, 2, NULL); ==> This task is not working.
xTaskCreate(led2_task, "led2_task", 1024, NULL, 3, NULL); ==> Works fine.
- Task stack size.
If the stack size of the two tasks combined to be greater than 3 KB, it was confirmed that the task was not working correctly. The code below works correctly.
xTaskCreate(led1_task, "led1_task", 2048, NULL, 2, NULL); ==> Works fine.
xTaskCreate(led2_task, "led2_task", 1024, NULL, 2, NULL); ==> Works fine.
However, the second task does not work if the stack size is changed as follows.
xTaskCreate(led1_task, "led1_task", 2048, NULL, 2, NULL); ==> Works fine.
xTaskCreate(led2_task, "led2_task", 2048, NULL, 2, NULL); ==> This task is not working.
Attempting to change the _Min_Stack_Size from 0x400 to 0x4000 in STM32F746ZGTx_FLASH.ld has the same problem.
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x200; /* required account of heap */
_Min_Stack_Size = 0x4000; /* required account of stack */
Can anyone explain the reason for this?