# Interrupt an interrupt pic16f628A

Status
Not open for further replies.

#### mkace

##### New Member
Hi,
I'm making a circuit and i am using RB0/INT as my interrupt port. When i set it to high it runs my interrupt routine. This works 100%. What i need to do is while i am running my interrupt routine if RB0/INT goes high again stop the interrupt routine and start it again.

My interrupt routine has an LED on for 10 seconds and when the RB0/INT goes high i want to reset my counter and keep the LED on for another 10 seconds (start the count again). Like a retriggerable timer. When on 48Khz the LED goes off for 0.5ms or less. I am setting INTCON.INTF = 0 ; at the start of my interrupt routine to do this. When set at 4Mhz it works. I have tested this with a multimeter, and i cannot see it drop on the 4Mhz only on the 48khz.

Any ideas?

Thanks,
Marc

#### Pommie

##### Well-Known Member
The simplest way is to test the interrupt flag in your 10 second delay and reset the counter. A better way would be to setup a timer interrupt and use that to count down your 10 second period. If an RB0 interrupt comes along then just set the period back to 10 seconds. Using a second interrupt frees up the processor to do other things. If you don't need it to do anything else then use the first method.

Mike.

#### Gayan Soyza

##### Active Member
Will this work?

Code:
		btfsc	INTCON,T0IF		;is it LED Time?
goto	Count_LED_Time
btfss	INTCON,INTF		;is it EXT INT?
goto	Exit_ISR

;reset	LED_Counter
Count_LED_Time  ;

Last edited:

#### Nigel Goodwin

##### Super Moderator
Hi,
I'm making a circuit and i am using RB0/INT as my interrupt port. When i set it to high it runs my interrupt routine. This works 100%. What i need to do is while i am running my interrupt routine if RB0/INT goes high again stop the interrupt routine and start it again.

My interrupt routine has an LED on for 10 seconds and when the RB0/INT goes high i want to reset my counter and keep the LED on for another 10 seconds (start the count again). Like a retriggerable timer. When on 48Khz the LED goes off for 0.5ms or less. I am setting INTCON.INTF = 0 ; at the start of my interrupt routine to do this. When set at 4Mhz it works. I have tested this with a multimeter, and i cannot see it drop on the 4Mhz only on the 48khz.
You need to reconsider your solution, ISR's need to be short and fast, you DON'T sit and wait 10 seconds (or even 10mS) in an ISR.

#### mkace

##### New Member
You need to reconsider your solution, ISR's need to be short and fast, you DON'T sit and wait 10 seconds (or even 10mS) in an ISR.

Will the interrupt routine go back to where it exited the main program or can i reset the program counter and start my main program from the start. hence keeping the counter in the main program not in the interrupt routine.