Chuck Hackett wrote:
> I'm attempting to convert the AVR Butterfly demo program to WinAVR
> from Atmel's
> CodeVision version. The program currently contains something like:
>
> __flash char foo_1[] = { 0, 1 };
> __flash char foo_2[] = { 2, 3 };
>
> __flash char __flash *foobar[] = { foo_1, foo_2 };
>
>
> I'm trying to create the gcc equivalent. Studying avr-libc
> documentation: a
> start is:
>
> #include <avr/pgmspace.h>
>
> prog_char foo_1[] = { 0, 1 };
> prog_char foo_2[] = { 2, 3 };
>
> <the puzzle> foobar[] = { foo_1, foo_2 };
>
I cut and pasted some working code and changed the names. It should work
for you.
#include <avr/pgmspace.h>
static const prog_uint8_t foo_1[] = {0, 1 };
static const prog_uint8_t foo_2[] = {2, 3 };
const prog_uint8_t *foobar[] PROGMEM = { foo_1, foo_2 };
PGM_P pArrayPointer;
uint16_t index;
index = 1;
pArrayPointer = (PGM_P)&(foobar[index]);
this_byte = pgm_read_byte(pArrayPointer)/2;
Mike
http://home.austin.rr.com/perks/micros/Message
Re: [AVR-Chat] How To: declare an array of pointers in flash pointing to character arrays in flash
2006-03-07 by Mike Perks
Attachments
- No local attachments were found for this message.