PDA

View Full Version : can su giup do ve PIC16C745


mhuong
12-09-2007, 10:56 AM
CHao cac ban ,

Minh đang làm project cuối năm về PIC6C745.
Minh phai viet cai code ma dung asembly language using MPLab version 7.2.
De la the nay.Nếu công tac 1 được ấn thì dèn LED sẽ dược sáng lên. Nếu công tắc 2 ấn thì đèn sẽ tắt di.
Code của tớ là :
Here is myCode:

MAIN org 00000030h

Start
bsf STATUS,RP0 ; select bank1
clrf PORTB ; clear PORTB output latch
movlw b'00000110' ; Set all pins PORTB 1,2 as Input
MOVWF TRISB ;

ON
btfsc PORTB,1 ; Has S2 been press? (Normally high,goes low when pressed.)
goto ON ; No, go back check again
movlw b'00000001' ; move it from register 1 to w.
movwf PORTB ; move it to PORTB to light up the LED

OFF
btfsc PORTB,2 ; Has key been press? (Normally high, goes low when pressed.)
goto OFF ; No, check again
movlw b'00000000' ; move it from register 1 to w.
movwf PORTB ; OFF the LED

DebounceA
btfss PORTB,1 ; Has key been released?
goto DebounceA ; No, wait again
goto Start ; Loop again
end ; directive indicates end of code

cac ban xem cho minh code da dung chua nhe.
Cam on cac ban nhieu