When you refer to an array there is an implicit 'take the address of' (ie: &) operator. So to assign the address of the first element of the array to the pointer you would say: SongArray = Song1Array; rather than SongArray = &Song1Array; alternatively you could say: SongArray = &Song1Array[0] to get the same result. Bob Ammerman RAm Systems ----- Original Message ----- From: "Harold Hallikainen" To: "Microcontroller discussion list - Public." Sent: Friday, May 06, 2005 7:21 PM Subject: Re: [PIC] Pointer to array in ROM? > Excellent idea! The compiler says: > > C:\ProductDesigns\HuwaldtGuitar\Control\050415\main.c:369:Error [1131] > type mismatch in assignment > > The erroneous line is: > > SongArray=&Song1Array; > > THANKS! > > Harold > > >> Don't have a clue what's the problem, but others might find it helpful >> if we know exactly what the compiler said. A copy & paste of the >> entire output might be helpful >> >> On 5/6/05, Harold Hallikainen wrote: >>> I have an array of structures in ROM. I want a pointer in RAM to point >>> to >>> that. The C manual that comes with MCC18 is a bit unclear on how to do >>> this. My array in ROM is defined as: >>> >>> struct SongChord >>> { >>> unsigned char beats; >>> unsigned int chord; >>> }; >>> >>> #pragma romdata song1=0xe000 >>> >>> struct SongChord rom const Song1Array[]={ >>> data goes here } >>> >>> I'm trying to define a pointer that points to it. Thus far, I define the >>> pointer like this: >>> >>> struct SongChord rom const *SongArray; // local pointer to a song >>> >>> I'm trying to initialize the pointer with this: >>> >>> SongArray=&Song1Array; >>> >>> and getting complaints from the compiler. >>> >>> My goal is to have SongArray be a pointer in RAM that points to the >>> array >>> in ROM so I can do something like this: >>> >>> NumBeats=SongArray[3].beats; >>> >>> Pointers in C have always been tricky to me. Mixing RAM and ROM makes it >>> worse! >>> >>> Thanks for any help! >>> >>> Harold >>> >>> -- >>> FCC Rules Updated Daily at http://www.hallikainen.com >>> -- >>> http://www.piclist.com PIC/SX FAQ & list archive >>> View/change your membership options at >>> http://mailman.mit.edu/mailman/listinfo/piclist >>> >> >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > > > -- > FCC Rules Updated Daily at http://www.hallikainen.com > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist