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

Pointer to constant

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 04, 2011 12:00 pm     Reply with quote

I made a test program that uses the "rom" keyword that Ttelmah refers to.
It displays the following output in the MPLAB simulator for vs. 4.119.
This output is correct.
Quote:

ptr = 0fef
PRODUCT ID V1.01
PRODUCT ID V1.01


Code:
#include <16F1824.h>
#fuses INTRC_IO,NOWDT
#use delay(clock=4000000)
#use rs232(baud=9600, UART1, ERRORS)

char rom version[] = "PRODUCT ID V1.01";
char rom *ptr;

void display_string(rom *str)
{
printf("%s \r", str);
}

//=====================
void main()
{
ptr = version;

printf("ptr = %lx \r", ptr);

display_string(version);
display_string(ptr);
   
while(1);
}
Pekub



Joined: 20 Dec 2005
Posts: 16

View user's profile Send private message Send e-mail

PostPosted: Tue Apr 05, 2011 3:11 am     Reply with quote

Thank you PCM programmer and Ttelmah also. This is what I needed.
In my opinion, use keyword "rom" is not sufficiently explained in the manual.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 3:39 am     Reply with quote

The 'best' explanation, is the _readme_ with the compiler. This covers things that are relatively recent (though 'ROM' has been used for over a year!), and not fully in the manual. This gives the current syntax for ROM, and the keywords to change between the ROM, and const behaviour.
To work with a PIC, and CCS, you need to use the following bits of paperwork:

The C programming language or a near equivalent.
The chip's data sheet
The CCS manual
The readme.txt, and fuses.txt
The Microchip reference manuals for the specific peripherals and chip versions.

You then 'have a chance'!.... Smile

Best Wishes
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