|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
Storing data in ROM |
Posted: Tue Jan 12, 2010 7:34 am |
|
|
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:
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
|
|
Posted: Tue Jan 12, 2010 11:59 am |
|
|
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
|
|
Posted: Tue Jan 12, 2010 3:30 pm |
|
|
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
|
|
Posted: Wed Jan 13, 2010 3:22 am |
|
|
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. |
|
|
|
|
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
|