Continue to Site

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.

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

Return from interrupt without RETFIE on Pics

Status
Not open for further replies.

blackman

New Member
Suppose I am writing an interrupt service routine and there is a particular circumstance under which an interrupt occurs and I don't want to do RETFIE.

Basically, I want to "start over" in some sense. Is it sufficient to just re-enable the interrupts I want, set the GIE in INTCON to enable all unmasked interrupts and then jump to the start of my code?

I'm not quite sure how to "pop off" the return address that is sitting on some stack somewhere.
 
blackman said:
Suppose I am writing an interrupt service routine and there is a particular circumstance under which an interrupt occurs and I don't want to do RETFIE.

Basically, I want to "start over" in some sense. Is it sufficient to just re-enable the interrupts I want, set the GIE in INTCON to enable all unmasked interrupts and then jump to the start of my code?

I'm not quite sure how to "pop off" the return address that is sitting on some stack somewhere.

You cannot directly POP a return address off of the return stack. Tha'ts not a big deal because it will wrap around. Although you might be able to get away with this I would recommend an alternate approach. Force a RESET. The easiest and most reliable way to force a RESET is to do a watchdog timeout.
 
Last edited:
If you don't reset the bit that caused the interrupt then as soon as GIE gets set an interrupt will occur. Therefore doing a retfie will enable interrupts, pop the return address and jump to the start of your (interrupt) code.

Mike.
 
blackman said:
Suppose I am writing an interrupt service routine and there is a particular circumstance under which an interrupt occurs and I don't want to do RETFIE.

I would seriously suggest you don't! - jumping to your program start isn't the same as doing a reset!.

If (for some obscure reason?) you want to do a reset, use an I/O pin to trigger an external monostable to cause a hardware reset. But I would also suggest you don't do it from within an interruopt routine, although with a full hardware reset it should make no difference.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top