list p=12f629 ; list directive to define processor #include ; processor specific variable definitions __CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _MCLRE_OFF & _INTRC_OSC_NOCLKOUT ;***** VARIABLE DEFINITIONS w_temp EQU 0x0C ; variable used for context saving status_temp EQU 0x0D ; variable used for context saving tmp EQU 0x0F CNT0 EQU 0x20 CNT1 EQU 0x21 CNT2 EQU 0x22 CNT3 EQU 0x23 CNT4 EQU 0x24 w_temp0 EQU 0x25 w_temp1 EQU 0x26 w_temp2 EQU 0x27 w_temp3 EQU 0x28 w_temp4 EQU 0x29 ORG 0x000 ; processor reset vector goto main ; go to beginning of program main CALL INIT CALL CHK_TMP CALL CHK_BATT GOTO $-2 INIT BSF STATUS,RP0 ; change to bank1 MOVLW 0x03 MOVWF TRISIO BCF STATUS,RP0 BSF GPIO, GPIO2 BCF GPIO, GPIO4 BCF GPIO, GPIO5 CALL Sleep1s BCF GPIO, GPIO2 BSF GPIO, GPIO4 BSF GPIO, GPIO5 RETURN CHK_TMP ; MOVLW 0xa6 ; MOVLW 0x81 ; 1.406V 42.7C MOVLW 0x80 ; 1.25V 60.6C BANKSEL VRCON MOVWF VRCON MOVLW 0x0e BANKSEL CMCON MOVWF CMCON CALL Sleep1ms ;BSF GPIO,GPIO4 ;BCF GPIO,GPIO2 BTFSS CMCON, COUT RETURN BCF GPIO,GPIO4 BSF GPIO,GPIO2 RETURN CHK_BATT MOVLW 0xaf BANKSEL VRCON MOVWF VRCON MOVLW 0x06 BANKSEL CMCON MOVWF CMCON CALL Sleep1ms BSF GPIO, GPIO5 BTFSS CMCON, COUT RETURN CALL Sleep1ms BTFSS CMCON, COUT RETURN CALL Sleep1ms BTFSS CMCON, COUT RETURN CALL Sleep1ms BTFSS CMCON, COUT RETURN CALL Sleep1ms BTFSS CMCON, COUT RETURN CALL Sleep1ms BTFSS CMCON, COUT RETURN BCF GPIO,GPIO5 CALL Sleep1s RETURN ;***** sleep routines ***** Sleep1s: MOVWF w_temp0 MOVLW D'10' MOVWF CNT0 Loop0: CALL Sleep100ms DECFSZ CNT0, F GOTO Loop0 CALL Sleep1ms CALL Sleep1ms CALL Sleep1ms RETLW w_temp0 Sleep100ms: MOVWF w_temp1 MOVLW D'97' MOVWF CNT1 Loop1: CALL Sleep1ms DECFSZ CNT1, F GOTO Loop1 RETLW w_temp1 Sleep1ms: MOVWF w_temp2 MOVLW D'200' MOVWF CNT2 Loop2: NOP NOP DECFSZ CNT2, F GOTO Loop2 RETLW w_temp2 END