View previous topic :: View next topic |
Author |
Message |
07arunsharma
Joined: 05 Mar 2012 Posts: 18 Location: India
|
How to access internal register of PIC using ccs pic c |
Posted: Tue May 08, 2012 6:42 am |
|
|
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: 1349
|
|
Posted: Tue May 08, 2012 7:06 am |
|
|
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
|
|
Posted: Tue May 08, 2012 7:23 am |
|
|
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
|
|
Posted: Tue May 08, 2012 8:40 am |
|
|
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
|
|
Posted: Tue May 08, 2012 8:16 pm |
|
|
Thanks alot.
It really helped me. _________________ Arun Sharma |
|
|
|