| AVR Z-LINKŪ |

# Compiler information.

## Overview

- Setup and Compile with IAR
- Setup and Compile with GCC
- Compiler References

The first step to compile the evaluation application with either the IAR or GCC compiler is to make a new project folder and copy the lib, inc and src/avr folders here. Pre configured project files can be found in the iar or gcc folders.

Note:
  In the reminder of this chapter it is assumed that you have AVR Studio and a valid copy of one of the two compilers installed.

## Setup and Compile with IAR

- Open IAR Embedded Workbench. Select New Workspace.
- Then select the Project menu and Create New Project...
  - The Create New Project will be visible. Select AVR as Tool chain.
  - Choose the Empty project template and press OK.
  - Save the Workspace and Project file to your project directory (Same level as inc and lib).
- Select the Project menu again and Options. The Options window will be visible:
  - General Options:
    - Target tab: Processor configurations: Choose Processor configuration -cpu=m1281.
    - Library Configuration tab: Library to Normal DLIB.
      - System tab: Set CSTACK to 1024 and RSTACK to 32, Check Enable bit definitions in I/O-Include files.
  - C/C++ Compiler:
    - Preprocessor tab:
      - Additional include directories: write "$PROJ_DIR$\inc".
      - Defined symbols: Add "RF_BAND=BAND_2400" and "RF_CHANNEL=11".
    - Diagnostics tab: In the Suppress these warnings field add "Pa050".
  - Linker:
    - Output tab:
      - Format: select other and Output format to "ubrof 8 (forced)". Do not alter anything else.
    - Extra Options tab:
      - Check Use command line options and add "-C $PROJ_DIR$\lib\avr\iar\libl2_rdk230_rel.r90".
- Add the files in the src/avr to the project.
- Press F7 and verify that the code compiles without errors.

## Setup and Compile with GCC

- Open AVRStudio, the Welcome to AVR Studio 4 screen will appear. Select New Project.
  - In the Create new Project screen:
    - Select AVR GCC as project type and type in a project name.
      - Browse into your project folder where you already have two folders (inc and lib).
      - Press next.
  - In the Select debug platform and device screen:
    - Select your Debug platform and ATmega1281 from the Device list.
    - Press Finish.
- In AVR Studio:
  - Select Project and Project Options from the drop down list.
  - General Tab:
    - Verify that Device is ATmega1281.
    - Set Frequency to 8000000 Hz.
    - Set Optimization to -Os.
    - Check Unsigned Chars, Unsigned Bitfields, PackStructure Members and Short Enums.
  - Include Directories Tab:
    - Add "inc\" to the Library Search Path.
    - Verify that the Available Link Objects list have a member called "libl2_rdk230_rel.a".
    - Select "libc.a" and "libl2_rdk230_rel.a" using the Add Library button.
  - Libraries Tab:
    - Add "lib\avr\gcc" to the File Search Path. -Press OK.
- Select Project and Project Options again (Must be done to update the Custom Options List).
  - Custom Options Tab:
    - Add the following three options to your Custom Compilation Options window:
      - "-DRF_BAND=BAND_2400" press add.
      - "-DRF_CHANNEL=11" press add.
      - "-std=c99" press add.
  - Press OK.
- Add the files in the src/avr to the project.
- Press F7 and verify that the code compiles.

## Compiler References

- http://www.iar.com
- http://winavr.sourceforge.net

@DOC_TITLE@