Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

I have a NUCLEO-H743ZI ARM STM32 Nucleo-144 development board with STM32H743ZI MCU and we are trying to create 3 tasks with blinking 3 different LED’s in each task. But while tried to create more than 3 tasks and ran the scheduler , 3 tasks only ran at a time and no break point hit the function of other remaining task. Attached the main.c file for reference.

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Did you check the return value of the xTaskCreate() calls used to create the tasks? If they returned pdFALSE then the tasks could not be created because you ran out of heap memory. https://www.freertos.org/a00125.html xTaskCreate() https://www.freertos.org/a00111.html heap management https://www.freertos.org/StaticVsDynamicMemoryAllocation.html

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Hi Richard, I created four tasks and checked the return values of each tasks. All the tasks return the pass response(pdPASS). After Debugging the project, while viewing the “Freertos Task list”, the viewed tasks were “3 tasks+one IDLE task”.Attached the main.c file for reference.

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Hi Richard, I created four tasks and checked the return values of each tasks. All the tasks return the pass response(pdPASS). After Debugging the project, while viewing the “Freertos Task list”, the viewed tasks were “3 tasks+one IDLE task”.Attached the main.c file for reference.

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

How are you determining task 4 does not run? Is your printf() thread safe? As not all your tasks block, do you have configUSETIMESLICING set to 1 (or left undefined, in which case it will default to 1).

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Hi Richard, How i determined the fourth task was not created is a) by looking the “freertos task list” option provided in “view” menu. In that freertos task list only 3 task were created. b) Put the breakpoint in any one of line of function which was called by fourth task. Finally I find out the problem is in stackdepth size I am allocated to each tasks. For example if the stack is 32-bits wide and usStackDepth(one of the parameter allocated to each task) is 400 then 1600 bytes will be allocated for use as the task’s stack. The stack i am currently using was 32 bit, My TOTALHEAPSIZE was around 15000 only. For eack task, i allocated 1000 (that means 4000 bytes allocated for each tasks). Four tasks means 16000 bytes will be allocated totally which exceeds the TOTALHEAPSIZE. while allocating the stackdepth as 400 (1600 bytes) to each task, will be able to create more 3 tasks now.

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Hi Richard, How i determined the fourth task was not created is a) by looking the “freertos task list” option provided in “view” menu. In that freertos task list only 3 task were created. Attached the reference for the “freertos task list” for the ran task b) Put the breakpoint in any one of line of function which was called by fourth task. Finally I find out the problem is in stackdepth size I am allocated to each tasks. For example if the stack is 32-bits wide and usStackDepth(one of the parameter allocated to each task) is 400 then 1600 bytes will be allocated for use as the task’s stack. The stack i am currently using was 32 bit, My TOTALHEAPSIZE was around 15000 only. For eack task, i allocated 1000 (that means 4000 bytes allocated for each tasks). Four tasks means 16000 bytes will be allocated totally which exceeds the TOTALHEAPSIZE. while allocating the stackdepth as 400 (1600 bytes) to each task, will be able to create more 3 tasks now.

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Hi Richard, How i determined the fourth task was not created is a) by looking the “freertos task list” option provided in “view” menu. In that freertos task list only 3 task were created. Attached the reference for the “freertos task list” for the ran task b) Put the breakpoint in any one of line of function which was called by fourth task. Finally I find out the problem is in stackdepth size I am allocated to each tasks. For example if the stack is 32-bits wide and usStackDepth(one of the parameter allocated to each task) is 400 then 1600 bytes will be allocated for use as the task’s stack. The stack i am currently using was 32 bit, My TOTALHEAPSIZE was around 15000 only. For eack task, i allocated 1000 (that means 4000 bytes allocated for each tasks). Four tasks means 16000 bytes will be allocated totally which exceeds the TOTALHEAPSIZE. while allocating the stackdepth as 400 (1600 bytes) to each task, will be able to create more 3 tasks now.

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Then the forth created shouldn’t have returned success on the create (which sounds like it shouldn’t), which would explain it not being created., so you code checking the return value of the create must be broken.

Unable to create more than 3 tasks in STM 32 (nucleo H743ZI)

Hi Richard, Yes I get the failure return response (0 means pdFALSE) for the fourth task while creating. Sometimes the fourth task creation,I get the return value(-1) returned for the “taskcreate function”. I don’t the meaning why the response -1 returned? In your reply, you said like “Is your printf() threadsafe?”. Could you tell more about this and how can we implement with thread safe?