I'm jumping in way late, but let me add to the confusion. Remember the Pics are Harvard archetecture - separate Program memory and Data memory. rom tells the compiler to put the "data" in program memory. It gets put there when you "burn" the chip. Doesn't need to be initialized - it's "always" there. udata tells the compiler to allocate space in data memory (RAM). It is uninitialized RAM so anything could be there when the program starts. idata tells the compiler to allocate space in data memeory too. But, it also tells the compiler to generate the neccesary startup code to copy the initialized values from program memory (ROM) into the data memory (RAM). When you power up your gizmo anything could be in the RAM. The startup code copies the initializer values from ROM into the appropriate areas of RAM for the variables that are in the idata section. Someone else can probably explain this much more eloquently than me. In fact, maybe I've got it all wrong! -- Mark > -----Original Message----- > From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu]On Behalf > Of slippyr4 > Sent: Thursday, October 19, 2006 2:13 PM > To: Microcontroller discussion list - Public. > Subject: Re: [PIC] C18 rom lookup table > > > well forgive me if i'm wrong, but the very array i posted before > compiled but was not initialized, until i added the pragma. > > presumably this depends on your linker script. > > All rom says is to put the variable in rom. The MCC18 docs say that > idata signifies a section of initialized data. Are you therefore > saying that the following will work:- > > #pragma udata uninitdatasection > rom int test=0x55; > #pragma udata > > ? > > On 19/10/06, John Temples wrote: > > No, you do not need a #pragma idata or any other #pragma for this > > array in C18. The "rom" keyword is sufficient. > > > > On Thu, 19 Oct 2006, slippyr4 wrote: > > > > > #pragma idata initdata > > > > > > rom char menuitems[4][10] = > > > { > > > {"Set Audio"}, > > > {"Set Radar"}, > > > {"Backlight"}, > > > {"Exit Menu"} > > > }; > > > > > > #pragma idata > > > > > > That'll see you right. You need to #pragma idata ("i" meaning > > > initialized data, i think), as well as rom -prefix your definition. > > > > > > On 19/10/06, Tom Sefranek wrote: > > >> Well, it compiles, with no errors, but I get no program data either. > > >> > > >> Kenneth Lumia wrote: > > >> > > >>>> I am trying to implement a "C" based lookup table > installed in program > > >>>> memory. I envision it as a one dimensional array, address > in, data out. > > >>>> > > >>>> > > >>>> > > >>> for C18, try > > >>> > > >>> rom INT_8 secondsunday[] = {9,8,14,13,12,11,10}; > > >>> > > >>> Which would be accessed somewhat like the following: > > >>> > > >>> //need to determine the day that the 2nd Sunday of March falls on > > >>> DST_temp.tm_mday = 1; //force to 1st day of month > > >>> day = dayofweek(&DST_temp); //determine what day the > 1st of the month > > >>> falls on > > >>> day = secondsunday[day]; //lookup the day > the second sunday > > >>> falls on > > >>> DST_temp.tm_mday = day; //save the second > sunday into the > > >>> structure > > >>> > > >>> Also, for text, you could use: > > >>> rom char dayofweektext[] = "SunMonTueWedThuFriSat"; > > >>> > > >>> Ken > > >>> ________________________________________ > > >>> "Well that never happened in any of the simulations" > > >>> klumia@adelphia.net > > >>> > > >>> > > >>> ----- Original Message ----- > > >>> From: "Thomas C. Sefranek" > > >>> To: "'Microcontroller discussion list - Public.'" > > >>> Sent: Wednesday, October 18, 2006 4:11 PM > > >>> Subject: [PIC] C18 rom lookup table > > >>> > > >>> > > >>> > > >>> > > >>>> I am trying to implement a "C" based lookup table > installed in program > > >>>> memory. I envision it as a one dimensional array, address > in, data out. > > >>>> > > >>>> I am lost in the # pragma romdata .... stuff. > > >>>> And I believe there is a way to initialize it too? > > >>>> > > >>>> ADVthanksANCE > > >>>> > > >>>> Tom > > >>>> > > >>>> * > > >>>> | __O Thomas C. Sefranek WA1RHP@ARRL.NET > > >>>> |_-\<,_ Amateur Radio Operator: WA1RHP > > >>>> (*)/ (*) Bicycle mobile on 145.41MHz PL74.4 > > >>>> > > >>>> ARRL Instructor, Technical Specialist, VE Contact. > > >>>> http://hamradio.cmcorp.com/inventory/Inventory.html > > >>>> http://www.harvardrepeater.org > > >>>> > > >>>> > > >>>> > > >>>> > > >>>> -- > > >>>> http://www.piclist.com PIC/SX FAQ & list archive > > >>>> View/change your membership options at > > >>>> http://mailman.mit.edu/mailman/listinfo/piclist > > >>>> > > >>>> > > >>>> > > >>> > > >>> > > >>> > > >>> > > >> > > >> -- > > >> * > > >> | __O Thomas C. Sefranek WA1RHP@ARRL.net > > >> |_-\<,_ Amateur Radio Operator: WA1RHP > > >> (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz > > >> > > >> http://hamradio.cmcorp.com/inventory/Inventory.html > > >> http://www.harvardrepeater.org > > >> > > >> -- > > >> 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 > > > > > > > -- > > John W. Temples, III > > -- > > 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 > > -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist