Navigation
- Examples on GitHub
Modelling-Tool specific Intro
Getting started
How-To
Language Backends
Designers Toolbox
- Using regions or not New!
- Article on www.embedded.com State charts can provide you with software quality insurance.
Examples
There are better ways to model state machines than using spread sheets!
In the past different μC manufacturers have published application notes about the benefit of using state machines for the design of embedded software. An example is the application note SLAA402 from Texas Instruments (TI). It suggests to generate source code based on a spread sheet table. Nowadays several affordable UML modeling tools are available supporting the efficient design of state machines in a graphical way. SinelaboreRT generates production quality source code from state diagrams created with many different UML tools. Give it a try!
Leave your comments
There are different possibilities. The most flexible is probably that you use a simple event queue per state machine. Then you check for each queue in the main loop if there is an event and then call the corresponding state machine.
An example of this approach is shown here: https://www.sinelabore.de/doku.php/wiki/news/02jan2015
The code example starts at "Weaving the state machines and the library part together”.
A simple implementation of a queue is also available on this page further down in the “lib” folder of the download. Or alternatively here: https://github.com/sinelabore/examples/tree/master/lib
If your machine has only view events (e.g. an irq handler implemented as SM) you can also instruct the code generator to generate the events represented as bits in a bitfield. Then a simple variable can store the events (bit set) for your state machine. But I think the queue based design is much more flexible. The relevant configuration parameter in the config file is: EventsAreBitCoded=yes
I send you the MPLAB files by separate mail.
Best regards,
Peter
I am evaluating your code generator for use with PIC24 controllers. I saw in Getting started with the PIC16F18446 and State Machines that you said "Use the example and expand it to learn. To receive a copy just send a mail."
Would it be possible to send me the MPLAB project for an example?
Also, I have a question about having several State Machines in the main loop. Do I have to worry about events being consumed by the wrong SM? How do I handle passing events to the correct SM?
Best Regards,
Jonathan Baize