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

Multiple interrupts on RB0 help....code included!

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







Multiple interrupts on RB0 help....code included!
PostPosted: Fri Apr 04, 2003 4:59 pm     Reply with quote

Just wondering if anyone can help...I am trying to use the RB0 interrupt pin on a PIC16F84A. I have a 4.7 pullup resistor on pin RB0. Usually, the resistor is open (0V), however on end of the resistor is connected to 5V (through a relay). I want the MCU to go the ISR when it sees 5V. Once the ISR completes, the relay opens up and the resistor sees 0V again.
The following code will only go to the ISR once! I need it to be able to go to the ISR anytime it sees 5V! Can anyone show me how to use the RB0 interrupt pin for multiple interrupts?
Thanks ahead...

Dzuy





#include <16F84A.H>
#fuses HS,NOWDT, NOPROTECT, PUT
#use DELAY (clock=20000000)

#use fast_io(A)
#use fast_io(B)

int i;
int x;
int c;

#int_rb
void lightISR()
{
output_high(PIN_A0);
delay_ms(200);
delay_ms(200);
output_low(PIN_A0);
}

/* main() */

void main()
{

/* Set pin A1 to be the blue led */
SET_TRIS_A(0x00);
/* Allow pin B0 to be an external interrupt pin */
SET_TRIS_B(0b00010000);

ext_int_edge(L_TO_H);
enable_interrupts(global);
enable_interrupts(int_rb);

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 13428
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Multiple interrupts on RB0 help....code included!
PostPosted: Fri Apr 04, 2003 5:19 pm     Reply with quote

:=Just wondering if anyone can help...I am trying to use the RB0 interrupt pin on a PIC16F84A. I have a 4.7 pullup resistor on pin RB0. Usually, the resistor is open (0V), however on end of the resistor is connected to 5V (through a relay). I want the MCU to go the ISR when it sees 5V. Once the ISR completes, the relay opens up and the resistor sees 0V again.
:=The following code will only go to the ISR once! I need it to be able to go to the ISR anytime it sees 5V! Can anyone show me how to use the RB0 interrupt pin for multiple interrupts?
------------------------------------------------------------

Your code is attempting to use INT_RB, which is the
"interrupt on change" interrupts. It also only works on
pins RB4-RB7. I think you really want to use INT_EXT.

Here is a demo program for INT_EXT.
<a href="http://www.pic-c.com/forum/general/posts/2138.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/2138.html</a>

Also, you don't want to leave the interrupt pin as a floating
input part of the time. I think that's what you're doing.
I'd suggest putting a 4.7K ohm resistor to +5v, as a pull-up,
and then have the relay put ground on the PIC RB0 pin, when
the relay is closed.

<PRE>
+5v
---- |
| >
| < 4.7K
| >
| |
RB0 |------------o o-----------
| relay |
---- contacts --- GND
-
</PRE>

When the relay contacts close, it will put GND on RB0,
but otherwise, it's pulled up to +5v.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13429
Dzuy Nguyen
Guest







Re: Multiple interrupts on RB0 help....code included!
PostPosted: Fri Apr 04, 2003 6:19 pm     Reply with quote

Thank you very much! It works!
Dzuy



:=:=Just wondering if anyone can help...I am trying to use the RB0 interrupt pin on a PIC16F84A. I have a 4.7 pullup resistor on pin RB0. Usually, the resistor is open (0V), however on end of the resistor is connected to 5V (through a relay). I want the MCU to go the ISR when it sees 5V. Once the ISR completes, the relay opens up and the resistor sees 0V again.
:=:=The following code will only go to the ISR once! I need it to be able to go to the ISR anytime it sees 5V! Can anyone show me how to use the RB0 interrupt pin for multiple interrupts?
:=------------------------------------------------------------
:=
:=Your code is attempting to use INT_RB, which is the
:="interrupt on change" interrupts. It also only works on
:=pins RB4-RB7. I think you really want to use INT_EXT.
:=
:=Here is a demo program for INT_EXT.
:= <a href="http://www.pic-c.com/forum/general/posts/2138.html" TARGET="_blank"> <a href="http://www.pic-c.com/forum/general/posts/2138.html" TARGET="_blank">http://www.pic-c.com/forum/general/posts/2138.html</a></a>
:=
:=Also, you don't want to leave the interrupt pin as a floating
:=input part of the time. I think that's what you're doing.
:=I'd suggest putting a 4.7K ohm resistor to +5v, as a pull-up,
:=and then have the relay put ground on the PIC RB0 pin, when
:=the relay is closed.
:=
:=<PRE>
:= +5v
:=---- |
:= | >
:= | < 4.7K
:= | >
:= | |
:=RB0 |------------o o-----------
:= | relay |
:=---- contacts --- GND
:= -
:=</PRE>
:=
:=When the relay contacts close, it will put GND on RB0,
:=but otherwise, it's pulled up to +5v.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13433
loh



Joined: 14 Jun 2004
Posts: 3
Location: Taiwan ROC, Taipei.

View user's profile Send private message

INT_EXT post
PostPosted: Tue Jun 15, 2004 1:03 am     Reply with quote

INT_EXT post no longer exists, repost please?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jun 15, 2004 1:24 am     Reply with quote

Quote:
INT_EXT post no longer exists, repost please ?

When posts were moved from the old board into the database
for this board, the links were broken. To find an old post,
use the search function to search for the post number.
For example, here is the post that you wanted:
http://www.ccsinfo.com/forum/viewtopic.php?t=8504&highlight=2138
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