[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] file length problem with atmega128

From: Brian Dean
Subject: Re: [avr-gcc-list] file length problem with atmega128
Date: Sun, 9 Feb 2003 22:29:05 -0500
User-agent: Mutt/1.4i

On Sat, Feb 08, 2003 at 12:10:33AM -0500, Josh Thompson wrote:

> I think this is my problem.  I misread the docs thinking it said the
> atmega128 has 64K of RAM onboard rather than being able to address that
> much but only having 4096 onboard (am I right on this?).

The ATmega128 can be configured to use 64K of external RAM by adding a
RAM chip and a latch to the circuit.  See my M128 board for an example
of this:


But without the external RAM chip, it has only 4K of RAM internally,
which is still not too bad for many applications.  I've seen folks do
some pretty impressive stuff in much less than that.

> I have a fair amount (more that 4096 bytes) of data I need to be able to
> reference.  However, it is const data.  Is there any way I can get it in
> the text region of the chip rather than the data region and then use a
> pointer to reference it (or something like that)?

Yes, though I don't think you will be able to reference it directly,
i.e., you can declare a pointer to FLASH memory and then directly
dereference it with AVR-GCC.  What you need to do is declare your data
something this this:

        #include <avr/pgmspace.h>
        const char const_data[] PROGMEM = { /* initialization data here */ };

You can then dereference and access this data something like this:

        uint8_t byte;

        byte = __lpm_inline(const_data + offset);

If you have string data, there are many functions in the avr-libc
library that have been modified to work with constant data in flash.
For example, printf() has a printf_P() counterpart that directly takes
a flash address.  I.e.:

        const char format[] PROGMAME = "value = %d\n";

        printf_P(format, value);

This keeps you from consuming valuable RAM by having to copy the
initialized data out of flash.  Not quite as nice as including the
constant strings right in with the function call like most of us are
used to, but with low-RAM micros, it can make all the difference
between fitting in the space provided or bursting at the seams.

Brian Dean, address@hidden
BDMICRO - Maker of the M128 ATmega128 Dev Board

reply via email to

[Prev in Thread] Current Thread [Next in Thread]