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

Clearing an RB0 Interrupt Flag (PIC18FXX2/XX20/XX8/XX80

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



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

Clearing an RB0 Interrupt Flag (PIC18FXX2/XX20/XX8/XX80
PostPosted: Wed Dec 07, 2005 1:03 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Dec 07, 2005 1:14 pm     Reply with quote

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







PostPosted: Wed Dec 07, 2005 6:53 pm     Reply with quote

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







PostPosted: Thu Dec 08, 2005 3:14 am     Reply with quote

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