PIC Vietnam

PIC Vietnam (http://www.picvietnam.com/forum/index.php)
-   Những câu hỏi thường gặp (http://www.picvietnam.com/forum/forumdisplay.php?f=54)
-   -   Help (http://www.picvietnam.com/forum/showthread.php?t=1538)

Dolphin 24-09-2007 07:13 AM

Help
 
1 Attachment(s)
Mình đang làm 1 mạch voi Led 7 đoạn, khi nhấn công tắc thì LED sẽ nhảy lên 1 đơn vị. Khi mô phỏng bằng Proteus thì bị lỗi. Sơ đồ mạch: Công tắc nối vào chân RA0 với điện trở kéo lên, LED 7 đoạn nối với PORTB.
Còn đây là đoạn code:

PROCESSOR PIC16f84a
include <p16f84a.inc>


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;---------------------------------------------------------------------------
count res 1
counta res 1
countb res 1
count1 res 1
;---------------------------------------------------------------------------
org 0
goto start
;-------------------------------------------------------------------------
start
BCF STATUS,RP1
BSF STATUS,RP0
CLRF TRISB
movlw 0xFF
movwf TRISA
BCF STATUS,RP0
;-------------------------------------------------------------------------
Clear
movlw b'11000000'
movwf PORTB
clrf count
Scan
btfss PORTA,0
goto counter
goto Scan
;-------------------------------------------------------------------------
counter
movfw count
call table
movwf PORTB
call delay
incf count,0
xorlw d'9'
btfsc STATUS,Z
goto Clear
incf count,1
goto Scan
;-------------------------------------------------------------------------
table
Addwf PCL,1
retlw b'11111001'
retlw b'10100100'
retlw b'10110000'
retlw b'10011001'
retlw b'10010010'
retlw b'10000010'
retlw b'11111000'
retlw b'10000000'
retlw b'10010000'
;-------------------------------------------------------------------------
delay
movlw d'100'
movwf count1
tm11p1
movlw d'199'
movwf counta
movlw d'5'
movwf countb
tm11p2
nop
nop
nop
decfsz counta,f
goto $+2
decfsz countb,f
goto tm11p2
decfsz count1,f
goto tm11p1
return
;-------------------------------------------------------------------------
end

Ai thấy chỗ nào sai chỉ hộ mình tí.


Múi giờ GMT. Hiện tại là 05:47 AM.

Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam