SinelaboreRT Header Logo


Productivity for embedded software development

User Tools

Site Tools


How to use state machines generated by Sinelabore with the CubeMX tool from STM

This example shows how easy it is to add statemachines to STM32 CubeMX projects.

The example was created for the STM32F103C8T, for which very cheap eval boards are available.

The graphic shows the typical development flow for a CubeMX project and where the Sinelabore State Machine Generator comes into play.

 Example project generated with the CubeMX and Sinelabore

In the example, CMSIS RTOS API is used with 2 tasks, a message queue and a timer. The state machine runs in Task02 and receives its events from the timer callback function cyclicTimer0Callback. And also from the default task. The state machine is kept simple and generates a blinking pattern that is terminated after some time by a FailSafe event.

The Statemachine was created with the integrated Statediagram Editor. To modify the machine, start the editor, load the model and regenerate the code after your changes.

Follow the steps below to create the example itself. It is assumed that you have installed the GNU Arm compiler tools and a debug interface. Links to the tools you need can be found below.

  • Download the demo project zip and unzip it
  • Create a project folder
  • Copy the project file to your project folder and load the project with the CubeMX programme.
  • Generate the complete project code from it into the project folder.
  • Replace the generated Makefile with the modified Makefile provided in the demo project folder. The modified Makefile contains the state machine C/H path.
  • Finally replace main.c in the Core/Src folder with the demo version. It contains the application from two tasks.

Now you can call make and flash the created elf file into the board with the debugger.

In one console run the debug stub;

  • /opt/homebrew/bin/st-util

In another console run the debugger:

  • /Applications/ARM/bin/arm-none-eabi-gdb
  • target remote
  • load build/example.elf
  • file build/example.elf
  • c

The ARM Tools and CubeMX make it super easy to get started with the STM uC family and the Sinelabore Statemachine Generator completes the toolschain perfectly.


This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
wiki/howto/cubemx.txt · Last modified: 2023/10/11 19:11 by webmin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki