Searching \ for '[PIC] C18 rom lookup table' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=table
Search entire site for: 'C18 rom lookup table'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] C18 rom lookup table'
2006\10\18@161153 by Thomas C. Sefranek

face picon face
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  spam_OUTWA1RHPTakeThisOuTspamARRL.NET
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41MHz PL74.4

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org




2006\10\18@162542 by William Couture

face picon face
On 10/18/06, Thomas C. Sefranek <.....tcsKILLspamspam@spam@cmcorp.com> 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.
>
> I am lost in the # pragma romdata .... stuff.
> And I believe there is a way to initialize it too?

It might help to know what compiler you are using, and what
sort of "addresses" and "data" you are using.

For most compilers, using the CONST keyword will put the table into
program memory instead of data ram.  i.e.

const long int powers_of_2[16] =
  {       1,      2,        4,        8,
        16,     32,      64,     128,
      256,   512,   1024,   2048,
    4096,  8192, 16384, 32768
  };

Bill

--
Psst...  Hey, you... Buddy...  Want a kitten?  straycatblues.petfinder.org

2006\10\18@165126 by Thomas C. Sefranek

face picon face
Thanks Bill,

-----Original Message-----
From: piclist-bouncesspamKILLspammit.edu [.....piclist-bouncesKILLspamspam.....mit.edu] On Behalf Of
William Couture
Sent: Wednesday, October 18, 2006 4:26 PM
To: Microcontroller discussion list - Public.
Subject: Re: [PIC] C18 rom lookup table

On 10/18/06, Thomas C. Sefranek <EraseMEtcsspam_OUTspamTakeThisOuTcmcorp.com> wrote:
{Quote hidden}

Address could be an integer, data could also be an integer.

>For most compilers, using the CONST keyword will put the table into
>program memory instead of data ram.  i.e.

const long int powers_of_2[16] =
  {       1,      2,        4,        8,
        16,     32,      64,     128,
      256,   512,   1024,   2048,
    4096,  8192, 16384, 32768
  };

Bill

--
Psst...  Hey, you... Buddy...  Want a kitten?  straycatblues.petfinder.org

Yea, I miss my fur persons.

Tom


2006\10\18@165248 by Kenneth Lumia

picon face
>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"
klumiaspamspam_OUTadelphia.net


{Original Message removed}

2006\10\18@165847 by peter green

flavicon
face

> 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.
declare your array as const rom

2006\10\18@172324 by Thomas C. Sefranek

face picon face
It compiles, Thanks.

Tom

 *
 |  __O    Thomas C. Sefranek  @spam@WA1RHPKILLspamspamARRL.NET
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41MHz PL74.4

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org

{Original Message removed}

2006\10\18@194009 by Tom Sefranek

face picon face
Well, it compiles, with no errors, but I get no program data either.

Kenneth Lumia wrote:

{Quote hidden}

>{Original Message removed}

2006\10\18@233353 by Kenneth Lumia

picon face
> From: "Tom Sefranek" <RemoveMEtcsTakeThisOuTspamcmcorp.com>
> Well, it compiles, with no errors, but I get no program data either.

Did you look in the .map file for the variable (in the example
below, you would search for secondsunday (no brackets)?
This would give the starting address and if it is in program
or data memory (doesn't show the initialzed data however).  
To see the initialized data, you could open a watch window
and select the variable - the watch window will expand it.
 
I'm not sure why it doesn't show up in the list file - you may
want to look for a command line option for the linker that would
force it into the list file for human readable output.

Ken
________________________________________
"Well that never happened in any of the simulations"
spamBeGoneklumiaspamBeGonespamadelphia.net


{Original Message removed}

2006\10\19@040305 by slippyr4

picon face
#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 <TakeThisOuTtcsEraseMEspamspam_OUTcmcorp.com> wrote:
{Quote hidden}

> >{Original Message removed}

2006\10\19@092112 by William Couture

face picon face
On 10/18/06, Thomas C. Sefranek <tcsEraseMEspam.....cmcorp.com> wrote:
> >It might help to know what compiler you are using,
>
> >From the subject line: C18

Memo to self:  learn to read...

Bill

--
Psst...  Hey, you... Buddy...  Want a kitten?  straycatblues.petfinder.org

2006\10\19@101758 by Thomas C. Sefranek

face picon face
Thanks Bill,

I think I better post that memo on my computer screen too.
(The only time I don't have my foot in my mouth is when I'm changing feet.)

Tom

 *
 |  __O    Thomas C. Sefranek  EraseMEWA1RHPspamARRL.NET
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41MHz PL74.4

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org

{Original Message removed}

2006\10\19@115440 by John Temples

flavicon
face
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:

{Quote hidden}

>>> {Original Message removed}

2006\10\19@141313 by slippyr4

picon face
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 <RemoveMEpiclist2TakeThisOuTspamspamxargs.com> wrote:
{Quote hidden}

> >>> {Original Message removed}

2006\10\19@153105 by Mark Scoville

flavicon
face
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 removed}

2006\10\19@160200 by Thomas C. Sefranek

face picon face

-----Original Message-----
From: piclist-bouncesSTOPspamspamspam_OUTmit.edu [spamBeGonepiclist-bouncesSTOPspamspamEraseMEmit.edu] On Behalf Of
John Temples
Sent: Thursday, October 19, 2006 11:54 AM
To: Microcontroller discussion list - Public.
Subject: Re: [PIC] C18 rom lookup table

No, you do not need a #pragma idata or any other #pragma for this
array in C18.  The "rom" keyword is sufficient.

Indeed!

This works for me:

rom int CAN_Id[80] = { 1, 3, 5, 0, 2, 4, 6, 0, 7, 9, 11, 0, 8, 10, 12, 0,
                13, 15, 17, 0, 14, 16, 18, 0, 19, 21, 23, 0, 20, 22, 24, 0,
                25, 27, 29, 0, 26, 28, 30, 0, 31, 33, 35, 0, 32, 34, 36, 0,
                37, 39, 41, 0, 38, 40, 42, 0, 43, 45, 47, 0, 44, 46, 48, 0
};

I get the values in program memory.
I checked!

BTW:  Thanks to all who tried to help.

Tom

 *
 |  __O    Thomas C. Sefranek  KILLspamWA1RHPspamBeGonespamARRL.NET
 |_-\<,_   Amateur Radio Operator: WA1RHP
 (*)/ (*)  Bicycle mobile on 145.41MHz PL74.4

ARRL Instructor, Technical Specialist, VE Contact.
hamradio.cmcorp.com/inventory/Inventory.html
http://www.harvardrepeater.org


2006\10\19@161707 by piclist2

flavicon
face
On Thu, 19 Oct 2006, slippyr4 wrote:

> well forgive me if i'm wrong, but the very array i posted before
> compiled but was not initialized, until i added the pragma.

I would guess you had some other problem then.

> All rom says is to put the variable in rom. The MCC18 docs say that
> idata signifies a section of initialized data.

Yes; initialized data in RAM, not in ROM.

> Are you therefore saying that the following will work:-
>
> #pragma udata uninitdatasection
>  rom int test=0x55;
> #pragma udata

Yes.  Try it.  "#pragma udata uninitdatasection" changes the name of
the active udata section to "uninitdatasection".  It does not mean
"put the variable on the next line in udata."  "rom" variables go into
the active "romdata" section.  You can't change that.

{Quote hidden}

>>>>> {Original Message removed}

More... (looser matching)
- Last day of these posts
- In 2006 , 2007 only
- Today
- New search...