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.

PROGRAMMING THE AVRAccessing AVR FeaturesThe strength of C is that while it is a high-level language, it allows you to access lowlevelfeatures of <strong>the</strong> target devices. With this capability, <strong>the</strong>re are very few reasons touse assembly except in cases where optimized code is of utmost importance. Even incases where <strong>the</strong> target features are not available in C, usually inline assembly <strong>and</strong>preprocessor macros can be used to access <strong>the</strong>se features transparently.The header files io*v.h (io8515v.h, iom103v.h, <strong>and</strong> so <strong>for</strong>th) define devicespecificAVR IO registers, <strong>and</strong> <strong>the</strong> file iccio<strong>avr</strong>.h can be used in place of <strong>the</strong>io*v.h file as it conditionally includes all <strong>the</strong> io*v.h files based on <strong>the</strong> device macropassed down by <strong>the</strong> IDE. The file AVRdef.h defines many useful macros. Forexample, <strong>the</strong> macro UART_TRANSMIT_ON() can be used to turn on <strong>the</strong> UART (whenavailable on <strong>the</strong> target device).The <strong>compiler</strong> is smart enough to generate <strong>the</strong> single-cycle instructions such as in,out, sbis, <strong>and</strong> sbi when accessing memory-mapped IO. See IO Registers.Since AVR’s native addressing space is 16 bits, most of <strong>the</strong> following sections discussaccessing less than 16 bits of data space or 16 bits of program space. To accessmemory beyond <strong>the</strong> normal range, see Accessing Memory Outside of <strong>the</strong> 64K Range.

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

Saved successfully!

Ooh no, something went wrong!