AVR-mUPI  v1.2
A unified application programming interface for megaAVR devices.
Examples

Introduction

AVR-mUPI comes with a set of application examples that can be found in the doc/examples subdirectory of the <tarball_dir> directory (see How to install AVR-mUPI? for details on this subdirectory). They illustrate how to use the AVR-mUPI interfaces, from simple single-file programs to more elaborated examples involving the definition and use of a code library.

Examples provided

Here is the complete list of examples provided:

Each example is presented in a dedicated page, providing a short description, the list of applicable mcu devices, the necessary hardware platform configuration to execute it, the source files location and their contents.

Building the examples

AVR-mUPI is distributed with all the examples already precompiled and ready to be used, assuming a system clock of 8 MHz. If you wish to modify some of the examples or use another system clock frequency, this section describes the necessary steps to be executed in order to recompile them.

Execute the following actions using a Linux/Bash environment in order to recompile the examples:

  1. Verify that the environment variable mUPI_INSTALL_DIR has already been defined with the path to the AVR-mUPI installation directory <install_dir>. If it is not the case, define it.
  2. Build the example library for the desired devices:
    1. Go to the doc/examples/library subdirectory in the <tarball_dir> directory.
          $ cd <tarball_dir>/doc/examples/library
    2. Build the example library indicating the desired device <mcu> (see the list of AVR device identifiers for the supported devices).
          $ make all MCU=<mcu>
      The library file will be named libexample.a and will be located in the lib/$(MCU) subdirectory of the library folder. All intermediate compilation files will be located in the lib/$(MCU)/obj subdirectory. Repeat this step for all desired MCU values.
  3. Build the example applications for the desired devices:
    1. Go to the doc/examples subdirectory in the <tarball_dir> directory..
          $ cd <tarball_dir>/doc/examples
    2. Build the example applications indicating the desired example number <example> = {1, 2, 3, ...}, device <mcu> and clock frequency <f_cpu>.
          $ make all EXAMPLE=<example> MCU=<mcu> F_CPU=<f_cpu>
      The executable file will be named firmware.hex and will be located in the bin/$(MCU) subdirectory of the example folder. All intermediate compilation files will be located in the bin/$(MCU)/obj subdirectory. Repeat this step for all desired combinations of EXAMPLE and MCU values.

The following lines show how to build example 2 for an ATmega8 clocked at 11.0592 MHz and example 3 for an ATmega8535 clocked at 16 MHz.

$ cd <tarball_dir>/doc/examples/library
$ make all MCU=atmega8
$ make all MCU=atmega8535
$ cd <tarball_dir>/doc/examples
$ make all EXAMPLE=2 MCU=atmega8 F_CPU=11059200
$ make all EXAMPLE=3 MCU=atmega8535 F_CPU=16000000

The files firmware.hex, generated in the previous example, can be found in the doc/examples/example_2/bin/atmega8 and doc/examples/example_3/bin/atmega8535 folders respectively.