FreeRtos : Only one task Running

A few days ago, I was running FreeRTOS smoothly without any issues, but when my STM32f4XX vgt6 microcontroller experienced a short circuit, I purchased a microcontroller with the same version, but my friend doesn’t remember which online store he bought it from (I will include a photo of the old microcontroller and the link to purchase the new microcontroller). When I ran the old code, no tasks were executed. Then I created 2 tasks with different priorities and ran a simple code, but only the task with the highest priority was executed. I’m confused, is this a code configuration error, microcontroller damage, or what? I ran it using the Arduino IDE, then converted it to a binary file and uploaded it using the ST-LINK utility.

#include <HardwareTimer.h>
#include <STM32FreeRTOS.h>

void setup() {
          1,  //Priority Lebih Rendah
          1024,  //awal 512
          2,  //Priority Lebih Tinggi

void loop() {


Task 1

void Sensor(void *pvParameters) {
  while (1) {
   vTaskDelay(10 / portTICK_PERIOD_MS);

Task 2

void Kaki(void *pvParameters) {
  while (1) {
    vTaskDelay(1000 / portTICK_PERIOD_MS);

Hello @mardana,

Welcome to FreeRTOS forums!

If it is the same microcontroller and your code is exactly the same, then it should work smoothly. It is weird that it does not.
Your task definitions look okay to me. We can rule out them being an issue.

We can go over some basic checks to verify that what is going on:

  • Can you check the return value of xTaskCreate to verify whether the tasks are actually created?
  • Did you try adding a break point to either task to see whether the breakpoints are being ‘hit’ which would tell us whether the task even runs once?
  • Can you enable asserts by adding a definition for configASSERT in FreeRTOSConfig.h?
  • Can you verify that any task is not exceeding its stack space - unlikely as you as giving 1024 words worth of space to both tasks?

That should help us narrow down the problem.


Thank you for the advice and knowledge provided.

  1. I have tried to check the tasks created with xTaskCreate and tested them with if( xReturned == pdPASS ), and it resulted in true, indicating that both tasks have been created.
  2. I print a string in each task, but only the string in the highest-priority task is printed.
  3. I don’t understand its meaning, but after I opened the library and searched for configASSERT in FreeRTOSConfig.h, I found this line of code: #define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }
  4. I have tried giving stack values of 128, 512, and 1024, and the result is the same, only the highest-priority task is executed.

I apologize for not informing earlier that I am using the STM32FreeRtos library, which is used to run FreeRtos on STM32f407 in the Arduino IDE. After downgrading the library version from 10.3.2 to 9.0.4, FreeRTOS works as usual, but sometimes the robot stops or stays still for some reason. I think this might be due to the significant version difference, leading to some bugs. Now, how can I make my microcontroller use the latest STM32FreeRtos library? I am confused if there is any configuration in the library before using it, or perhaps I need to update my microcontroller board (I also don’t know how to do that).

This is the GitHub link to the library I’m using

The purchase link and specification for the STM32f4


I had a similar behavior in my code, and the problem was the amout of memory defined in the TCB, in your case, 1024.

In fact, the real root cause was the FreeRTOSConfig.h that I received when the RAKWireless libraries for boards(in my case it is a Nordic nRF52840) was installed it was wrong.

In the AWS Github has some vendors (they are a little bit old but you can compare with number that you have in your file), and ST has: FreeRTOSConfig.h for STM32l475. Maybe you can find some fixes… :slight_smile:



Can you toggle 2 different LEDs from 2 tasks to confirm if the task is not executing or print is not working?

This means that you have defined configASSERT and you are good.