Difference between revisions of "AVR8"

From ERIKA WIKI
Jump to: navigation, search
(BOARD)
(BOARD)
 
(17 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= Introduction =
+
= introduction =
Embedded microcontroller units are spreading in thousands of applications, ranging from single to distributed systems, control applications, multimedia, communication, medical applications and many others. Modern microcontrollers, which are growing in computational power, speed and interfacing capabilities, are more and more feeling the need of tools to make the development of complex scalable applications easier.
+
This manual describes the porting details of the ERIKA Enterprise v3 kernel(s) for the Atmel (now Microchip) families of microcontrollers which support 8/16-bit RISC AVR cores (aka AVR8).
  
This manual describes the porting details of the ERIKA Enterprise v3 kernel(s) for the Atmel (now Microchip) families of microcontrollers which supports 8/16-bit RISC AVR cores (aka AVR8).
+
= AVR8 Features Supported =
  
= ERIKA Enterprise v3 and RT-Druid v3 for AVR8 =
+
The following are the main features of the currently implemented support:
Embedded applications often require tight control on the temporal behavior of each single activity in the system. Real-time complex system systems such as Wireless Sensor Networks are nowadays deployed in academic and industrial environments. The very limited set of resources available in the popular hardware platforms, and the diversified domains of WSN applications, require the adoption of an Operating System responding to the following pre-requisites:
 
* minimum footprint to fit the limited RAM capacity (of the order of few KB);
 
* tunable scheduling algorithm to handle the execution of the tasks;
 
* an application interface acting on the kernel layer and well decoupled from OS service implementation.
 
  
ERIKA Enterprise v3 and RT-Druid v3 represent the answer of Evidence Srl for the development of scalable real-time applications for AVR8.
+
* Development tools
 +
** Support for AVR GCC compiler [http://winavr.sourceforge.net/download.html WinAVR]
 +
* Microcontrollers
 +
** [http://www.microchip.com/design-centers/8-bit/avr-mcus Microchip AVR MCUs] Families
 +
*** [https://www.microchip.com/wwwproducts/en/ATmega328P Microchip ATmega328P] Specific MCU.
 +
* Evaluation Boards
 +
** [https://store.arduino.cc/arduino-uno-rev3 Arduino Uno Board] (ATmega328p)
 +
* External Libraries
 +
** Full support for [https://www.arduino.cc/en/Main/Software Arduino SDK 1.8.5];
  
ERIKA Enterprise v3 provides AVR8 developers the following features:
+
== Tutorials ==
  
* Traditional RTOS features:
+
The following tutorials are available for this architecture:
** Support for four conformance classes to match different application requirements;
+
* [[AVR8_-_Arduino_application_build_on_Windows|AVR8: Arduino application build on Windows]]
** Support for preemptive and non-preemptive multitasking;
 
** Support for fixed priority scheduling;
 
** Support for stack sharing techniques, and one-shot task model to reduce the overall stack usage;
 
** Support for shared resources;
 
** Support for periodic activations using Alarms;
 
** Support for centralized Error Handling;
 
** Support for hook functions before and after each context switch.
 
  
* RT-Druid development environment
+
= Configuration and Programming =
** Development environment based on the Eclipse IDE;
+
 
** Support for the OIL language for the specification of the RTOS configuration;
+
ERIKA Enterprise is configured through [[Tutorial: RT-Druid and OIL basics | RT-Druid and an OIL file]] and some other properties.
** Graphical configuration plugin to easily generate the OIL configuration file and to easily configure the RTOS parameters;
+
 
** Full integration with the Cygwin development environment to provide a Unix-style scripting environment;
+
The following sections describe the properties and OIL fields customized for Atmel (now Microchip) AVR8 architecture.
** Apache ANT scripting support for code generation.
+
 
 +
== Compiler Path ==
  
* AVR8 integration features
+
It is possible to choose the path of the compiler in three different ways:
** Support for AVR8 GCC compiler;
 
** Support for the following families Atmel (now Microchip) MCUs:
 
*** [http://www.atmel.com/products/microcontrollers/avr/megaAVR.aspx megaAVR]
 
** Support for following boards
 
*** [https://store.arduino.cc/arduino-uno-rev3 Arduino Uno Board] (ATmega328p)
 
** List of functions:
 
*** Full support for [https://www.arduino.cc/en/Main/Software Arduino SDK 1.8.5];
 
  
= Integration with other tools for AVR8 =
+
* ''Compiler specific environment variables'': '''AVR_TOOLS'''
ERIKA Enterprise and RT-Druid aims to the best integration with the existing tools for development available from the AVR microcontrollers.
+
** E.g.: AVR_TOOLS=C:\WinAVR
RT-Druid will be used to quickly configure the application, setting temporal parameters of real-time tasks, memory requirements, stack allocation and many other parameters. Moreover, RT-Druid generates the application template, and leaves the developer the task to implement the logic of each single task.
+
* ''RT-Druid Eclipse IDE Property''.
While programming the application, the developer can exploit the power and flexibility offered by the primitives of the ERIKA Enterprise real-time kernel.
+
* ''RT-Druid Configuration File Entry'': '''preference_avr8__path_for_gcc_compiler'''
ERIKA Enterprise also supports the compiling environments provided by Atmel (now Microchip), providing also direct support for the programming and JTAG solutions of Atmel  (now Microchip).
+
** E.g.: preference_avr8__path_for_gcc_compiler=C:\WinAVR
  
= Content of this document =
+
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
The purpose of this document is to describe all the information needed to create, develop and modify an Erika Enterprise application for the AVR family of microcontrollers.
 
  
In particular, the document describes:
+
== Arduino SDK Path ==
* The design flow which should be used to generate an Erika Enterprise application;
 
* The configuration of the development environment;
 
* The options which are available to configure the system.
 
  
As a final note, all the settings which are explained in this document apply both to Erika Enterprise if not otherwise stated.
+
It is possible to choose the path in three different ways:
  
<pre>
+
* ''Specific environment variables'': '''ARDUINO_SDK_FILES'''
Note: If you are looking for a step-by-step / quick guide tutorial on how to use Erika Enterprise and RT-Druid with AVR,
+
** E.g.: ARDUINO_SDK_FILES=C:\Program Files (x86)\Arduino
please read the “Erika Enterprise Tutorial for the AVR microcontrollers”, available for download on the Evidence Web site.
+
* ''RT-Druid Eclipse IDE Property''.
</pre>
+
* ''RT-Druid Configuration File Entry'': '''preference_avr8__path_for_arduino_sdk'''
 +
** E.g.: preference_avr8__path_for_arduino_sdk=C:\Program Files (x86)\Arduino
  
 +
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
  
= Configuration and Programming =
+
== Arduino Serial Port ==
 +
 
 +
It is possible to choose the Serial Port for Arduino in two different ways:
 +
 
 +
* ''RT-Druid Eclipse IDE Property''.
 +
* ''RT-Druid Configuration File Entry'': '''preference_avr8__serial_port_for_arduino'''
 +
** E.g.: preference_avr8__serial_port_for_arduino=COM5
  
ERIKA Enterprise is configured through [[Tutorial: RT-Druid and OIL basics | RT-Druid and an OIL file]]. Here are listed, after the information to set compiler path, the OIL fields customized for Atmel (now Microchip) AVR8 architecture.
+
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
  
== Compiler Path ==
+
== Arduino Serial Baudrate ==
  
It is possible to choose the path of the compiler in three different ways:
+
It is possible to choose the Serial Baudrate for Arduino in two different ways:
  
* ''PATH enviornment variable'': You can put compilers bin directories in PATH and the environmet can use them from here.  
+
* ''RT-Druid Eclipse IDE Property''.
* ''Compiler specific environment variables'':
+
* ''RT-Druid Configuration File Entry'': '''preference_avr8__serial_baudrate_for_arduino'''
** '''AVR8 GCC toolchain''': You can specify the compiler path for AVR8 GCC with the '''AVR_TOOLS'''.
+
** E.g.: preference_avr8__serial_baudrate_for_arduino=115200
* ''RT-Druid configuration file'' see [[RT-Druid configuration#Compiler paths]]:
 
** '''preference_avr8__path_for_gcc_compiler''' set GCC compiler path for AVR8
 
  
 
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
 
Here is an [[Common oil.pref example|example of RT-Druid configuration file]].
Line 81: Line 74:
  
 
'''CPU_DATA''' must be set to  '''AVR8'''.
 
'''CPU_DATA''' must be set to  '''AVR8'''.
 +
 +
The available <tt>COMPILER</tt> is <tt>GCC</tt>.
  
 
Example of a CPU_DATA section:
 
Example of a CPU_DATA section:
  
 
     CPU_DATA = AVR8 {
 
     CPU_DATA = AVR8 {
 +
      COMPILER = GCC;
 
       ...
 
       ...
 
     };
 
     };
Line 90: Line 86:
 
== MCU ==
 
== MCU ==
  
'''MCU_DATA''' supports for now the '''MEGA''' value only.
+
'''MCU_DATA''' object supports for now the '''MEGA''' value only.
 +
 
 +
Example of a MCU_DATA section:
 +
 
 +
    MCU_DATA = MEGA {
 +
      ...
 +
    };
 +
 
 +
=== MODEL ===
  
 
'''MODEL''' attribute of '''MCU_DATA''' supports for now the '''MEGA_328p''' value only.
 
'''MODEL''' attribute of '''MCU_DATA''' supports for now the '''MEGA_328p''' value only.
 +
Default value is '''MEGA_328p'''.
 +
 +
Example of MODEL attribute of a MCU_DATA section:
  
 
   MCU_DATA = MEGA {
 
   MCU_DATA = MEGA {
Line 100: Line 107:
 
== BOARD ==
 
== BOARD ==
  
For now there is no NATIVE board support for AVR8 Architecture. The ONLY supported board is [[Arduino]] by [https://www.arduino.cc/en/Main/Software Arduino SDK 1.8.5].
+
For now, there is no NATIVE board support for AVR8 Architecture. The ONLY supported board is [[Arduino]] by [https://www.arduino.cc/en/Main/Software Arduino SDK 1.8.5].
 +
 
 +
'''NOTE:''' To support a custom board, it's mandatory to install the Arduino SDK software package and correctly set the related RT-Druid properties.
 +
 
 +
Moreover it's mandatory to set the ''F_CPU'' macro according to the ''CLOCK FREQUENCY'' set by custom AVR8 MCU Driver (e.g. 16MHz in the following example).
 +
 
 +
  ...
 +
  OS myOs {
 +
    ...
 +
    CFLAGS = "-DF_CPU=16000000L";
 +
    ...
 +
  };
 +
  ...
 +
 
 +
== LIB ==
 +
 
 +
'''LIB''' object supports for now the '''ARDUINO''' value only.
 +
 
 +
Example of a LIB section:
 +
 
 +
    LIB = ARDUINO {
 +
      ...
 +
    };
 +
 
 +
=== ARDUINO ===
 +
 
 +
The following sections describe the OIL fields of the '''LIB''' object customized for the official '''ARDUINO''' SDK supports.
 +
 
 +
==== SDK_BOARD ====
 +
 
 +
'''SDK_BOARD''' attribute of '''ARDUINO''' supports for now the '''UNO''' value only.
 +
Default value is '''UNO'''.
 +
 
 +
Example of SDK_BOARD attribute of ARDUINO:
 +
 
 +
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      ...
 +
    };
 +
 
 +
==== VARIANT ====
 +
 
 +
'''VARIANT''' attribute of '''ARDUINO''' supports for now the '''CC''' value only.
 +
Default value is '''CC'''.
 +
 
 +
Example of VARIANT attribute of ARDUINO:
 +
 
 +
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      VARIANT = CC;
 +
      ...
 +
    };
 +
 
 +
===== VERSION =====
 +
 
 +
'''VERSION''' attribute of '''ARDUINO CC VARIANT''' supports for now the '''"1.8.5"''' value only.
 +
Default value is '''"1.8.5"'''.
 +
 
 +
Example of VERSION attribute of ARDUINO CC VARIANT:
 +
 
 +
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      VARIANT = CC {
 +
        VERSION = "1.8.5";
 +
      };
 +
      ...
 +
    };
 +
 
 +
==== STAND_ALONE ====
 +
 
 +
'''STAND_ALONE''' boolean attribute of '''ARDUINO''' configures the build system to generate or not '''libarduinosdk.a''' stand-alone binary library. The default value is set to '''TRUE'''.
 +
Default value is '''TRUE'''.
 +
 
 +
Example of STAND_ALONE attribute of ARDUINO:
 +
 
 +
    LIB = ARDUINO {
 +
      SDK_BOARD = UNO;
 +
      VARIANT = CC {
 +
        VERSION = "1.8.5";
 +
      };
 +
      STAND_ALONE = TRUE;
 +
    };
  
 
== Interrupt Handling ==
 
== Interrupt Handling ==
Line 108: Line 196:
 
=== MEGA Family ===
 
=== MEGA Family ===
  
The '''MEGA''' family of '''AVR8''' microcontrollers has an interrupt vector table which is stored in the flash memory. The lowest addresses of the interrupt vector table is allocated to the RESET and to the interrupt vectors. Interrupt handlers placed at lower addresses have higher hardware priorities than interrupt handlers placed at higher addresses so the '''PRIORITY''' attribute of the '''ISR''' object in the OIL is USELESS. The complete list of '''SOURCE''' entries is shown below.
+
The '''MEGA''' family of '''AVR8''' microcontrollers has an interrupt vector table which is stored in the flash memory. The lowest addresses of the interrupt vector table are allocated to the RESET and to the interrupt vectors. Interrupt handlers placed at lower addresses have higher hardware priorities than interrupt handlers placed at higher addresses so the '''PRIORITY''' attribute of the '''ISR''' object in the OIL is USELESS. The complete list of '''SOURCE''' entries is shown below.
  
 
* <code>RESET</code>: External Pin, Power-on Reset, Brown-out Reset and Watchdog System Reset
 
* <code>RESET</code>: External Pin, Power-on Reset, Brown-out Reset and Watchdog System Reset
Line 146: Line 234:
 
This Section contains information about the OSEK/VDX Extensions (or optional features) that have been implemented for the AVR8 support.
 
This Section contains information about the OSEK/VDX Extensions (or optional features) that have been implemented for the AVR8 support.
  
=== System Timer ===
+
== System Timer ==
  
 
System Timer is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the System Timer configuration of ERIKA Enterprise v3 is shown below.
 
System Timer is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the System Timer configuration of ERIKA Enterprise v3 is shown below.
Line 153: Line 241:
  
 
For the '''MEGA''' family of '''AVR8''' microcontrollers the System Timer is linked to TIMER1 so the '''DEVICE''' attribute MUST be se to '''TIMER1_COMPA''' as shown below.
 
For the '''MEGA''' family of '''AVR8''' microcontrollers the System Timer is linked to TIMER1 so the '''DEVICE''' attribute MUST be se to '''TIMER1_COMPA''' as shown below.
 
  
 
   COUNTER SystemTimer {
 
   COUNTER SystemTimer {

Latest revision as of 10:27, 26 September 2018

introduction

This manual describes the porting details of the ERIKA Enterprise v3 kernel(s) for the Atmel (now Microchip) families of microcontrollers which support 8/16-bit RISC AVR cores (aka AVR8).

AVR8 Features Supported

The following are the main features of the currently implemented support:

Tutorials

The following tutorials are available for this architecture:

Configuration and Programming

ERIKA Enterprise is configured through RT-Druid and an OIL file and some other properties.

The following sections describe the properties and OIL fields customized for Atmel (now Microchip) AVR8 architecture.

Compiler Path

It is possible to choose the path of the compiler in three different ways:

  • Compiler specific environment variables: AVR_TOOLS
    • E.g.: AVR_TOOLS=C:\WinAVR
  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__path_for_gcc_compiler
    • E.g.: preference_avr8__path_for_gcc_compiler=C:\WinAVR

Here is an example of RT-Druid configuration file.

Arduino SDK Path

It is possible to choose the path in three different ways:

  • Specific environment variables: ARDUINO_SDK_FILES
    • E.g.: ARDUINO_SDK_FILES=C:\Program Files (x86)\Arduino
  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__path_for_arduino_sdk
    • E.g.: preference_avr8__path_for_arduino_sdk=C:\Program Files (x86)\Arduino

Here is an example of RT-Druid configuration file.

Arduino Serial Port

It is possible to choose the Serial Port for Arduino in two different ways:

  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__serial_port_for_arduino
    • E.g.: preference_avr8__serial_port_for_arduino=COM5

Here is an example of RT-Druid configuration file.

Arduino Serial Baudrate

It is possible to choose the Serial Baudrate for Arduino in two different ways:

  • RT-Druid Eclipse IDE Property.
  • RT-Druid Configuration File Entry: preference_avr8__serial_baudrate_for_arduino
    • E.g.: preference_avr8__serial_baudrate_for_arduino=115200

Here is an example of RT-Druid configuration file.

CPU

CPU_DATA must be set to AVR8.

The available COMPILER is GCC.

Example of a CPU_DATA section:

   CPU_DATA = AVR8 {
     COMPILER = GCC;
     ...
   };

MCU

MCU_DATA object supports for now the MEGA value only.

Example of a MCU_DATA section:

   MCU_DATA = MEGA {
     ...
   };

MODEL

MODEL attribute of MCU_DATA supports for now the MEGA_328p value only. Default value is MEGA_328p.

Example of MODEL attribute of a MCU_DATA section:

 MCU_DATA = MEGA {
   MODEL = MEGA_328p;
 };

BOARD

For now, there is no NATIVE board support for AVR8 Architecture. The ONLY supported board is Arduino by Arduino SDK 1.8.5.

NOTE: To support a custom board, it's mandatory to install the Arduino SDK software package and correctly set the related RT-Druid properties.

Moreover it's mandatory to set the F_CPU macro according to the CLOCK FREQUENCY set by custom AVR8 MCU Driver (e.g. 16MHz in the following example).

 ...
 OS myOs {
   ...
   CFLAGS = "-DF_CPU=16000000L";
   ...
 };
 ...

LIB

LIB object supports for now the ARDUINO value only.

Example of a LIB section:

   LIB = ARDUINO {
     ...
   };

ARDUINO

The following sections describe the OIL fields of the LIB object customized for the official ARDUINO SDK supports.

SDK_BOARD

SDK_BOARD attribute of ARDUINO supports for now the UNO value only. Default value is UNO.

Example of SDK_BOARD attribute of ARDUINO:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     ...
   };

VARIANT

VARIANT attribute of ARDUINO supports for now the CC value only. Default value is CC.

Example of VARIANT attribute of ARDUINO:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     VARIANT = CC;
     ...
   };
VERSION

VERSION attribute of ARDUINO CC VARIANT supports for now the "1.8.5" value only. Default value is "1.8.5".

Example of VERSION attribute of ARDUINO CC VARIANT:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     VARIANT = CC {
       VERSION = "1.8.5";
     };
     ...
   };

STAND_ALONE

STAND_ALONE boolean attribute of ARDUINO configures the build system to generate or not libarduinosdk.a stand-alone binary library. The default value is set to TRUE. Default value is TRUE.

Example of STAND_ALONE attribute of ARDUINO:

   LIB = ARDUINO {
     SDK_BOARD = UNO;
     VARIANT = CC {
       VERSION = "1.8.5";
     };
     STAND_ALONE = TRUE;
   };

Interrupt Handling

Interrupt Handling is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the ISRs configuration of ERIKA Enterprise v3 is shown below.

MEGA Family

The MEGA family of AVR8 microcontrollers has an interrupt vector table which is stored in the flash memory. The lowest addresses of the interrupt vector table are allocated to the RESET and to the interrupt vectors. Interrupt handlers placed at lower addresses have higher hardware priorities than interrupt handlers placed at higher addresses so the PRIORITY attribute of the ISR object in the OIL is USELESS. The complete list of SOURCE entries is shown below.

  • RESET: External Pin, Power-on Reset, Brown-out Reset and Watchdog System Reset
  • INT0: External Interrupt Request 0
  • INT1: External Interrupt Request 1
  • PCINT0: Pin Change Interrupt Request 0
  • PCINT1: Pin Change Interrupt Request 1
  • PCINT2: Pin Change Interrupt Request 2
  • WDT: Watchdog Time-out Interrupt
  • TIMER2_COMPA: Timer/Counter2 Compare Match A
  • TIMER2_COMPB: Timer/Counter2 Compare Match B
  • TIMER2_OVF: Timer/Counter2 Overflow
  • TIMER1_CAPT: Timer/Counter1 Capture Event
  • TIMER1_COMPA: Timer/Counter1 Compare Match A
  • TIMER1_COMPB: Timer/Coutner1 Compare Match B
  • TIMER1_OVF: Timer/Counter1 Overflow
  • TIMER0_COMPA: Timer/Counter0 Compare Match A
  • TIMER0_COMPB: Timer/Counter0 Compare Match B
  • TIMER0_OVF: Timer/Counter0 Overflow
  • SPI_STC: SPI Serial Transfer Complete
  • USART_RX: USART Rx Complete
  • USART_UDRE: USART, Data Register Empty
  • USART_TX: USART, Tx Complete
  • ADC_ADC: Conversion Complete
  • EE_READY: EEPROM Ready
  • ANALOG_COMP: Analog Comparator
  • TWI: 2-wire Serial Interface
  • SPM_READY: Store Program Memory Ready

EEOPT

The following EEOPTs are specific of AVR8 Architecture:

  • __AVR8_GCC_C99__: Enables C99 compiler option.

OSEK/VDX Extensions

This Section contains information about the OSEK/VDX Extensions (or optional features) that have been implemented for the AVR8 support.

System Timer

System Timer is microcontroller dependent so for each supported Atmel (now Microchip) AVR8 microcontroller family, the System Timer configuration of ERIKA Enterprise v3 is shown below.

MEGA Family

For the MEGA family of AVR8 microcontrollers the System Timer is linked to TIMER1 so the DEVICE attribute MUST be se to TIMER1_COMPA as shown below.

 COUNTER SystemTimer {
   MINCYCLE = 1;
   MAXALLOWEDVALUE = 65535;
   TICKSPERBASE = 1;
   TYPE = HARDWARE {
     DEVICE = "TIMER1_COMPA";
     SYSTEM_TIMER = TRUE;
   };
   SECONDSPERTICK = 0.001;
 };

Additional Notes

T.B.D.