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

Reading various SFRs at run time

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



Joined: 12 Jan 2004
Posts: 5

View user's profile Send private message

Reading various SFRs at run time
PostPosted: Wed Feb 14, 2007 2:02 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 14, 2007 2:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 14, 2007 2:24 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Feb 14, 2007 2:29 pm     Reply with quote

See this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=23368
kgn340



Joined: 12 Jan 2004
Posts: 5

View user's profile Send private message

PostPosted: Wed Feb 14, 2007 3:00 pm     Reply with quote

AWESOME!!!

that's what it was.



THANK YOU!!!
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