Getting Started With AVRA

 

Getting Started With AVRA

AVRA is an open source assembler for AVR microcontrollers. It can be obtained on linux by entering the following command in a terminal

$ sudo apt-get install avra

Using AVRA

AVRA expects assembly source files to have the extension .asm. To assemble a program, you can simply type avra at the command line followed by the filename:

$ avra filename.asm

This is all you need to do to produce a .hex file to load to you microcontroller.

Command Line Options

The man page for AVRA specifies the command line options as follows:

avra [-f] [O|M|I|G] output file type
     [-o outfile] output file name
     [-l listfile] generate list file
     [-m mapfile] generate map file
     [--define symbol[=value]] [--includepath path] [-listmac]
     [--max_errors number] [--devices] [--version]
     [-h] [--help] general help infile

Output file type

By default, AVRA will generate .hex and .eep.hex in Intel hex format, as well as .cof and .obj files.

Unfortunately, the output file type option is not implemented, even though it is listed in the documentation. Attempting to use either the -f or -o flags will result in an error.


List and Map File

In addition to the default files, a map file and a list file can be generated using the -l and -m flags, respectively.

$ avra -l main.lst -m main.map filename.asm

Define Symbols

Symbols can be defined using the -D flag. Each symbol must be separated from the flag with a space. For example:

$ avra -D DEVICE=m328p -D F_CPU=1600000 filename.asm

Include Paths

If you are including files located in a different directory than the one you are currently in, you can use the -I flag to include an extra search location. This follows the same rules as the -D flag:

$ avra -I /dir1/ -I /dir2/ filename.asm

List Macros

If you would like to see the code generated by your macros in the .lst file, the --listmac option can be specified

$ avra -l filename.lst --listmac filename.asm

Others

Although not documented in the man page, the -W NoRegDef option can be specified which prevents the assembler from generating errors if .def is used to give multiple names to the same register. For example, without this option, the following code would generate an error:

.def	mpr1 = r16
.def	mpr2 = r16

Post a Comment

Post a Comment (0)

Previous Post Next Post