di2571.txt ;************************************************************************************************** ; LISTING 1 - PIC12C508 ASSEMBLY PROGRAM ; ; "Timer automatically shuts off," EDN, Aug 17, 2000, pg 128 ; ; http://www.ednmag.com/ednmag/reg/2000/08172000/designideas.htm#17di2 ;*************************************************************************************************** LIST p=12c508 #include cnt_1 equ 0x07 ; cnt_2 equ 0x08 ; cnt_3 equ 0x09 ; cnt_4 equ 0x0a ; cnt_5 equ 0x0b ; temp equ 0x0c ; ; org 0x0 ; ; movlw 0x0f ; tris GPIO ; movlw 0x20 ; movwf GPIO ; turn switch on call delay_100ms ; clrf GPIO ; movf GPIO, W ; read inputs andlw 0x0f ; movwf temp ; btfss STATUS, Z ; goto next_1 ; movlw 0x02 ; 10 seconds movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_1 decfsz temp, F ; goto next_2 ; movlw 0x03 ; 15 seconds movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_2 decfsz temp, F ; goto next_3 ; movlw 0x04 ; 20 seconds movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_3 decfsz temp, F ; goto next_4 ; movlw 0x06 ; 30 seconds movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_4 decfsz temp, F ; goto next_5 ; movlw 0x09 ; 45 seconds movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_5 decfsz temp, F ; goto next_6 ; movlw 0x0c ; 1 minute movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_6 decfsz temp, F ; goto next_7 ; movlw 0x18 ; 2 minutes movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_7 decfsz temp, F ; goto next_8 ; movlw 0x24 ; 3 minutes movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_8 decfsz temp, F ; goto next_9 ; movlw 0x3c ; 5 minutes movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_9 decfsz temp, F ; goto next_10 ; movlw 0x78 ; 10 minutes movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_10 decfsz temp, F ; goto next_11 ; movlw 0xb4 ; 15 minutes movwf cnt_4 ; movlw 0x01 ; movwf cnt_5 ; goto loop ; next_11 decfsz temp, F ; goto next_12 ; movlw 0x68 ; 30 minutes movwf cnt_4 ; movlw 0x02 ; movwf cnt_5 ; goto loop ; next_12 decfsz temp, F ; goto next_13 ; movlw 0x1c ; 45 minutes movwf cnt_4 ; movlw 0x03 ; movwf cnt_5 ; goto loop ; next_13 decfsz temp, F ; goto next_14 ; movlw 0xd0 ; 1 hour movwf cnt_4 ; movlw 0x03 ; movwf cnt_5 ; goto loop ; next_14 decfsz temp, F ; goto next_15 ; movlw 0xa0 ; 2 hours movwf cnt_4 ; movlw 0x06 ; movwf cnt_5 ; goto loop ; next_15 ; movlw 0x70 ; 3 hours movwf cnt_4 ; movlw 0x09 ; movwf cnt_5 ; ; loop ; call delay_5s ; decfsz cnt_4, F ; goto loop ; decfsz cnt_5, F ; goto loop ; turn_off ; movlw 0x10 ; switch off movwf GPIO ; call delay_100ms ; clrf GPIO ; end_lp goto end_lp ; ; delay_100ms ; 0.1 second delay loop clrf cnt_1 ; movlw 0x88 ; movwf cnt_2 ; dly_100ms_lp ; decfsz cnt_1, F ; goto dly_100ms_lp ; decfsz cnt_2, F ; goto dly_100ms_lp ; return ; ; delay_5s ; 5 second delay loop clrf cnt_1 ; movlw 0x85 ; movwf cnt_2 ; movlw 0x19 ; movwf cnt_3 ; dly_5s_lp ; decfsz cnt_1, F ; goto dly_5s_lp ; decfsz cnt_2, F ; goto dly_5s_lp ; decfsz cnt_3, F ; goto dly_5s_lp ; return ; ; end ;