Skip to main content
Graduate II
June 10, 2024
Question

How to transform a project without RTOS into a project with Azure RTOS?

  • June 10, 2024
  • 2 replies
  • 2321 views

Hi all,

thank you very much for the valuable advices.

I am writing to you because I would like to understand how I can convert an existing program without Azure RTOS ThreadX with a program in which I use Azure RTOS ThreadX.
For example I would like to add Azure RTOS ThreadX on an existing program that reads a series of values ​​with GPIO, ADC, or by communicating with external components with SPI and I2C and sets digital signals with PWM and GPIO. It also communicates via the serial port with another board.
What should I do with CubeMX?
Do I take the existing project and add ThreadX in the "Middleware" section and change the timebase source for "SYS" from SysTick to TIM6 in the "System Core" section?
Do I need to make further changes in CubeMX?
At the code level I will have to use Threads, but how can I structure the program?
Currently the commands arrive on the serial port through the interrupt and I insert them into the relevant buffer which is read by a function present in the while(1) of the main. The readings of some digital and analog signals are made every few milliseconds and to do this I use interrupts. I would like to understand how I can structure the program. How can I organize at file level, today almost all the code is in the main.c file and I would like to understand with what logic I create the threads and assign them to the various activities (GPI readings, ADC readings, reading from external components with SPI and I2C, management of the serial buffer and related responses, writes to memory, etc.).

Let me know what rules I should follow to structure the code well.

Thank you very much for the support.

    This topic has been closed for replies.

    2 replies

    Super User
    June 10, 2024

    Don't forget to add a link to this in your previous thread!

    And did you take a look at those introductory resources?

    No, you can't just "bolt on" an RTOS to an existing project.

    Running under an RTOS is a whole new way of structuring your system - you need to design your task structure, think about priorities, think about how tasks will communicate, etc, etc ...

    Graduate II
    June 10, 2024

    Hi @Andrew Neil ,

    yes I read the documentation quite fast and I checked also the webinar on the ST youtube channel about Azure RTOS ThreadX. The example of the toggle led with and without RTOS is very easy, but what about a more complex program?

    It could be very useful to understand step by step how to design the task structure. I do not have experience with RTOS and if you have some advices or some step by step documentation or projects about how to design a project with Azure RTOS ThreadX, it could be very useful.

    Thank you very much for the support.

    Graduate II
    June 10, 2024

    In classic app you dont require RTOS, only IRQ and DMA is capable todo all required, but this ends when multiclient peripheral exist. For example ethernet or audio stream... Here MCU require more as one thread system.

    Your question switch to RTOS is simple all from main while you manualy move into first task... Next steps is your job

    Super User
    June 10, 2024

    Here you can find advice and help with all aspects of your STM32 project.