avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Re: Structs in program memory.


From: Christian Ludlam
Subject: Re: [avr-gcc-list] Re: Structs in program memory.
Date: Tue, 11 May 2004 23:45:24 +0100
User-agent: Messenger-Pro/1.00c (MsgServe/1.00a) (RISC-OS/5.05) POPstar/2.05

On 11 May Douglas Dotson wrote:

> I guess my concern is how do I declare a pointer to
> something in program memory. Is there any special
> consideration? I have an array of structs but I am
> accessing the individual elements via a pointer
> rather than a subscript.

<avr/pgmspace.h> declares pointer types prog_void, prog_int etc. A pointer
type can be created with

typedef const prog_void *prog_void_p;

See also the PGM_P and PGM_VOID_P types from the same header. It's not too
important, though, since the pointer type is cast to int by the pgm_read_word
functions.

There are issues with the different addressing modes in that one uses byte
addressing, and the other word addressing (so changing between addressing
modes requires division or multiplication by 2). I assume that GCC gets the
address right for variables declared as PROGMEM, so you should be OK. Best
thing to do is try it and see!

-- 
Christian Ludlam
address@hidden


reply via email to

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