<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://sinelabore.de/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>SinelaboreRT - de</title>
        <description>Productivity for embedded software development</description>
        <link>https://sinelabore.de/</link>
        <lastBuildDate>Tue, 07 Apr 2026 22:29:53 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://sinelabore.de/lib/exe/fetch.php/favicon.ico</url>
            <title>SinelaboreRT</title>
            <link>https://sinelabore.de/</link>
        </image>
        <item>
            <title>Code aus UML Zustandsdiagrammen und Aktivitätsdiagrammen erzeugen!</title>
            <link>https://sinelabore.de/doku.php/de/start</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;code_aus_uml_zustandsdiagrammen_und_aktivitaetsdiagrammen_erzeugen&quot;&gt;Code aus UML Zustandsdiagrammen und Aktivitätsdiagrammen erzeugen!&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Code aus UML Zustandsdiagrammen und Aktivit\u00e4tsdiagrammen erzeugen!&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;code_aus_uml_zustandsdiagrammen_und_aktivitaetsdiagrammen_erzeugen&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;12-94&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;sinelabore_ermoeglicht_es_entwicklern_von_eingebetteten_systemen_event-basierte_architekturen_hierarchische_zustandsautomaten_modellbasiertes_design_und_automatische_codegenerierung_effektiv_zu_kombinieren&quot;&gt;Sinelabore ermöglicht es Entwicklern von eingebetteten Systemen, event-basierte Architekturen, hierarchische Zustandsautomaten, modellbasiertes Design und automatische Codegenerierung effektiv zu kombinieren.&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sinelabore&lt;em&gt;RT&lt;/em&gt; wurde speziell für Entwickler von eingebetteten Echtzeitsystemen entwickelt. Der Schwerpunkt liegt auf einer Aufgabe: Effizienten und verständlichen Code aus &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Zustandsdiagrammen (State Machines, State Diagrams) und Aktivitätsdiagrammen in C/CPP zu erzeugen. Der Generator ist ein schlankes und einfach zu verwendendes Werkzeug. Durch das neue Java, Swift, Lua und C# Backend ist es ebenfalls bestens für die Entwicklung von Desktop oder Serveranwendungen geeignet. Ein Payback ist üblicherweise schon innerhalb weniger Stunden gegeben.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Sinelabore erm\u00f6glicht es Entwicklern von eingebetteten Systemen, event-basierte Architekturen, hierarchische Zustandsautomaten, modellbasiertes Design und automatische Codegenerierung effektiv zu kombinieren.&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;sinelabore_ermoeglicht_es_entwicklern_von_eingebetteten_systemen_event-basierte_architekturen_hierarchische_zustandsautomaten_modellbasiertes_design_und_automatische_codegenerierung_effektiv_zu_kombinieren&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;95-880&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit3&quot; id=&quot;wie_funktioniert_der_generator&quot;&gt;Wie funktioniert der Generator?&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Von verschiedenen &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Tools erstellte Diagramme kann der Generator direkt in die gewählte Zielsprache übersetzten. Vor der Umsetzung werden ausführliche Tests auf Modellebene durchgeführt, um die Konsistenz des Modells sicherzustellen. Das erspart Zeit beim Review und Testen. Die folgende Generierung kann in weiten Grenzen an besondere Bedürfnisse angepasst werden. Der Generator unterstützt alle wichtigen &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Elemente in Zustandsdiagrammen (Deep/Flat History, Regions, Submachines) und Aktiviätsdiagrammen.
&lt;/p&gt;

&lt;p&gt;
Sie werden optimal in den verschiedenen Entwicklungsphasen, wie z.B. in der Testphase durch die automatische Erzeugung von Testfällen, oder während der Fehlersuche durch automatisch erzeugten Tracecode unterstützt.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.de/lib/exe/detail.php/sinelabore_homepage.svg?id=de%3Astart&quot; class=&quot;media&quot; title=&quot;sinelabore_homepage.svg&quot;&gt;&lt;img src=&quot;https://sinelabore.de/lib/exe/fetch.php/sinelabore_homepage.svg?w=800&amp;amp;tok=a37790&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot; Wie funktioniert der Generator&quot; alt=&quot; Wie funktioniert der Generator&quot; width=&quot;800&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Funktionen im Überblick:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Automatisch generierter Code höchster Güte&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Erzeugt C, CPP, Java, Swift oder C# Code  &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Automatisierte Robustheitstests auf &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Modellebene&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Keine Laufzeitumgebung notwendig&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Kann mit jedem Prozessor, Compiler und &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt;/&lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; verwendet werden &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Codeerzeugung speziell für eingebettete Echtzeitsysteme&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Gut an verschiedene Systemdesigns anpassbar    (Foreground/Background, &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt;-basiert …)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Design und Code passen immer zusammen&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Modellieren sie nur die Teile die ein Modell benötigen!&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Unterstützte Tools: Cadifra, UModel, Magic Draw,  Modelio, Enterprise Architect und ArgoUML &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Eingebauter Editor zur effizienten Erstellung von Statecharts&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Automatische Generierung von Testfällen&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Interaktive oder Batch-Simulation (Replay).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Echtzeitdarstellung der Maschine im Zielsystem&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Trace Code Erzeugung&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Ausführliches Handbuch&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Wie funktioniert der Generator?&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;wie_funktioniert_der_generator&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;881-2637&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit4&quot; id=&quot;schnelleinstieg&quot;&gt;Schnelleinstieg&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Um einen Eindruck von den Möglichkeiten des Codegenerators zu bekommen, laden sie sich &lt;a href=&quot;https://sinelabore.de/doku.php/wiki/download&quot; class=&quot;wikilink1&quot; title=&quot;wiki:download&quot; data-wiki-id=&quot;wiki:download&quot;&gt; hier&lt;/a&gt; direkt die Testversion herunter. Im Ordner mit den Beispielen finden sie Beispielprojekte für verschiedene &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;-Tools und Zielsprachen. Wählen sie das am besten geeignete Beispiel aus, um einen Eindruck des generierten Codes zu bekommen. Im Handbuch sind alle Funktionen detailliert beschrieben. Einen Schnellstart finden Sie auch auf den “Getting Started”-Seiten auf dieser Website. Das &lt;a href=&quot;https://sinelabore.de/lib/exe/fetch.php/wiki/downloads/sinelaborert.pdf&quot; class=&quot;media mediafile mf_pdf&quot; title=&quot;wiki:downloads:sinelaborert.pdf (6.9 MB)&quot;&gt;Handbuch&lt;/a&gt; enthält auch eine grundlegende Einführung in Zustandsautomaten und wie man diese Testet – falls Sie eine Auffrischung benötigen. Lesen sie weiterhin die Abschnitte, die sich auf Ihr &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;-Tool und das Sprach-Backend beziehen, das Sie verwenden möchten.
&lt;/p&gt;

&lt;p&gt;
Sie haben nun folgende Möglichkeiten, sich weiter mit Codegenerator vertraut zu machen:
&lt;/p&gt;

&lt;p&gt;
1) Führen sie die Beispiele auf Ihrem PC aus. Die Beispiele modellieren einen Mikrowellenherd und können ausgeführt und getestet werden. Spielen sie mit dem Modell und verbessern Sie es. Generieren Sie den Code neu und lernen sie aus den Warn- und Fehlermeldungen.
&lt;/p&gt;

&lt;p&gt;
2) Führen sie die Beispiele auf einem Mikrocontroller aus, z.B. auf einem MSP430-Evaluierungsboard oder unter Arduino. Ein MSP430-Beispiel, das auf der einfachen Foreground/Background-Architektur basiert, ist auf &lt;a href=&quot;https://github.com/sinelabore/examples/tree/master/EnergiaBlink&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/sinelabore/examples/tree/master/EnergiaBlink&quot; rel=&quot;ugc nofollow&quot;&gt;Github&lt;/a&gt; verfügbar.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Schnelleinstieg&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;schnelleinstieg&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;2638-4131&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit5&quot; id=&quot;verwendung_von_state-machines_in_low-power_embedded_systems&quot;&gt;Verwendung von State-Machines in (Low-Power) Embedded Systems&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Es gibt verschiedene Möglichkeiten, wie Zustandsautomaten in ein bestimmtes Systemdesign integriert werden können. Einige Gestaltungsprinzipien sind eher für Entwickler von kleine eingebetteten Systemen geeignet (z.B. den uC in einer Lampensteuerung). Andere sind eher für Entwickler relevant, die nicht so enge Ressourcenbeschränkungen haben.
&lt;/p&gt;

&lt;/div&gt;

&lt;h4 id=&quot;verwendung_von_zustandsautomaten_in_einer_hauptschleife&quot;&gt;Verwendung von Zustandsautomaten in einer Hauptschleife&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;
In diesem Design ruft eine Endlosschleife - typischerweise die Hauptfunktion - einen oder mehrere Zustandsautomaten nacheinander auf. 
&lt;a href=&quot;https://sinelabore.de/lib/exe/detail.php/wiki/mainloop.png?id=de%3Astart&quot; class=&quot;media&quot; title=&quot;wiki:mainloop.png&quot;&gt;&lt;img src=&quot;https://sinelabore.de/lib/exe/fetch.php/wiki/mainloop.png?w=150&amp;amp;tok=1262d4&quot; class=&quot;medialeft&quot; align=&quot;left&quot; loading=&quot;lazy&quot; title=&quot;Verwendung von Zustandsautomaten in einer Hauptschleife&quot; alt=&quot;Verwendung von Zustandsautomaten in einer Hauptschleife&quot; width=&quot;150&quot; /&gt;&lt;/a&gt; Dies ist nach wie vor eine der gängigsten Methoden für den Entwurf kleiner eingebetteter Systeme. Die von den Zustandsautomaten verarbeiteten Ereignisinformationen können von globalen oder lokalen Variablen stammen, die von anderen Funktionen oder Interrupt-Handlern eingespeist werden. Die Vorteile dieses Entwurfs sind, dass kein Laufzeit-System erforderlich ist und nur wenig RAM benötigt wird.
&lt;/p&gt;

&lt;p&gt;
Die Folgen sind:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Der gesamte Rahmen-Code muss vom Entwickler bereitgestellt werden.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Die Hauptschleife muss schnell genug sein, um die geforderte Gesamtreaktionszeit zu erreichen.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Im Falle von Erweiterungen muss das Timing nochmals sorgfältig überprüft werden.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;hiddenGlobal  hiddenActive&quot;&gt;&lt;div class=&quot;hiddenElements&quot;&gt;&lt;/div&gt;&lt;div class=&quot;hiddenHead  hiddenSinceBeginning&quot;&gt;&lt;div class=&quot;hiddenOnHidden&quot;&gt;
&lt;p&gt;
Beispiel:
&lt;/p&gt;
&lt;/div&gt;&lt;div class=&quot;hiddenOnVisible&quot;&gt;
&lt;p&gt;
Beispiel:
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt; &lt;!-- .hiddenHead --&gt;&lt;div class=&quot;hiddenBody&quot;&gt;&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  …
  sm_A&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  sm_B&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  …
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;
&lt;br/&gt;

&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Verwendung von State-Machines in (Low-Power) Embedded Systems&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;verwendung_von_state-machines_in_low-power_embedded_systems&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;4132-5616&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit6&quot; id=&quot;verwendung_von_zustandsautomaten_in_einer_hauptschleife_mit_event-queue&quot;&gt;Verwendung von Zustandsautomaten in einer Hauptschleife mit Event-Queue&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Dieser Entwurf ist ähnlich wie der oben vorgestellte. Allerdings erhält der Zustandsautomat seine Ereignisse aus einer Event-Queue. Die Queue wird durch Timer-Ereignisse, andere Zustandsmaschinen (kooperierende Maschinen) oder Interrupt-Handler gefüllt.
&lt;a href=&quot;https://sinelabore.de/lib/exe/detail.php/wiki/mainloop_ext.png?id=de%3Astart&quot; class=&quot;media&quot; title=&quot;wiki:mainloop_ext.png&quot;&gt;&lt;img src=&quot;https://sinelabore.de/lib/exe/fetch.php/wiki/mainloop_ext.png?w=400&amp;amp;tok=59ea17&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;Verwendung von Zustandsautomaten in einer Hauptschleife mit Ereigniswarteschlange&quot; alt=&quot;Verwendung von Zustandsautomaten in einer Hauptschleife mit Ereigniswarteschlange&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
Vorteile:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Ereignisse gehen nicht verloren (Warteschlange)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Ereignisreihenfolge bleibt erhalten&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entkopplung der Ereignisverarbeitung von der Ereignisgenerierung.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Konsequenzen:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Ein minimaler Laufzeitrahmen ist erforderlich: typ. Timer und Queue&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Die Hauptschleife muss schnell genug sein, um die erforderliche Gesamtreaktionszeit zu erreichen.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Ein minimales Laufzeit-Framework für C ist hier verfügbar: &lt;a href=&quot;https://github.com/sinelabore/examples/tree/master/lib&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/sinelabore/examples/tree/master/lib&quot; rel=&quot;ugc nofollow&quot;&gt;https://github.com/sinelabore/examples/tree/master/lib&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Es bietet Zeitgeber und Warteschlangen. Der Verwendungszweck ist wie folgt:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Jeder Zustandsautomat hat eine eigene Queue&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Schließlich benötigt ein Zustandsautomat einen oder mehrere Timer (einmalig/sigle-shot oder zyklisch).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Ein Zustandsautomat kann so viele Software-Timer wie nötig erstellen. Bei der Erstellung eines Timers muss die Queue des Zustandsautomaten und das Timeout-Ereignis angegeben werden. Für verschiedene Timer ist es sinnvoll, verschiedene Timeout-Ereignisse bereitzustellen.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Damit der Timer funktioniert, muss eine Tick-Zählervariable zyklisch von einem Timer-Interrupt inkrementiert werden (z.B. alle 10 ms). Die Tickfrequenz sollte auf der Grundlage der minimal erforderlichen Auflösung der Timeout-Zeiten gewählt werden. &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Eine tick()-Funktion muss in der Hauptschleife aufgerufen werden, um zu prüfen, ob ein Timer abgelaufen ist. Falls eine Zeitüberschreitung eingetreten ist, wird das entsprechende Ereignis in der Queue des Zustandsautomaten gespeichert.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Die Hauptschleife muss prüfen, ob für einen Zustandsautomaten Ereignisse in seiner Queue gespeichert sind. Wenn es neue Ereignisse gibt, werden sie aus der Queue geholt und der Zustandsautomat wird mit dem Ereignis aufgerufen.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;hiddenGlobal  hiddenActive&quot;&gt;&lt;div class=&quot;hiddenElements&quot;&gt;&lt;/div&gt;&lt;div class=&quot;hiddenHead  hiddenSinceBeginning&quot;&gt;&lt;div class=&quot;hiddenOnHidden&quot;&gt;
&lt;p&gt;
Der Beispielcode mit zwei Zustandsautomaten zeigt das allgemeine Prinzip:
&lt;/p&gt;
&lt;/div&gt;&lt;div class=&quot;hiddenOnVisible&quot;&gt;
&lt;p&gt;
Der Beispielcode mit zwei Zustandsautomaten zeigt das allgemeine Prinzip:
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt; &lt;!-- .hiddenHead --&gt;&lt;div class=&quot;hiddenBody&quot;&gt;&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// tick irq&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; tick&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  pulseCnt&lt;span class=&quot;sy0&quot;&gt;++;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  ….
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// create two queues for two state machines and init the timer subsystem&lt;/span&gt;
  fifoInit&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;fifo2VendingMachine&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; fifo2VendingMachineRawMem&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  fifoInit&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;fifo2ProductStoreMachine&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; fifo2ProductStoreMachineRawMem&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  timerInit&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  …
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; evt&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;//&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// Check if there are new events for the state machine. If yes,&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// call state machine with event.&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;//&lt;/span&gt;
    bool fifoEmpty &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; fifoIsEmpty&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;fifo2VendingMachine&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;fifoEmpty&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      fifoGet&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;fifo2VendingMachine&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;evt&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
      vending_machine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;vendingMachine&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; evt&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    fifoEmpty &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; fifoIsEmpty&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;fifo2ProductStoreMachine&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;fifoEmpty&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      fifoGet&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;fifo2ProductStoreMachine&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;evt&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
      product_store_sm&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;productStoreMachine&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; evt&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
   &lt;span class=&quot;co1&quot;&gt;// any new timeouts?&lt;/span&gt;
   tick&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;
&lt;br/&gt;

Wie in der Abbildung oben dargestellt, können auch andere Zustandsautomaten oder Interrupt-Handler Ereignisse in die Queue eines Zustandsautomaten schieben. Ein Beispiel hierfür ist unten dargestellt.
&lt;br/&gt;

&lt;/p&gt;
&lt;div class=&quot;hiddenGlobal  hiddenActive&quot;&gt;&lt;div class=&quot;hiddenElements&quot;&gt;&lt;/div&gt;&lt;div class=&quot;hiddenHead  hiddenSinceBeginning&quot;&gt;&lt;div class=&quot;hiddenOnHidden&quot;&gt;
&lt;p&gt;
Beispiel:
&lt;/p&gt;
&lt;/div&gt;&lt;div class=&quot;hiddenOnVisible&quot;&gt;
&lt;p&gt;
Beispiel:
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt; &lt;!-- .hiddenHead --&gt;&lt;div class=&quot;hiddenBody&quot;&gt;&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// add event evErr to a state machine queue.&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; ISR_Btn1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  fifoPut&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;fifo2VendingMachine&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; evErr&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;sy0&quot;&gt;&amp;lt;/&lt;/span&gt;hidden&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;nbsp;
\\
&lt;span class=&quot;sy0&quot;&gt;====&lt;/span&gt; Verwendung von Zustandsautomaten in einer Hauptschleife mit Queue&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; optimiert für geringen Stromverbrauch &lt;span class=&quot;sy0&quot;&gt;====&lt;/span&gt;
Bei der Entwicklung von Systemen mit geringstem Stromverbrauch besteht ein wichtiges Ziel darin&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; den Prozessor so lange wie möglich im Energiesparmodus &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;deep sleep&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; zu halten und ihn nur aufzuwecken&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; wenn etwas verarbeitet werden muss. &lt;span class=&quot;me1&quot;&gt;Der&lt;/span&gt; Entwurf ist dem oben beschriebenen sehr ähnlich. &lt;span class=&quot;me1&quot;&gt;Der&lt;/span&gt; Hauptunterschied besteht darin&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; dass die Hauptschleife nicht die ganze Zeit läuft&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; sondern nur dann&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; wenn ein Ereignis eingetreten ist. &lt;span class=&quot;me1&quot;&gt;Der&lt;/span&gt; Timer&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;Service für das kleine Laufzeit&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;Framework wird über den Timer&lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;Interrupt abgewickelt.
\\
&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;hidden Ein Skelett für den MSP430 sieht wie folgt aus&lt;span class=&quot;sy0&quot;&gt;:&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;code c&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// init system&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// check event queues and run the state machine as shown above&lt;/span&gt;
&amp;nbsp;
     …
     __bis_SR_register&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;LPM3_bits &lt;span class=&quot;sy0&quot;&gt;+&lt;/span&gt; GIE&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;// Enter low power mode once&lt;/span&gt;
     __no_operation&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;                    &lt;span class=&quot;co1&quot;&gt;// no more events to process&lt;/span&gt;
   &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// Timer A0 interrupt service routine. If the timer &lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// function tick() returns true there&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// is a timeout and we wakeup the main loop.&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#pragma vector=TIMER0_A0_VECTOR&lt;/span&gt;
__interrupt &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; Timer_A0&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  bool retVal&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  P1OUT &lt;span class=&quot;sy0&quot;&gt;|=&lt;/span&gt; BIT0&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// toggle for debugging&lt;/span&gt;
&amp;nbsp;
  retVal &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; tick&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;retVal&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// at least one timeout timer fired.&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// wake up main loop&lt;/span&gt;
    bic_SR_register_on_exit&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;LPM3_bits&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  P1OUT &lt;span class=&quot;sy0&quot;&gt;&amp;amp;=&lt;/span&gt; ~BIT0&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// toggle for debugging&lt;/span&gt;
  &lt;span class=&quot;co1&quot;&gt;// no more events must be processed&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;
&lt;br/&gt;

&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Verwendung von Zustandsautomaten in einer Hauptschleife mit Event-Queue&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;verwendung_von_zustandsautomaten_in_einer_hauptschleife_mit_event-queue&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;5617-10632&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit7&quot; id=&quot;verwendung_von_zustandsautomaten_in_interrupts&quot;&gt;Verwendung von Zustandsautomaten in Interrupts&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Manchmal ist eine zustandsabhängige Interruptbehandlung erforderlich. Dann ist es sinnvoll, den Zustandsautomaten direkt in den Interrupt-Handler einzubetten, um sich weiteren Overhead zu sparen. Typische Anwendungen sind die Vorverarbeitung von Zeichen, die über eine serielle Schnittstelle empfangen werden, Abfragen von Tasten, oder die zustandsabhängige Filterung eines analogen Signals vor der weiteren Verarbeitung. 
&lt;a href=&quot;https://sinelabore.de/lib/exe/detail.php/wiki/irq.png?id=de%3Astart&quot; class=&quot;media&quot; title=&quot;wiki:irq.png&quot;&gt;&lt;img src=&quot;https://sinelabore.de/lib/exe/fetch.php/wiki/irq.png?w=100&amp;amp;tok=a3b1db&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;Verwendung von Zustandsautomaten in Interrupts&quot; alt=&quot;Verwendung von Zustandsautomaten in Interrupts&quot; width=&quot;100&quot; /&gt;&lt;/a&gt;
Die Verwendung von Zustandsautomaten in einem Interrupt-Handler kann in jedem Systemdesign nützlich sein.
&lt;/p&gt;

&lt;p&gt;
Für die Codegenerierung sind einige Überlegungen notwendig. In der Regel ist es notwendig, Interrupt-Handler mit compilerspezifischen Schlüsselwörtern oder Vektorinformationen usw. auszustatten. Außerdem haben Interrupt-Service-Handler keine Parameter und keinen Rückgabewert. Um diese Anforderungen zu erfüllen, bietet der Sinelabore Codegenerator die Parameter &lt;code&gt;StateMachineFunctionPrefixHeader&lt;/code&gt;, &lt;code&gt;StateMachineFunctionPrefixCFile&lt;/code&gt; und &lt;code&gt;HsmFunctionWithInstanceParameters&lt;/code&gt;. 
&lt;/p&gt;
&lt;div class=&quot;hiddenGlobal  hiddenActive&quot;&gt;&lt;div class=&quot;hiddenElements&quot;&gt;&lt;/div&gt;&lt;div class=&quot;hiddenHead  hiddenSinceBeginning&quot;&gt;&lt;div class=&quot;hiddenOnHidden&quot;&gt;
&lt;p&gt;
Click to display ⇲
&lt;/p&gt;
&lt;/div&gt;&lt;div class=&quot;hiddenOnVisible&quot;&gt;
&lt;p&gt;
Click to hide ⇱
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt; &lt;!-- .hiddenHead --&gt;&lt;div class=&quot;hiddenBody&quot;&gt;
&lt;p&gt;
 Das folgende Beispiel zeigt eine Interrupt-Service-Routine mit den compilerspezifischen Erweiterungen, wie sie von mspgcc verlangt werden.&amp;gt;
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// generated state machine code for an irq&lt;/span&gt;
&amp;nbsp;
interrupt &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;INTERRUPT_VECTOR&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; IntServiceRoutine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
   &lt;span class=&quot;coMULTI&quot;&gt;/* generated statemachine code goes here */&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;
Um diesen Code zu erzeugen, setzen Sie die Schlüssel/Wert-Paare in Ihrer Konfigurationsdatei wie folgt:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;StateMachineFunctionPrefixCFile=interrupt (INTERRUPT_VECTOR)
HsmFunctionWithInstanceParameters=no&lt;/pre&gt;

&lt;p&gt;
Wenn sich das Präfix der Interruptroutine über mehr als eine Zeile erstrecken muss, kann das Zeichen für den Zeilenumbruch “\n” wie unten gezeigt eingefügt werden:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;StateMachineFunctionPrefixCFile=#pragma vector=UART0TX_VECTOR\n__interrupt void&lt;/pre&gt;

&lt;p&gt;
Präfixe für den Header und die C-Datei können separat angegeben werden. 
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Verwendung von Zustandsautomaten in Interrupts&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;verwendung_von_zustandsautomaten_in_interrupts&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:7,&amp;quot;range&amp;quot;:&amp;quot;10633-12671&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit8&quot; id=&quot;verwendung_von_zustandsautomaten_mit_einem_echtzeitbetriebssystem&quot;&gt;Verwendung von Zustandsautomaten mit einem Echtzeitbetriebssystem&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Bei diesem Entwurf läuft jeder Zustandsautomat normalerweise im Kontext einer eigenen Task. Der prinzipielle Aufbau ist in der folgenden Abbildung dargestellt.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.de/lib/exe/detail.php/wiki/task_ab.png?id=de%3Astart&quot; class=&quot;media&quot; title=&quot;wiki:task_ab.png&quot;&gt;&lt;img src=&quot;https://sinelabore.de/lib/exe/fetch.php/wiki/task_ab.png?w=400&amp;amp;tok=c863d2&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;Verwendung von Zustandsautomaten mit einem Echtzeitbetriebssystem&quot; alt=&quot;Verwendung von Zustandsautomaten mit einem Echtzeitbetriebssystem&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Jede Task führt einen Zustandsautomaten (oft als &amp;#039;Active Object bezeichnet) in einer endlosen while-Schleife aus. Die Tasks warten auf neue Ereignisse, die von der Zustandsmaschine verarbeitet werden. Liegt kein Ereignis vor, wird die Task vom &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; in den Idle-Modus versetzt. Sind ein oder mehrere neue Ereignisse vorhanden, weckt das &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; die Task auf.  Der verwendete &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt;-Mechanismus zur Ereignissignalisierung kann unterschiedlich sein. Häufig wird jedoch eine Queue verwendet. In der Queue können Ereignisse aus verschiedenen Quellen gespeichert werden. Z.B. aus einer anderen Task oder aus einer Interrupt-Service-Routine. 
Dieses Design kann mit jedem Echtzeitbetriebssystem realisiert werden. Lediglich die Mechanismen für den Ereignistransport können sich unterscheiden.
&lt;/p&gt;

&lt;p&gt;
Vorteile:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Effiziente und gut getestete Laufzeitumgebung, die vom Echtzeitbetriebssystem bereitgestellt wird&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Priorisierung von Aufgaben und Scheduling möglich&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Zustandsmaschinen-Verarbeitungszeiten sind voneinander entkoppelt.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Die Folgen:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Notwendigkeit eines Echtzeitbetriebssystems (Komplexität, Speicherbedarf, Lizenzkosten …)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Im How-to-Abschnitt wird ein Beispiel für dieses &lt;a href=&quot;https://sinelabore.de/doku.php/wiki/howto/rtos&quot; class=&quot;wikilink1&quot; title=&quot;wiki:howto:rtos&quot; data-wiki-id=&quot;wiki:howto:rtos&quot;&gt;Muster mit FreeRTOS&lt;/a&gt; vorgestellt. Die folgenden Beispiele zeigen Code für das &lt;a href=&quot;https://www.rtems.org&quot; class=&quot;urlextern&quot; title=&quot;https://www.rtems.org&quot; rel=&quot;ugc nofollow&quot;&gt;RTEMS&lt;/a&gt; und &lt;a href=&quot;https://www.segger.com/products/rtos/embos/&quot; class=&quot;urlextern&quot; title=&quot;https://www.segger.com/products/rtos/embos/&quot; rel=&quot;ugc nofollow&quot;&gt;embOS&lt;/a&gt;.
&lt;/p&gt;
&lt;div class=&quot;hiddenGlobal  hiddenActive&quot;&gt;&lt;div class=&quot;hiddenElements&quot;&gt;&lt;/div&gt;&lt;div class=&quot;hiddenHead  hiddenSinceBeginning&quot;&gt;&lt;div class=&quot;hiddenOnHidden&quot;&gt;
&lt;p&gt;
Beispiele für RTEMS
&lt;/p&gt;
&lt;/div&gt;&lt;div class=&quot;hiddenOnVisible&quot;&gt;
&lt;p&gt;
Beispiele für RTEMS
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt; &lt;!-- .hiddenHead --&gt;&lt;div class=&quot;hiddenBody&quot;&gt;&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// rtems specific task body&lt;/span&gt;
rtems_task oven_task&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;rtems_task_argument unused&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  OVEN_INSTANCEDATA_T inst &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OVEN_INSTANCEDATA_INIT&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// returns if one event was processed&lt;/span&gt;
    oven&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;inst&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// generated state machine code&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;extern&lt;/span&gt; rtems_id Queue_id&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; msg&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;NO_MSG&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;size_t&lt;/span&gt; received&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
rtems_status_code status&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;   oven&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
  OVEN_EV_CONSUMED_FLAG_T evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 0U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
  &lt;span class=&quot;coMULTI&quot;&gt;/*execute entry code of default state once to init machine */&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;superEntry &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; 1U&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ovenOff&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;superEntry &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 0U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;coMULTI&quot;&gt;/* action code */&lt;/span&gt;
  &lt;span class=&quot;coMULTI&quot;&gt;/* wait for message */&lt;/span&gt;
  status &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; rtems_message_queue_receive&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;
             Queue_id&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
             &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
             &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;received&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
             RTEMS_DEFAULT_OPTIONS&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
             RTEMS_NO_TIMEOUT
           &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; status &lt;span class=&quot;sy0&quot;&gt;!=&lt;/span&gt; RTEMS_SUCCESSFUL &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    error_handler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;co1&quot;&gt;// generated state handling code&lt;/span&gt;
     …
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;
&lt;br/&gt;

&lt;/p&gt;
&lt;div class=&quot;hiddenGlobal  hiddenActive&quot;&gt;&lt;div class=&quot;hiddenElements&quot;&gt;&lt;/div&gt;&lt;div class=&quot;hiddenHead  hiddenSinceBeginning&quot;&gt;&lt;div class=&quot;hiddenOnHidden&quot;&gt;
&lt;p&gt;
Hier ist ein ähnliches Beispiel für das embOS &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; von Segger.
&lt;/p&gt;
&lt;/div&gt;&lt;div class=&quot;hiddenOnVisible&quot;&gt;
&lt;p&gt;
Hier ist ein ähnliches Beispiel für das embOS &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; von Segger.
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt; &lt;!-- .hiddenHead --&gt;&lt;div class=&quot;hiddenBody&quot;&gt;&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// state machine instance&lt;/span&gt;
SM_INSTANCEDATA_T instanceVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; SM_INSTANCEDATA_INIT&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// Task and queue objects.&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; OS_STACKPTR &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; Stack_TASK_1&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;128&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;   &lt;span class=&quot;coMULTI&quot;&gt;/* Task stacks */&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; OS_TASK         TCB_TASK_1&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;         &lt;span class=&quot;coMULTI&quot;&gt;/* Task-control-blocks */&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; OS_Q            MyQueue&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt;            MyQBuffer&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
OS_TIMER MyTimer&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; txbuf&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;32&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// Routine called from the embOS RTOS to signal &lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// a timeout. A timeout event is sent to the state&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// machine. Multiple timer callback functions might be created if&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// several timers are needed at the same time. Each one then fires an own&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// event. E.g. ev50ms or ev100ms&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; MyTimerCallback&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; msg&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;evtTimeout&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    OS_Q_Put&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;MyQueue&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// Task blocked until a new event is present. The new event is &lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// then sent to the state machine.&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; TaskRunningStateMachine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; pData&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// waiting for new event&lt;/span&gt;
        &lt;span class=&quot;kw4&quot;&gt;volatile&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; Len &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OS_Q_GetPtr&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;MyQueue&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;**&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;pData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kw4&quot;&gt;volatile&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; msg &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;pData&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
        sm&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;SM_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// call generated state machine with event&lt;/span&gt;
&amp;nbsp;
        OS_Q_Purge&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;MyQueue&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;
&lt;br/&gt;

~~DISCUSSION:closed|Hinterlassen sie ihre Kommentare~~
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Verwendung von Zustandsautomaten mit einem Echtzeitbetriebssystem&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;verwendung_von_zustandsautomaten_mit_einem_echtzeitbetriebssystem&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:6,&amp;quot;secid&amp;quot;:8,&amp;quot;range&amp;quot;:&amp;quot;12672-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Thu, 28 Sep 2023 19:56:59 +0000</pubDate>
        </item>
    </channel>
</rss>
