call init_tmr1_prg<br /><br />continue_pd <br /> clrwdt <br /> call pd_tmr1_stop_prg<br /> btfss stop_sign ;判断计数器是否停止<br /> goto continue_pd;没有停止则继续关门<br />;********************************************************************<br />pd_tmr1_stop_prg <br /> call delay001s <br /> decfsz r4,1<br /> goto pd_tmr1_stop_prg_ret1<br /> movlw d'100'<br /> movwf r4 <br /> movf tmr1l,0<br /> subwf ys_tmr1l,0<br /> btfss z<br /> goto tmr1_no_stop<br /> movf tmr1h,0<br /> subwf ys_tmr1h,0<br /> btfss z<br /> goto tmr1_no_stop<br /> bsf stop_sign ;计数器的停止标志<br /> goto pd_tmr1_stop_prg_ret<br />tmr1_no_stop <br /> movf tmr1l,0<br /> movwf ys_tmr1l<br /> movf tmr1h,0<br /> movwf ys_tmr1h<br />pd_tmr1_stop_prg_ret1<br /> bcf stop_sign<br />pd_tmr1_stop_prg_ret<br /> return<br /><br />;*******************************************************************<br />;子程序名:定时器1初始化程序'init_tmr1_prg'<br /><br />;***************************************************************<br />init_tmr1_prg<br /> movlw b'00000010' ;工作在计数状态,分频比为1:1 <br /> movwf t1con<br /> clrf intcon<br /> clrf tmr1l<br /> clrf tmr1h <br /> clrf ys_tmr1l<br /> clrf ys_tmr1h<br /> bsf tmr1on ;计数器开始计数<br /> bcf stop_sign ;计数器停止标志位清‘0’<br /> return<br />;****************************************************************** |
|