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 support@ccsinfo.com

How to define variable in specific address of data memory?

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



Joined: 09 Apr 2009
Posts: 29

View user's profile Send private message

How to define variable in specific address of data memory?
PostPosted: Thu Apr 09, 2009 11:13 am     Reply with quote

Hi friends
I use PCW 4.057.
what should i do to define specific address for a variable? ie,when I use 18F452, I want to define 16bit variable in 0x120 and 0x121 of internal ram. what should i write in CCS to locate my variable in these addresses?
Regards
_________________
Sorry if i have much mistakes, my english is not good.
Thanks a lot for your helps.
Have a good time
Ttelmah
Guest







PostPosted: Thu Apr 09, 2009 2:45 pm     Reply with quote

There are actually several ways of doing this.
The 'correct' way, depends on whether you want to stop any other variable using the same area as well.
Code:

int16 val;

#byte val=0x120

The int16 variable 'val', is now located at 0x120/121
The area can _still be used by C for other variables_. This is the approach normally used to locate a named variable 'on' one of the internal registers, since you need to still allow other variables the compiler may have mapped to the same locations, to be in the same spot.

Code:

int16 val;

#locate val=0x120

The int16 variable 'val', is again located at 0x120/121, but now C won't use the area for anything else.

Best Wishes
Guest








PostPosted: Fri Apr 10, 2009 1:21 am     Reply with quote

Thanks a lot Ttelmah, I understand. But can I write other things instead of int16 too?
Thanks again
Study



Joined: 09 Apr 2009
Posts: 29

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 1:23 am     Reply with quote

Anonymous wrote:
Thanks a lot Ttelmah, I understand. but can i write other things instead of int16 too?
Thanks again

Sorry this is my post, i forgot to login before sending post Embarassed
_________________
Sorry if i have much mistakes, my english is not good.
Thanks a lot for your helps.
Have a good time
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Apr 10, 2009 3:26 am     Reply with quote

Quote:
But can I write other things instead of int16 too?.

1. Consider #locate as a general CCS specific command and try to answer the question yourself.
2. In case of doubt, consult the compiler manual
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