Dr_Nic
(Nic)
August 20, 2025, 10:19am
1
STM32F411RE, CubeIDE
I have 4 tasks, all of equal priority, each with their own task profile counter,
void acquire_tsk(void *pvParameters);
void noise_tsk(void *pvParameters);
void combine_tsk(void *pvParameters);
void filter_tsk(void *pvParameters);
uint32_t task1Profiler, task3Profiler, task3Profiler, task4Profiler;
main()
{
xTaskCreate(acquire_tsk, "get signal", 100, NULL, 1, NULL);
xTaskCreate(noise_tsk, "get noise", 100, NULL, 1, NULL);
xTaskCreate(combine_tsk, "combine signal", 100, NULL, 1, NULL);
xTaskCreate(filter_tsk, "filter signal", 100, NULL, 1, NULL);
vTaskStartScheduler();
while(){}
}
void acquire_tsk(void *pvParameters)
{
while(1)
{
task1Profiler++;
}
}
void noise_tsk(void *pvParameters)
{
while(1)
{
task2Profiler++;
}
}
void combine_tsk(void *pvParameters)
{
while(1)
{
task3Profiler++;
}
}
void filter_tsk(void *pvParameters)
{
while(1)
{
task1Profiler++;
}
}
When I open up my debugger & track the task profilers only task1Profiler
counts up, all the others remain at 0
.
I was expecting round robin scheduling & to see all the task profilers to count up. What am I missing here?
hs2
(Hartmut Schaefer)
August 20, 2025, 10:38am
2
Did you configure your FreeRTOS app accordingly ?
Dr_Nic
(Nic)
August 20, 2025, 11:04am
3
I am using the default config which according to the docs,
By default, FreeRTOS uses a fixed-priority preemptive scheduling policy, with round-robin time-slicing of equal priority tasks
hs2
(Hartmut Schaefer)
August 20, 2025, 11:14am
4
Seems right then.
So … maybe the SysTick isn’t running or not setup correctly ?
You could put a breakpoint @ xTaskIncrementTick
to see if it’s hit periodically or halt the target and check that the (global) xTickCount
variable is incremented.
Dr_Nic
(Nic)
August 20, 2025, 11:33am
5
Put a break point @TaskIncrementTick
it is never hit
xTickCount
variable is never incremented.
Dr_Nic
(Nic)
August 20, 2025, 11:56am
6
Although HAL timebase functions are declared as weak, do you think this might a problem with HAL using SysTick as well as RTOS using it?
Dr_Nic
(Nic)
August 20, 2025, 12:17pm
7
Yes it was the HAL messing with FreeRTOS’s handling of SysTick, thanks for the pointer.
Changed HAL’s clock by changing SYS clock to TIM1 & all is working as expected.
aggarg
(Gaurav Aggarwal)
August 20, 2025, 2:56pm
8
FreeRTOS tasks are not supposed to exit. You need to either make them infinite loop or call vTaskDelete:
void acquire_tsk(void *pvParameters)
{
for( ;; )
{
task1Profiler++;
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
}
}
OR
void acquire_tsk(void *pvParameters)
{
task1Profiler++;
vTaskDelete( NULL );
}
Dr_Nic
(Nic)
August 20, 2025, 3:03pm
9
OOps my bad they are all in a while(1){}
loop. In my haste I forgot to include that, will edit the OP accordingly.