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 AVRAccessing Memory Outside of <strong>the</strong> 64K RangeWith 16-bit pointers, <strong>the</strong> AVR can normally access 64K bytes of data memory, 64Kwords of program memory used <strong>for</strong> functions <strong>and</strong> 64K bytes of program memory <strong>for</strong>constant data. The latter requires a clarification: since code must be aligned on a wordboundary, <strong>the</strong> AVR uses word addresses to access code (e.g., <strong>for</strong> a function call). Thisallows a function call to reach <strong>the</strong> full 128K byte / 64K word of <strong>the</strong> Mega128 flashmemory space with a 16-bit word address. However, constant data in <strong>the</strong> flashmemory uses byte addresses, so <strong>the</strong> AVR normally can only access constant data in<strong>the</strong> lower 64K bytes of <strong>the</strong> flash memory using <strong>the</strong> LPM instruction.To get around <strong>the</strong>se limitations, <strong>the</strong> AVR uses <strong>the</strong> RAMPZ IO register to allow greaterthan-64Kaccess to flash memory. The XMega has four such IO registers: RAMPX,RAMPY, RAMPZ, <strong>and</strong> RAMPD, to allow greater-than-64K access to both data <strong>and</strong>flash memory.Currently we do not support automatic changing of <strong>the</strong> RAMP? IO registers topreserve <strong>the</strong> simplicity of using 16-bit pointers. Allowing a mix of 16- <strong>and</strong> 24/32-bitpointers would increase <strong>the</strong> code size significantly, <strong>and</strong> it is more efficient if youmanage <strong>the</strong> paging yourselves using <strong>the</strong> following rules <strong>and</strong> library functions.Non-XMega: Managing <strong>the</strong> RAMPZ RegisterThe non-XMega AVR uses <strong>the</strong> RAMPZ to access constant data above <strong>the</strong> 64K-byteboundary (using <strong>the</strong> elpm instruction) <strong>and</strong> does not define <strong>the</strong> o<strong>the</strong>r RAMP? registers.There<strong>for</strong>e it is easiest if you just change RAMPZ as needed when accessing aconstant item. With careful managment (see Managing Constant Data), you can set<strong>and</strong> reset RAMPZ as needed.The rest of this manual section is <strong>for</strong> XMega only, as <strong>the</strong> topics do not apply to non-XMega parts.XMega: Managing <strong>the</strong> RAMP? RegistersThe XMega uses all four RAMP? registers <strong>for</strong> accessing data memory, <strong>and</strong> RAMPZ isalso used <strong>for</strong> accessing constant data above 64K bytes. We recommend thatgenerally to leave <strong>the</strong> RAMP? registers at <strong>the</strong>ir values initialized in <strong>the</strong> Startup File,which is zero in all cases except <strong>for</strong> RAMPZ. RAMPZ is set to zero unless you arebuilding a bootloader project that is located above <strong>the</strong> 64K-byte boundary, in whichcase, it is set to 1, 2, or 3 depending on <strong>the</strong> location of <strong>the</strong> bootloader. These defaultswork well most of <strong>the</strong> time as most data <strong>and</strong> constant data reside in <strong>the</strong>ir respectivelower 64K-byte areas.127

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

Saved successfully!

Ooh no, something went wrong!