以下程序是在16F72上的.但现在要用在16F677上,不只可行吗?怎么改啊?我只看得懂一点汇编(51的),这个看不懂啊.请教了...... ;------------------------I/O CONFIG-------------------------- ; start key <--------------------------->RA0 (I) ; fail lamp<--------------------------->RC0 (0) ; pass lamp<--------------------------->RC1 (0) ; power <--------------------------->RC3 (0) ; LED <--------------------------->RB (I) ;------------------------Systerm CONFIG---------------------- ; XT=4Mhz,Master Reset=Enable ;----------------------------------------------------------------- list p=16f72 #include "p16f72.inc" cnt0 equ 20h cnt1 equ 21h cnt2 equ 22h cnt3 equ 23h temp equ 25h org 00h nop goto main main: banksel ADCON1 movlw 0x06 movwf ADCON1 banksel TRISA movlw 0x01 movwf TRISA movlw 0x0ff movwf TRISB movlw 0x00 movwf TRISC movlw 0x00 movwf PIE1 banksel PORTA clrf PORTA clrf PORTB clrf PORTC movlw 0x00 movwf INTCON movlw 0x00 movwf PIR1 movlw 0x30 movwf T1CON movlw 0x00 movwf TMR1L movlw 0x00 movwf TMR1H movlw 0x0f0 movwf PORTC wait: btfsc PORTA,0 goto $-1 call delay btfsc PORTA,0 goto wait clrf PORTC bsf PORTC,3 clrf PIR1 call delay loopa: clrf TMR1L clrf TMR1H movlw 0x0ff movwf PORTB call delay bsf T1CON,TMR1ON loopa00: clrf TMR1L clrf TMR1H loopa0: btfss PORTB,0 goto loopa10 btfsc PIR1,0 goto stop goto loopa0 loopa10: clrf TMR1L clrf TMR1H loopa1: btfss PORTB,1 goto loopa20 btfsc PIR1,0 goto stop goto loopa1 loopa20: clrf TMR1L clrf TMR1H loopa2: btfss PORTB,2 goto loopa30 btfsc PIR1,0 goto stop goto loopa2 loopa30: clrf TMR1L clrf TMR1H loopa3 btfss PORTB,3 goto loopa40 btfsc PIR1,0 goto stop goto loopa3 loopa40: clrf TMR1L clrf TMR1H loopa4: btfss PORTB,4 goto loopa50 btfsc PIR1,0 goto stop goto loopa4 loopa50: clrf TMR1L clrf TMR1H loopa5: btfss PORTB,5 goto loopa60 btfsc PIR1,0 goto stop goto loopa5 loopa60: clrf TMR1L clrf TMR1H loopa6 btfss PORTB,6 goto loopa70 btfsc PIR1,0 goto stop goto loopa6 loopa70: clrf TMR1L clrf TMR1H loopa7: btfss PORTB,7 goto pass btfsc PIR1,0 goto stop goto loopa7 stop: movlw 0x0f9 movwf PORTC bcf T1CON,0 call delay2s clrf PORTC goto wait pass: movlw 0x0fA movwf PORTC bcf T1CON,0 call delay2s clrf PORTC goto wait delay: movlw 0x0c8 movwf cnt1 lp1: movlw 0x0FA movwf cnt0 lp0: nop decfsz cnt0 goto lp0 decfsz cnt1 goto lp1 retlw 0
delay2s: movlw 0x05 movwf cnt3 movlw 250 movwf cnt2 movwf cnt1 loop3: clrf TMR1H clrf TMR1L decfsz cnt1,f goto loop3 decfsz cnt2,f goto loop3 decfsz cnt3,f goto loop3 bcf PORTC,3 retlw 0
end
|