CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Storing data in ROM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








Storing data in ROM
PostPosted: Tue Jan 12, 2010 7:34 am     Reply with quote

Hi,

I have a question regarding ROM data storage. The background is that the project I'm working on use character arrays to store data associated with our menu system in the program memory. A while ago this was done like this:

Code:
UCHAR ROM menuData[] = {.....};


This code refuses to compile after a compiler upgrade we did a while back (from PCW 4.064 to PCW 4.104) so we had to switch to using this instead:

Code:
const UCHAR menuData[] = {.....};


The const qualifier causes quite a bit of overhead tho and it is this I would like to get rid of since we're already running low on flash. If I've understood the manual correctly I should be able to keep using the const qualifier and adding the following line to achieve what I want:

Code:
#device CONST=ROM


However, this causes an abundance of compiler errors telling me that I'm missing an opening parenthesis at every array. My question is, why doesn't this work? Is it some kind of compiler bug? I should mention that using CONST=ROMI works like a charm but that seems to cause as much overhead as omitting the line all together.

Thanks in advance,
Axel Lindholm
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 12, 2010 11:59 am     Reply with quote

It compiled with no problems for me, using vs. 4.104. However, I did
have to add the typedef statement for UCHAR to make it compile.
Here's the test program:
Code:

#include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

typedef unsigned char UCHAR;

unsigned char ROM menuData[] = {"Hello World"};

//====================   
void main(void)
{

while(1);
}
tesla80



Joined: 23 May 2007
Posts: 81

View user's profile Send private message

PostPosted: Tue Jan 12, 2010 3:30 pm     Reply with quote

Can the program access to ROM (program memory of PIC) for writing or reading?

Bootloaders does this?
Axel



Joined: 18 Sep 2008
Posts: 9
Location: Gothenburg

View user's profile Send private message

PostPosted: Wed Jan 13, 2010 3:22 am     Reply with quote

PCM programmer wrote:
It compiled with no problems for me, using vs. 4.104. However, I did
have to add the typedef statement for UCHAR to make it compile.


Thank you very much, I found what was wrong thanks to your reply. It would seem that the keyword "ROM", which was in upper case in our source code, has been changed to lower case in version 4.104 of the compiler. We are using the #case directive in our code and the upper case rom qualifier worked fine with 4.064 but not with 4.104.

tesla80 wrote:
Can the program access to ROM (program memory of PIC) for writing or reading?

Bootloaders does this?


Yes, this can be done by calling read_program_memory(...) and write_program_memory(...) with the appropriate parameters.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group