;********************************************************************* ; * ; External Wakeup on INTB0 * ; * ;********************************************************************* ;* TARGET PIC16C71 ;********************************************************************* ;* @version 0.1, 15 October 2001 ;* @author James Caska ;********************************************************************* list p=16C71 #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 PIC16C71 ;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 PIC16C71 ;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 PIC16C7X ;Config Wiz V0.1, www.virtualbreadboard.com ;========================================== ;======Begin PORT Configuration BSF STATUS,RP0 ;Set Bank1 ;======PORT A MOVLW .31 ;PORTA Configuration Bits MOVWF TRISA ;======PORT B MOVLW .1 ;PORTB Configuration Bits MOVWF TRISB BCF STATUS,RP0 ;Restore Bank0 ;========================================== ;Autogenerated configuration code PIC16C71 ;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 SWAPF PORTA,W ANDLW B'11110000' MOVWF PORTB BTFSC FLAGS,SLEEPNOW GOTO FEELING.SLEEPY GOTO MAIN END