我用12F629写了一个产生30秒脉冲波的程序。<br /><br />GP3脚接一个按键,按下之后,在GP0脚上产生一个<br /><br />30秒钟周期为250毫秒的脉冲波。<br /><br />可是按键按下之后,只产生一个周期的脉冲波。<br /><br />请高手指教。程序如下:<br /><br />trisio equ 85h<br />option_reg equ 81h<br />wpu equ 95h<br />tmr0 equ 01h<br />status EQU 03H<br />gpio EQU 05H<br />intcon equ 0bh<br />cmcon equ 19h<br />rp0 equ 5h<br />rp1 equ 6h<br />c equ 0<br />data1 equ 7h<br />data2 equ 8h<br />count1 equ 9h<br />count2 equ 11h<br /><br />org 00h<br />main nop<br /> bcf status,rp0<br /> bcf status,rp1<br /> movlw 1fh<br /> movwf cmcon<br /> bsf status,rp0<br /> bcf status,rp1<br /> <br /> movlw 08h ;5入0出<br /> movwf trisio<br /> movlw 37h<br /> movwf wpu<br /> bcf status,rp0<br /> clrf gpio<br /> movlw 01h ;5高电平<br /> movwf gpio<br /> clrf intcon<br /> ;goto $<br />check btfss gpio,3<br /> goto check<br /> call delay<br /> btfss gpio,3<br /> goto check<br />chshh <br /> clrf count1<br /> clrf count2<br /> ;clrf tmr0<br /> MOVLW 0ch<br /> MOVWF tmr0<br /> movlw 87h<br /> movwf option_reg<br />del30 movlw 0ffh<br /> subwf tmr0,0<br /> btfss status,c<br /> goto del30<br /> clrwdt<br /> movlw 0ch<br /> movwf tmr0 ;<br /> incf count1,1<br /> movlw 02h <br /> subwf count1,0<br /> btfss status,c<br /> goto del30<br /> clrf count1 ;125ms<br /> movlw 01h<br /> xorwf gpio,1<br /> incf count2,1<br /> movlw 0f0h<br /> subwf count2,0<br /> btfss status,c<br /> goto del30<br /> clrf count2<br /> movlw 01h<br /> movwf gpio<br /> goto check<br /> ;goto $<br /> <br /><br /> <br />delay movlw 0dh<br /> movwf data1<br />lp0 movlw 0ffh<br /> movwf data2<br />lp1 decfsz data2,1<br /> goto lp1<br /> decfsz data1,1<br /> goto lp0<br /> return<br /> end <br /><br /> <br /> <br /> <br /> |
|