|
|
View previous topic :: View next topic |
Author |
Message |
Skywalker
Joined: 11 Mar 2004 Posts: 5 Location: Germany/Ilmenau
|
Easy way to read Interrupt bits but not using interrupts? |
Posted: Wed Aug 04, 2004 1:47 am |
|
|
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 |
Posted: Wed Aug 04, 2004 1:56 am |
|
|
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 |
|
|
|
|
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
|