11.07.2015 Views

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

Imagecraft c compiler and development environment for the atmel avr

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRio???v.h Header FilesThe naming scheme of <strong>the</strong> IO registers, bit definitions, <strong>and</strong> <strong>the</strong> interrupt vectors arest<strong>and</strong>ardized on <strong>the</strong>se header files. The io????v.h header files define symbolicnames <strong>for</strong> AVR’s IO registers <strong>and</strong> bits, interrupt vector numbers, <strong>and</strong> lock/fuse bits ifsupported (Mega AVRs only). IO register <strong>and</strong> bit names are defined as in data sheetswith few exceptions <strong>and</strong> extensions (note that occasionally <strong>the</strong> summary pages havemisspellings!). The file iccio<strong>avr</strong>.h conditionally includes all <strong>the</strong>se io????v.h filesdepending on which device macro is defined, which is passed down by <strong>the</strong> IDE.There<strong>for</strong>e, you may write#include <strong>and</strong> it will work <strong>for</strong> any supported devices.Some notes about <strong>the</strong> header files: SREG bits are not defined (not needed in C).UART status flag OR is defined as OVR (old ICCAVR style) <strong>and</strong> DOR (new megaAVR style).16-bit registers on subsequent addresses (e.g. Timer/Counter1 registers or StackPointer) are defined int as well as char. To use <strong>the</strong> int definition, simply write<strong>the</strong> register name without <strong>the</strong> L/H suffix, e.g., ICR1. If 16-bit access uses mcu'sTEMP register, ICCAVR creates <strong>the</strong> correct code sequence by itself. Interrupt vector numbers are defined as in data sheet tables “Reset <strong>and</strong> InterruptVectors” (source column) with iv_ as a prefix. Use with #pragmainterrupt_h<strong>and</strong>ler, <strong>for</strong> example:#pragma interrupt_h<strong>and</strong>ler timer0_h<strong>and</strong>ler: iv_TIMER0_OVFFor more in<strong>for</strong>mation, see Interrupt H<strong>and</strong>ling. With <strong>the</strong>se definitions, you may refer toIO registers by names:... = PINA; // read from PINAThere are some double definitions added to overcome AVR's most irritating syntaxdifferences: UART_RX <strong>and</strong> UART_RXC (*) UART_DRE <strong>and</strong> UART_UDRE (*) UART_TX <strong>and</strong> UART_TXC (*) EE_RDY <strong>and</strong> EE_READY ANA_COMP <strong>and</strong> ANALOG_COMP112

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!