My solution for a quick and easy one shot interrupt to send the main body of my program to a completion routine to send data to the PC is as follows.
goto Start
define INTHAND myint
asm
myint goto _printlog
endasm
That’s it! On completion of data logging the unit goes to low power state “@sleep”. When the user is ready to log to the PC, a GP2 ext int button is pushed. Unit goes to printlog and uploads data then goes to low power.
With GIE clear from interrupt INTF does not have to be cleared and no Return or Retfie is needed if the program is not going back to the position of interrupt, I am not concerned with anything on the stack since the main program is finished so if data is pushed off the stack during the upload routine, who cares. The only thing I was not able to do was reset the interrupt function to operate again without resetting the processor. INTCON was reset but it just didn’t work without a reset. (?) SO, for a one shot interrupt to a last short routine, this works great.
Final note of interest: The program uses SLEEP and @sleep. PBP SLEEP uses WDT to time the sleep period indicated. @sleep is used to go to a low power state indefinitely if the WDT is turned off. My program uses WDT under software control (WDTCON) to give me the ability to use both instructions. PBP SLEEP will not function properly under software control unless you set WDTCON.WDTPS =100. It took me a while to figure out why SLEEP60 was timing out in 5sec. rather than 1min.
Bookmarks