I’m starting to understand and learn about RTOS and I wanted to test a simple code to run two tasks in a Nucleo-F072RB, however, I am only able to run 1 task and I am not able to get to my task #2. I may need something else in my code but I would like to get some support from you guys and that way I could understand it better. (Hopefully).
What I want to do is to run both tasks, I know there is no simultaneously tasks running at the same time, but I am hoping to get one task… then run the other… and so on.
I am also aware that main() function is a main thread but I was hoping to handle tasks in different handlers (functions).
Your code runs OK on a NUCLEO-F103RB (20kB SRAM). Maybe the NUCLEO-F072RB (16kB SRAM) doesn’t have sufficient SRAM to run correctly such program. To learn RTOS I would suggest to get a board with more SRAM (32kB and more). At the moment the STM32F401 (96kB SRAM, 4.55$ on eBay) and STM32F411 (128kB SRAM, 4.88$ on eBay) development boards seem to have a very good price-to-SRAM ratio. The STM32F407VET6 (128kB + 64kB SRAM) development board, with on-board SD card slot, 16Mbit SPI Flash memory and battery holder, could be also a good (low cost) choice. Then you can use the NUCLEO-F072RB as a programmer.
I also have other STM32 boards here to test, I used a Nucleo-F411RE and the code run it succesfully!
Then I tested my code in the Nucleo F072RB and I saw this in the terminal:
++ MbedOS Error Info ++
Error Status: 0x8001011F Code: 287 Module: 1
Error Message: Operator new[] out of memory
Location: 0x8004D31
Error Value: 0x1000hell
Current Thread: main Id: 0x200014D4 Entry: 0x8005E79 StackSize: 0xC00 StackMem: 0x200003C8 SP: 0x20000F18
So yes, it is running out of memory.
I was thinking and I would like to know from your side if is possible to change the stack size and then maybe able to run several tasks in this board ?
Mostly because I previously tested FreeRTOS in STM32Cube framework and there I was able to run multiple tasks/threads (I simply ran 2 threads, did not test more than that).