Hi, Navaid
1) think to reset the interrupt flag BEFORE allowing PORTB interrupt and entering sleep ...
2) not sure ... but , generally, change on portB need to read portB to clear the " Mismatch condition " ( @ wake-up ...)
3) enabling GIE sends you @ wake up ... to address 04 ( interrupt vector )
disabling GIE ...... to the next address of your program ( @sleep +1)
where a "nop" is highly recommended ( you did it fine ...).
a little example for a PIC 18F:
Here INT1 is the Wake-up "button"
Code:
Sommeil:
LCDOUT $FE,1, "!!*BYE - BYE*!!"
For I = 16 to 0 Step -1 'Animation arret
LCDOUT $FE,$C0,REP "*"\I," " ' ... 4s
PAUSE 250
NEXT I
PORTD = %00000000 ' PortD à 0
AlLCD = 1 ' Coupure LCD
ADCON0.0 = 0 ' Désactivation ADC
AlRef = 0 ' Coupure Vref
T3CON.0 = 0 ' arret TMR3
T1CON.0 = 0 ' arret TMR1
T0CON.7 = 0 ' arret TMR0
INTCON.7 = 0 ' Wakeup sans interruptions
INTCON3.0 = 0 ' reset flag INT1
INTCON3.3 = 1 ' validation INT1 pour réveil
@ SLEEP
@ Nop ' Redémarrage par mise du contact
INTCON3.3 = 0 'Neutralisation INT1
INTCON3.0 = 0 'Reset Flag INT1
'*****************************************************************************
Wakeup: 'Début du Programme - reveil du PIC / Affichage Memoire
'*****************************************************************************
'
FLAGS = 0 ' Validation Reset LCD
PORTD = 0
Reveil = 1
LSelect = 0
....
Alain
Bookmarks