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

Easy way to read Interrupt bits but not using interrupts?

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



Joined: 11 Mar 2004
Posts: 5
Location: Germany/Ilmenau

View user's profile Send private message ICQ Number

Easy way to read Interrupt bits but not using interrupts?
PostPosted: Wed Aug 04, 2004 1:47 am     Reply with quote

I want to look in the code serveral times after the interrupt bit for Timer0 overflow. I dont want to use an interrupt for that, but reading an resetting this bit manualy. Is there an easy way or have I to read write direkt to the register?

Thx

Skywalker
Ttelmah
Guest







Re: Easy way to read Interrupt bits but not using interrupts
PostPosted: Wed Aug 04, 2004 1:56 am     Reply with quote

Skywalker wrote:
I want to look in the code serveral times after the interrupt bit for Timer0 overflow. I dont want to use an interrupt for that, but reading an resetting this bit manualy. Is there an easy way or have I to read write direkt to the register?

Thx

Skywalker

The 'easy way', is to write/read the register, but use the bit declaration. If (for instance), this is on a 18F PIC, the timer0 interrupt flag is bit 2 of the 'INTCON' register, which is at address 0xFF2. You can therefore code as:

#byte INTCON = 0xFF2
#bit TMR0IF = INTCON.2

Then to read/clear the flag, you can use code like:
Code:

if (TMR0IF) {
    TMR0IF=0;
    //Do whatever you want here now that the flag has been seen

}


It makes it plain what you are doing, and 'safe' (the access doesn't affect the other bits in the register).
You can't really get much easier!.
A while ago, somebody did post an 'include' file, containing definitions like this for just about every register and bit on the PIC. If you need to access more than just a couple of bits, it'd be worth searching the forum for this.

Best Wsihes
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