Procyon AVRlib is an open-source collection of C-language function libraries for the Atmel AVR series processors. The goal of AVRlib is to provide the programmer with a code base which performs the most often needed tasks in embedded system programming. Hopefully, this will allow the programmer to focus on high-level operation of their code rather than get bogged down in the details of low-level code.
In short, AVRlib is a bunch of functions that do things commonly needed in embedded systems. Despite the learning curve of getting started, for most projects, using AVRlib will shorten the time spent programming and/or improve the quality or functionality of the final product.
AVRlib functions are available for a wide variety of tasks and purposes. In general, AVRlib tries to address the following kinds of needs:
- Functions which control or interface to AVR processor hardware (like timers, uarts, the a2d converter, etc)
- Functions which interface to or drive devices often used in embedded systems (like LCDs, hard disks, gps units, etc)
- Functions which create higher-level functionality from processor resources (like pulse generation, software uarts, software i2c bus, etc)
For a partial list of currently available function libraries see the AVRlib Main Page.
AVRlib is currently available as individual files, or a complete zip file. Both are available from the AVRlib Main Page.
Downloading the complete avrlib.zip file is highly recommended as documentation and code examples are included in the zip.
This installation for AVRlib assumes you have already installed the AVR-GCC or WinAVR compiler and successfully tested it.
You can install AVRlib anywhere you like, however, it's suggested that you install it in a directory alongside your own AVR code projects. Create or choose a top-level directory to hold both AVRlib and the project folders which you will create to hold the code for each individual project you work on. The directory you choose should not contain spaces in its name or path. Some examples are:
c:\Code\AVR (GOOD) c:\My Code (NOT RECOMMENDED - HAS SPACES IN PATH)From the download step you should have an avrlib.zip file. Unzip this file into the code directory you chose above. Be sure to preserve the internal directory structure of the zip file when you unzip it. Afterward, you can delete avrlib.zip but you may want to keep it for later re-installs or as a backup.
You should now have an avrlib directory where you installed AVRlib. If you have some time, get familiar with what's inside some of the directories. Your directories should look something like this:
c:\Code\AVR\avrlib <-- AVRlib header and code files c:\Code\AVR\avrlib\conf <-- AVRlib template configuration files c:\Code\AVR\avrlib\docs <-- AVRlib documentation c:\Code\AVR\avrlib\examples <-- AVRlib example applications c:\Code\AVR\avrlib\make <-- AVRlib makefile include (avrproj_make file in here)Finally, you need to create an environment variable AVRLIB which points to the directory where you "installed" or unzipped the AVRlib files so the compiler can find them. An example might be:
AVRLIB = c:/code/avr/avrlib <-- change to actual AVRlib install directoryIf you are unsure how to set environment variables on your system, look at the WinAVR/AVR-GCC installation guide elsewhere on this site or consult the web.
AVRlib installation is complete!
There are a few simple steps you can take to verify that AVRlib is properly installed:
(This assumes you have previously installed and tested the AVR-GCC or WinAVR compiler)
- Open a Command Prompt (find it in your Start Menu or select Run, and run cmd.exe)
- Change directories to the location where you installed AVRlib. For example:
cd c:\Code\AVR\AVRlib- Go into the examples directory. cd examples
- Pick an example to try compiling such as rprintf and change to that directory. cd rprintf
- Type make clean at the prompt
- Type make
- If your output looked like this then you just compiled your first AVRlib program:
AVRlib is ready to use!C:\Code\AVR\avrlib\examples\rprintf>make avr-gcc -c -g -Os -Wall -Wstrict-prototypes -Ic:/code/avr/avrlib -Wa,-ahlms=rpri ntftest.lst -mmcu=atmega323 -I. rprintftest.c -o rprintftest.o avr-gcc -c -g -Os -Wall -Wstrict-prototypes -Ic:/code/avr/avrlib -Wa,-ahlms=c:/c ode/avr/avrlib/buffer.lst -mmcu=atmega323 -I. c:/code/avr/avrlib/buffer.c -o c:/ code/avr/avrlib/buffer.o avr-gcc -c -g -Os -Wall -Wstrict-prototypes -Ic:/code/avr/avrlib -Wa,-ahlms=c:/c ode/avr/avrlib/uart.lst -mmcu=atmega323 -I. c:/code/avr/avrlib/uart.c -o c:/code /avr/avrlib/uart.o avr-gcc -c -g -Os -Wall -Wstrict-prototypes -Ic:/code/avr/avrlib -Wa,-ahlms=c:/c ode/avr/avrlib/rprintf.lst -mmcu=atmega323 -I. c:/code/avr/avrlib/rprintf.c -o c :/code/avr/avrlib/rprintf.o avr-gcc -c -g -Os -Wall -Wstrict-prototypes -Ic:/code/avr/avrlib -Wa,-ahlms=c:/c ode/avr/avrlib/timer.lst -mmcu=atmega323 -I. c:/code/avr/avrlib/timer.c -o c:/co de/avr/avrlib/timer.o avr-gcc -c -g -Os -Wall -Wstrict-prototypes -Ic:/code/avr/avrlib -Wa,-ahlms=c:/c ode/avr/avrlib/vt100.lst -mmcu=atmega323 -I. c:/code/avr/avrlib/vt100.c -o c:/co de/avr/avrlib/vt100.o avr-gcc c:/code/avr/avrlib/buffer.o c:/code/avr/avrlib/uart.o c:/code/avr/avrli b/rprintf.o c:/code/avr/avrlib/timer.o c:/code/avr/avrlib/vt100.o rprintftest.o -Wl,-Map=rprintftest.map,--cref -mmcu=atmega323 -o rprintftest.elf avr-objcopy -O ihex -R .eeprom rprintftest.elf rprintftest.hex avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section -lma .eeprom=0 -O ihex rprintftest.elf rprintftest.eep avr-size rprintftest.elf text data bss dec hex filename 9596 0 192 9788 263c rprintftest.elf Errors: none rm c:/code/avr/avrlib/vt100.o c:/code/avr/avrlib/rprintf.o c:/code/avr/avrlib/ua rt.o c:/code/avr/avrlib/timer.o c:/code/avr/avrlib/buffer.o C:\Code\AVR\avrlib\examples\rprintf>