Hi,
Here is one way to do that ( Pic is a 18F2520 )
Here, the processor stops and restarts @ the line after the "@Sleep" command, because GIE bit has been disabled.Code:Sommeil: LCDOUT $FE,2, "BYE-BYE " For I = 8 to 0 Step -1 'Animation arret LCDOUT $FE,$C0,REP "*"\I," " ' ... 4s PAUSE 500 NEXT I PORTB.4 = 0 'Ports LCD à 0 PORTB.5 = 0 PORTC.7 = 0 ' PortC à 0 PORTC.6 = 0 PORTC.5 = 0 PORTC.4 = 0 AlLCD = 1 ' Coupure LCD AlRef = 0 ' Coupure Vref ADCON0.0 = 0 ' Désactivation ADC 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 Alim = 0 'Coupure alimentation Signal = 0 'Extinction voyant régime @ SLEEP @ Nop ' Redémarrage par mise du contact sans coupure générale ' Arret par décharge capa alim. INTCON3.3 = 0 'Neutralisation INT1 INTCON3.0 = 0 'Reset Flag INT1 Alim = 1 'Remise alimentation si remise contact rapide. '***************************************************************************** Wakeup: 'Début du Programme - reveil du PIC / Affichage Memoire '***************************************************************************** ' FLAGS = 0 ' Validation Reset LCD PORTB.4 = 0 'Ports LCD à 0 PORTB.5 = 0 PORTC.7 = 0 ' PortC.4-7 à 0 PORTC.6 = 0 PORTC.5 = 0 PORTC.4 = 0 Reveil = 1 LSelect = 0 GOTO Load 'Rechargement mémoires et Affichage de Départ
The @NOP is highly recommended here ...
IF GIE is not disabled , processor will jump to the Interrupt stubb ...
Alain




Bookmarks