View previous topic :: View next topic |
Author |
Message |
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
Clearing an RB0 Interrupt Flag (PIC18FXX2/XX20/XX8/XX80 |
Posted: Wed Dec 07, 2005 1:03 pm |
|
|
I'm calling a function to service an rb0 ext interrupt from within another isr.
Anyways, what is the correct way to clear the INTCON.RB0IF flag? Do I simply write a '0' to that bit? Or can I just do a 'dummy read' of portB to clear it. Or is either method ok? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 07, 2005 1:14 pm |
|
|
From CCS manual:
Quote: | CLEAR_INTERRUPT()
Syntax: clear_interrupt(level)
Examples: clear_interrupt(int_timer1); |
If your version of the compiler doesn't support that function,
then clear the flag as you described (except the bit is actually
INT0IF). Dummy read is only for "interrupt on change" interrupts
which are not the same as INT_EXT, and are on different pins. |
|
|
valemike Guest
|
|
Posted: Wed Dec 07, 2005 6:53 pm |
|
|
Oh, i never knew that function existed.
I guess all this time then, that i rarely did get overlapping interrupts; otherwise i'd be getting wrong motor counts (since my encoder is hooked up to rb0). Otherwise, i'd be interrupting to a timer isr, which would then call a pending rb0 interrupt isr function, would have exited and unexpectedly called the rb0 interrupt again. |
|
|
Ttelmah Guest
|
|
Posted: Thu Dec 08, 2005 3:14 am |
|
|
As a comment, you need to do both operations (read the port, _and_ clear the flag). The flag is set, if the data on port B, differs from the value held in a 'ghost' register, which is updated whenever the port is read. If you clear the flag, without reading the port, the flag will immediately re-set. The sequence should be:
Dummy read.
Clear flag.
Best Wishes |
|
|
|