Hey Group,

So I have this project... The PIC goes to SLEEP as it is supposed to, Then I have two pins PortA.3 and PortA.4 that have INT on change (going from high to low) enabled. I also have the WDT enabled to wake the PIC up every 60 seconds.

When the PIC is awakened from sleep by the WDT it executes as expected... ie, it displays the message "awake" (see code below)

When the PIC is awakened from sleep by either A.3 or A.4 it does NOT go to the location defined by ON INTERRUPT, if it did I would see the message "Int" displayed and I never do.

I know I should probably convert to DT's instant interrupts... but I have not YET.


Here is the relevant portion of the code, simplified for this discussion... (I can post more if needed)

Code:
On Interrupt goto MyInt 
INTCON = %10001000 'enable interupt on change
'=========================================================
'============= SLEEP HANDLER =============================
'=========================================================
 
SleepNow:
INTCON.0 = 0 'clear interrupt flag register
 
  ENABLE
SleepHere:
@ SLEEP
  DISABLE
 
pause 500
arraywrite msg,["Awake"]
len=5:GOSUB Message
 
goto SleepHere
END 
'=======================================================
'========================= Interrupt Handler
'=======================================================
MyInt:
INTCON.0 = 0 'clear interrupt flag register
pause 500
arraywrite msg,["Int"]
len=3:GOSUB Message
 
goto SleepNow 
What I thought should happen is that when the PIC is awakened by the WDT it would execute the code after the @SLEEP... It does.

While SLEEP'ing and one of the two push buttons A.3 or A.4 is pressed the PIC should execute the code in the MyInt: section where ON INTERRUPT says it should go when interrupted... IT DOES NOT. What it does do is display "Awake" and then keeps looping "Awake" (I think I need to clear an interrupt flag to stop this)

But I never get to my code in the MyInt: section.

WHY???

Any ideas are appreciated.


PS: as you can see I only ENABLE interrupts while I am sleeping... I do not want to be interrupted at other times.

Would it be better to use the regular PBP SLEEP command instead of @ SLEEP ??

Thanks in advance