;********************************************************************* ; * ; External Wakeup on INTB0 * ; * ;********************************************************************* ;* TARGET PIC16F877 ;********************************************************************* ; Waking up while a device is active before falling asleep again ; is a common thing to want to do. This device wakes up and is ; active until ;********************************************************************* ;* @version 0.1, 25 September 2001 ;* @author James Caska ;* @history 0.1, 25 September 2001 Created ;********************************************************************* list p=16F877 #include FLAGS EQU .32 SLEEPNOW EQU .0 ORG .0 GOTO INIT ORG .4 INTERRUPTHANDLER BTFSS PORTB,0 GOTO GoToSleep ;********************************************************************* ; When we wakeup we change the interrupt to look for a falling edge ; to put us back to sleep ;********************************************************************* WakeUp ;========================================== ;Autogenerated configuration code PIC16F877 ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin INTBO Configuration BCF INTCON, INTF ;Clear Interrupt flag BSF STATUS,RP0 ;Access bank 1 BCF OPTION_REG,INTEDG ;Falling Edge Detect BCF STATUS,RP0 ;Restore bank 0 BSF INTCON,INTE ;Enable the INB0 Interrupt BCF FLAGS,SLEEPNOW GOTO EndInterrupt ;********************************************************************* ; When we go to sleep we change the interrup to look for a rising edge ; to wake us up ;********************************************************************* GoToSleep ;========================================== ;Autogenerated configuration code PIC16F877 ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin INTBO Configuration BCF INTCON, INTF ;Clear Interrupt flag BSF STATUS,RP0 ;Access bank 1 BSF OPTION_REG,INTEDG ;Rising Edge Detect BCF STATUS,RP0 ;Restore bank 0 BSF INTCON,INTE ;Enable the INB0 Interrupt BSF FLAGS,SLEEPNOW EndInterrupt RETFIE INIT ;========================================== ;Autogenerated configuration code PIC16F877 ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin PORT Configuration BSF STATUS, RP0 ;PORT TRIS Registers are on page 1 ;======PORT B MOVLW .255 ;PORTB Configuration Bits MOVWF TRISB ;======PORT C MOVLW .255 ;PORTC Configuration Bits MOVWF TRISC ;======PORT D MOVLW .0 ;PORTd Configuration Bits MOVWF TRISD BCF STATUS, RP0 ;Restore Page0 ;========================================== ;Autogenerated configuration code PIC16F877 ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin INTBO Configuration BCF INTCON, INTF ;Clear Interrupt flag BSF STATUS,RP0 ;Access bank 1 BSF OPTION_REG,INTEDG ;Rising Edge Detect BCF STATUS,RP0 ;Restore bank 0 BSF INTCON,INTE ;Enable the INB0 Interrupt BSF INTCON,GIE ;Enable the Interrupts FEELING.SLEEPY SLEEP NOP MAIN MOVF PORTC,W MOVWF PORTD BTFSC FLAGS,SLEEPNOW GOTO FEELING.SLEEPY GOTO MAIN END