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

How to access internal register of PIC using ccs pic c

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



Joined: 05 Mar 2012
Posts: 18
Location: India

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

How to access internal register of PIC using ccs pic c
PostPosted: Tue May 08, 2012 6:42 am     Reply with quote

i am new to ccs pic c
and found it really very usefull, but one thing i want to know is that, how can i access the internal registers of pic using this compiler..

for example.. suppose i have to write some data in some register like rcsta or some other..
how can i do so..

Thanks in advance
_________________
Arun Sharma
jeremiah



Joined: 20 Jul 2010
Posts: 1358

View user's profile Send private message

PostPosted: Tue May 08, 2012 7:06 am     Reply with quote

The main way is #byte or #word (depending on if your pic uses 8bit or 16bit registers)

#byte variable_name = address
#word variable_name = address

For address, you can sometimes put:

#byte variable_name = getenv("Register_Name")

For a more portable version.

There is also a #bit. All of this is in the compiler manual.
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Tue May 08, 2012 7:23 am     Reply with quote

Possibly a more important question is what you want to gain direct access to the registers? What is it that you are trying to do? Beginners seldom, if ever NEED to access SFRs directly. Even experienced programmers don't need to very often, and many, such as myself, need to check the syntax and details with the manual and data sheet.

RF Developer.
jgschmidt



Joined: 03 Dec 2008
Posts: 184
Location: Gresham, OR USA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue May 08, 2012 8:40 am     Reply with quote

In the CCS IDE select "View" and "Special Registers". There you can see all the registers for a particular part. You can then select "Make Include File" and a .h file with register names and addresses will be generated. You can generate all of them or just portions such as only those related to SPI.

As the other responders say, you should only be doing this if you know precisely why and what you are doing this for. A major reason for using the CCS compiler is to avoid all this.
_________________
Jürgen
www.jgscraft.com
07arunsharma



Joined: 05 Mar 2012
Posts: 18
Location: India

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

PostPosted: Tue May 08, 2012 8:16 pm     Reply with quote

Thanks alot.

It really helped me.
_________________
Arun Sharma
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