View previous topic :: View next topic |
Author |
Message |
kgn340
Joined: 12 Jan 2004 Posts: 5
|
Reading various SFRs at run time |
Posted: Wed Feb 14, 2007 2:02 pm |
|
|
Hi all,
I'm working with the PIC18F8722 and have developed a simple user interface.
To aid in debugging, I would like to be able to read various Special Function Registers (T3CON, ADCON0, T1CON, etc) at run time.
Is there some time of read that will allow me to index into the SFRs?
ie. SFR_READ ( 0xFCD ) would read T1CON.
Thanks,
kevin |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Feb 14, 2007 2:17 pm |
|
|
Use the CCS #byte directive to declare the address of the SFR register.
Look up the address in the PIC's data sheet, or use a pre-made SFR
declarations file:
http://www.ccsinfo.com/forum/viewtopic.php?t=14755
Then treat the declared register name as a normal variable.
Example:
Code: |
#byte T1CON = 0xFCD
void main()
{
int8 value;
value = T1CON;
while(1);
}
|
|
|
|
kgn340
Joined: 12 Jan 2004 Posts: 5
|
|
Posted: Wed Feb 14, 2007 2:24 pm |
|
|
I guess I didn't make myself clear enough.
In my program I would like the ability to read *any* SFR register, not just hard coded ones.
if possible, it will help me debug a set of operating issues as they arise.
is this possible? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
kgn340
Joined: 12 Jan 2004 Posts: 5
|
|
Posted: Wed Feb 14, 2007 3:00 pm |
|
|
AWESOME!!!
that's what it was.
THANK YOU!!! |
|
|
|