[ReaGeniX home]

Learning ReaGeniX by Example

Note: The details, as file paths, menu structures, form layouts, etc., may vary depending on the tool versions. Consult documentation of the specific tool version for the details.

This is a quick start tutorial to learn the concepts you need to develop software with the ReaGeniX code generation tool. We use an example to explain the software development phases from application design till software is running on a target environment:

This tutorial aims to explain briefly all aspects that are needed to enter ReaGeniX based software development, therefore we also describe how ReaGeniX generated software is bound into a target environment:

ReaGeniX requirements to a software development process and target environment resources are very lightweight. You can use this document to integrate ReaGeniX within your existing software environment, or you can also use this document as it is to jump start your software development.

Contents

ReaGeniX example Blink

Create a new Visio design for Blink

Rename Blink drawing

Define Blink interfaces

Implement Blink functionality

Generate Blink source and header files with ReaGeniX

Execute Blink on Windows

Execute Blink on ATmega128

Advanced procedure

Install the AVR tools

Build Blink using AVR tools

Configure PC and STK500 board

Flash Blink to ATmega128 micro-controller

Conclusion

ReaGeniX example Blink

Blink is used as an example application throughout this tutorial. Blink is a simple application that has two states: blink_led_is_ON and blink_led_is_OFF. Blink control transfers between these two states at 0,5s interval, thus a LED is blinking at 1 Hz frequency. Figure 1 shows Blink functionality.


Figure 1. Blink state diagram.

We use Blink instead of traditional Hello example. The reason is that Hello requires keyboard input and screen output (or serial drivers) that are not readily available in all target environments. Blink uses simply a LED (or a GUI widget) to indicate that software is running so it is much more convenient to implement in constrained devices. In addition, console software (like Hello) would be rather akward to demonstrate proper timing functionality, which is most essential to many embedded programs.

Create a new Visio design for Blink.

Rgx3w ReaGeniX template is a good starting point to create a new application. The template opens the ReaGeniX stencil and creates an empty ReaGeniX component that can be used as basis for a new application.

ReaGeniX development method is based on components. A simple application may be implemented in one component, and when complexity increases the application may be composed of many hierarchical components. Each ReaGeniX component has:

An application has one top-level component so it is a typical custom to name a top-level component after an application. Blink is a very simple application so we implement it in one component and within this tutorial we use the name Blink to refer to the Blink application, the Blink component, and the Blink example.

Rename Blink drawing

The page name is used when the source and header files are generated. If you do not rename page-1 as blink, the generated files will be named as page-1.h and page-1.c instead of blink.c and blink.h.

Define Blink interfaces

The name led_pin is used here to emphasize that Blink drives a pin that is connected to a LED in a target hardware. GUI developers probably prefer some GUI widget terminology, but before changing the name notice that the output port is refered from component's implementation later using the name led_pin.

Blink interfaces are now ready. As shown above, Blink has the flag (boolean) output led_pin, and no inputs at all. Indeed, Blink is a simple application.

The concept of interfaces is fundamental to ReaGeniX architecture. A component communicates through its interfaces with other software. We connect Blink's led_pin output later to a hardware pin (or a GUI widget). 

Implement Blink functionality

=>
l(led_pin);
ov(blinking_timer) = Second/2;

when(timeout(blinking_timer))
=>
r(led_pin);
ov(blinking_timer) = Second/2;

when(timeout(blinking_timer))
=>
l(led_pin);
ov(blinking_timer) = Second/2;

The both interfaces and implementation of Blink are now ready, as shown below.

An application can be in one component and one state at a moment. The application reacts only to those transitions that leave from the current state. After a condition of any transition is fulfilled the application executes the actions that are defined in the transition, and then transfers from the current state to the next one along the transition.

Blink has just one component so it is always in the state blink_led_is_ON or blink_led_is_OFF. Because all transitions into these two states start a blinking_timer, and because both states have a leaving condition for blinking_timer, the application transfers between the two states at 500ms interval. Furthermore, the actions defined in transitions after the blinking_timer timeout condition make led_pin output raise and lower causing a blinking LED at 1 Hz frequency.

Generate Blink source and header files with ReaGeniX

ReaGeniX generates source files from the Visio design. The files blink.c and blink.h can be found from the same folder where you saved Blink application (that is ReaGeniX/Example/Blink).

  • Execute Blink on Windows
  • This tutorial explains how Blink is executed on Windows. The tools used are:

        Build Blink using Visual C++ 6

        Conclusion

    Congratulations! Blink that you created using Visio, generated using ReaGeniX and compiled using Visual C++ 6 is now running on Windows. You can see:

    See ReaGeniX User’s Manual, Interfacing Manual and other tutorials for more about Windows programming and ReaGeniX integration.

       

       Execute Blink on ATmega128

      This tutorial explains how Blink can be executed on an ATmega128 microcontroller. The tools used are:

      Advanced procedure

      If you are already familiar with the compiler tool chain and target environment or you use different tools, do the following:

      If you have not yet installed the tools or configured the target environment, then you need to continue reading.

      Install the AVR tools

      Build Blink using AVR tools


      Configure PC and STK500 board

      Flash Blink to ATmega128 micro-controller

      Conclusion

      Congratulations! Blink is now running on an ATmega128 microcontroller. You can see LEDs blinking:

      • LED0 blinkds at 1 Hz frequency; implemented in blink.c of Blink application.
      • LED1 shows the ATmega128 workload; implemented in main.c of ReaGeniX main loop.

      ReaGeniX® is a trademark of OBP Research Oy.

      Copyright © 1995-2010 OBP Research Oy.