PDA

View Full Version : How to use RB1(INT1) as an interrupt?



elec_mech
- 30th June 2005, 16:33
Okay, I've been trying this all morning with absolutely no luck. Do any of you gracious, knowledgeable programming guru's have a snippet of code just to use RB1 (on the PIC 18F2525 in this instance) as an interrupt. I have tried everything I can think of, I've read countless posts to no avail. I've found info on using RB0 (which I'm using and having no problem with) and even RB4-RB7, but nothing on RB1.

Some say to call out the registers before using the ON INTERRUPT command, the PBP manual and many codes on the forum put them after. Reading the datasheet, I think I set up RB1 as an active interrupt by:

On Interrupt goto some_routine
intcon = %10000000
intcon3 = %00001000

But when I push my momentary switch to simulate an interrupt (goes low), nothing happens. If I stick with the INT0 interrupt solely, everything works beautifully.

My goal is to use two interrupts going to the same interrupt handler, but only have one on all the time. The other would be turned on and off within the program. I'm pretty sure I can figure that out if someone could just show me how to turn on the RB1 (INT1) interrupt. Thanks all!

elec_mech
- 30th June 2005, 17:54
Alright, after having someone look it and pull out a meter, I noticed I wasn't getting enough current through the switch. So, for anyone asking this question, here's some code. If it doesn't work, make sure the PIC is seeing at least 3V if it's supposed to be normally high.

On Interrupt goto some_routine
intcon = %10000000 ' Enable global interrupt (GIE)
intcon3.3 = 1 ' Enable INT1 (on 18F2525 datasheet)

Hope this helps someone.