View Single Post
  #10   Spotlight this post!  
Unread 14-03-2006, 11:02
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Please help: Memory allocation problem dealing with sections

The "rom const" directive is in the C18 manual. What it says is that the data that it refers to, (whatever its type - char, int, struct, array...) is not going to change (the const part). Further it says that you want this data to be stored in the program memory (the rom part).

The compiler will look at the directive and allocate the space for the data along with the program in the program memory which is much much bigger than the RAM. The compiler will make sure that the addressing modes in the generated machine code for accessing that data are appropriate for pulling data out of the program space.

Take a look at the .map file with the data declared as "rom const" and again with
the data declared without the "rom const" and see what section and what address the data is being stored at. I think that will help you understand what is going on.