Charles,
I'm pretty sure you're using DT_INTS with the 18F, so here's a macro that should do the same thing that RESUME LABEL does with ON Interrupt and 16F's.
I DO NOT recommend actually using it. It's just BAD programming practice. And it will cause more problems than it will alleviate. However, being the capable programmer that you are, you may be able to make some use of it.
It can be used in place of INT_RETURN.
With the format ... @ INT_RESUME _Label, IntsEnabled
The line above would "resume" at the Main: label, with interrupts enabled.Code:@ INT_RESUME _Main, 1
Changing IntsEnabled to 0, will leave the interrupts DISABLED. In case they need to be setup again from the new "Starting point".
All previous GOSUB's and Interrupts will be discarded, and the command that was interrupted will NOT be completed. Stopping a PBP command in the middle can cause unexpected results. In particular, the I2C and LCD commands, may be left in the incorrect state. Clearing the Flags register, will correct those two, but other problems can arise.
The label that is resumed to, MUST be a GOTO Loop, just like the Main loop. It CAN NOT be a subroutine with a RETURN at the end.
And since it is exiting the interrupt handler without the assistance of DT_INTS, you have to make sure the IF (interrupt flag) bits are cleared before resuming.
18F's ONLY
HTH,Code:ASM #define Reg(PBPreg, PBPbit) PBPreg ; Returns the register for a PBP BIT var INT_RESUME macro Label, IntsEnabled local PopLoop PopLoop ; Remove everything from the stack pop movf STKPTR, W bnz PopLoop ifdef ReEnterHPused ; let Instant Interrupts know we are if (ReEnterHPused == 1) ; done with the System variables banksel Reg(_VarsSaved_H) ; that were saved during the bcf _VarsSaved_H ; High Priority interrupt. endif endif ifdef ReEnterLPused ; And, we're done with the variables if (ReEnterLPused == 1) ; saved on a Low Priority INT. banksel Reg(_VarsSaved_L) bcf _VarsSaved_L endif endif ifdef USE_LOWPRIORITY ; If Low Priority INTs are being used, if (USE_LOWPRIORITY == 1) if (IntsEnabled == 1) ; and the user specified IntsEnabled bsf INTCON, GIEL ; then enable Low Priority Interrupts else ; if not, bcf INTCON, GIEL ; disable LP INTs endif endif endif if (IntsEnabled == 1) ; If the user specified IntsEnabled, bsf INTCON, GIEH ; enable High Priority Interrupts else ; if not, bcf INTCON, GIEH ; disable HP INTs endif clrf BSR ; reset to Bank0 goto Label ; resume from the users Label endm ENDASM




Bookmarks