• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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
Most Helpful 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.
 

Nigel Goodwin

Super Moderator
Most Helpful 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.
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.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
RETFIE returns the program counter to where it was, and the main program continues as if nothing had happened. ISR's normally set a flag, and that flag is tested in the main program, with the main program taking the appropriate action.
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top