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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ICCV8 <strong>for</strong> AVR – C Compiler <strong>for</strong> Atmel AVRSpecific AVR IssuesThere are a wide array of AVR devices available from Atmel, differing in memory sizes<strong>and</strong> peripherals. This section describes some of <strong>the</strong> AVR <strong>and</strong> device specific issues.AVR FeaturesAVR uses <strong>the</strong> Harvard architecture <strong>and</strong> separate <strong>the</strong> program <strong>and</strong> data memory.See Program Data <strong>and</strong> Constant Memory.Program memory size is specified in bytes (e.g. M32 has 32K bytes of flash) buteach instruction is at least 2 bytes long. There<strong>for</strong>e, program locations encoded in<strong>the</strong> instructions are word addresses. When used as storage <strong>for</strong> literal tables etc.,<strong>the</strong> program memory is byte addressable using <strong>the</strong> lpm/elpm family ofinstructions.ICCV8 <strong>for</strong> AVR programs such as <strong>the</strong> <strong>compiler</strong> proper, <strong>the</strong> assembler <strong>and</strong> linkeruse byte addresses in most usages <strong>and</strong> <strong>the</strong> tools do <strong>the</strong> appropriate word addressconversion as necessary.The registers are not all general purpose. AVR instructions that use immediatesource oper<strong>and</strong>s (e.g. addi, ldi etc.) only operate on <strong>the</strong> upper 16 registersR16 to R31. There are only 3 set of “pointer” registers: R26/R27 or X, R28/R29 orY, <strong>and</strong> R30/R31 or Z. Y <strong>and</strong> Z can use <strong>the</strong> displacement mode with an offset but Xcannot use such mode.The generated code use two stacks (see Program Data <strong>and</strong> Constant Memory),<strong>the</strong> native hardware stack <strong>for</strong> CALL return addresses <strong>and</strong> a software stack using<strong>the</strong> Y pointer. While this makes it more challenging to ensure that both stackshave sufficient space, <strong>the</strong> alternative of using a single stack generatessubstantially more code.Device-Specific InstructionsDevices with 8K or less bytes of program memory do not support <strong>the</strong> jmp <strong>and</strong> callinstructions, <strong>and</strong> only <strong>the</strong> rjmp <strong>and</strong> rcall relative instructions. The initial generationof <strong>the</strong> AVR (sometimes known as “classic” AVRs) do not have <strong>the</strong> newer instructionssuch as <strong>the</strong> multiply instructions <strong>and</strong> <strong>the</strong> extended lpm instructions.139

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

Saved successfully!

Ooh no, something went wrong!