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.

External interrupt program

Status
Not open for further replies.
If you want the lower priority to be ignored if it occurred whilst the high priority ISR is executing, clear the interrupt flag for that peripheral at the end of the high ISR.

On the 16 series, GIE is automatically cleared and restored during an interrupt so there is no need to touch it.

Mike.

You are quite correct Mike..... Adrian..... do as Mike said...

Actually thinking on..... if an interrupt is active... the other will wait until its finished anyway!!!
 
Last edited:
Actually thinking on..... if an interrupt is active... the other will wait until its finished anyway!!!

Yes, they will but clearing the interrupt flag will stop it firing after the current ISR. Edit, I think this is what he asked for but I may be wrong.

On the 18 series, low priority will be interrupted by a high priority interrupt.

Mike.
 
Last edited:
Hi, i managed to do a low priority interrupt. Now i have one problem which is; can i use goto (or similar instruction set) instead of RETFIE ?? I want to use goto instruction because i want the program to go to the MAIN label and not return to where it was after the ISR is ready.

Thanks.

EDIT: I already tried using the GOTO instruction, but its not working.
 
The interrupt HAS to have a retfie.... retfie has the return address on the stack and the program counter needs to be restored.

In the interrupt you can set a flag, once back in the main you can redirect program flow if the flag has bee set.
 
So basically the program is in an interrupt routine, when finished it will always return to where it was? there is not way to return to the MAIN label instead?

Thanks
 
So basically the program is in an interrupt routine, when finished it will always return to where it was? there is not way to return to the MAIN label instead?

Thanks

hi adrian,
Have you considered Pushing 'your' Return address onto the Stack at the end of that subr.??
 
Last edited:
Hi ericgibbs,

No i haven't tried that, actually i dont know how to do that. Is that done to change the stack address so that it will return to the MAIN loop ?
 
Hi Eric.... can you push and pop the stack on a pic16? I know you can on an 18!

hi Ian,
From his other thread ref/adc, I assumed Adrian was using the 18F4550.??

Adrian, can you please confirm the PIC type..

EDIT:
Rechecking post#1 it is a 18F4550...
 
Last edited:
Hi ericgibbs,

No i haven't tried that, actually i dont know how to do that. Is that done to change the stack address so that it will return to the MAIN loop ?

hi,
You PUSH the address of the Main onto the Stack just before the Retfie, you could make the PUSH conditional within the ISR if required.
 
Hi,

Yes it is an 18F4550 PIC microcontroller.

ericgibbs, is that done as below:

PUSH STACK, 0000H

??
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top