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

Place a const at a fixed location?

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








Place a const at a fixed location?
PostPosted: Wed Feb 10, 2010 8:12 am     Reply with quote

I want to place this line at fixed location in the code, how to do that?
Code:
Const char IDNr[] = {"hw:2.00 / fw:1.20"};


hints?
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Feb 10, 2010 10:52 am     Reply with quote

Look at #org in the help.
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Wed Feb 10, 2010 2:13 pm     Reply with quote

I've used something similar to the code shown in this post.

The location is usually the last implemented registers.

Example for 12F629:
Code:
#ORG 0x3D0,0x3DF
const char build_rev[] = {"Rev 1.0"};   // max length = 15
#ORG 0x3E0,0x3EF
const char build_date[] = __DATE__;      // max length = 15
#ORG 0x3F0,0x3FF
const char build_time[] = __TIME__;      // max length = 15

...

printf("%s\nBuild: \%s, \%s\n\r", build_rev, build_date, build_time);
Guest








PostPosted: Wed Feb 10, 2010 2:45 pm     Reply with quote

I dont understand I cant compile it when using the #ORG xx yy statement?
I get error...
I place the statement at the top of my main.c file.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 10, 2010 2:52 pm     Reply with quote

This post has an example of where to place the #org statement
in your program:
http://www.ccsinfo.com/forum/viewtopic.php?t=41440&start=3
Guest








PostPosted: Wed Feb 10, 2010 3:51 pm     Reply with quote

Thanks, But wont work.

I use:
Code:
#org 0x300, 0x310
Const Char IDNr[] = "v1.0";


And get this error:
Code:
*** Error 71 "main.c" Line 444(0,1): Out of ROM, A segment or the program is too large    @const76
Seg 00300-00310, 0012 left, need 0022


Its the same error even if I change the #org addr space?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 10, 2010 3:54 pm     Reply with quote

Post your PIC and your compiler version.
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Wed Feb 10, 2010 6:22 pm     Reply with quote

Also post the small program...

I believe this:
Code:
Const Char IDNr[] = "v1.0";

should read:
Code:
Const Char IDNr[] = {"v1.0"};


Your address looks pretty low too:
Code:
#org 0x300, 0x310


Normally you would place this at the top range of the code space.
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