em làm thử một led 8x8 mà nó chạy chậm và giật có ai bít cách khắc phục nó để nó chạy chậm mà ko bị giật(các led sáng nháy chứ ko sáng bình thường) nữa ko
đây la code của em
pác nào bít thì sửa giúp em nha thanks trước
đây la code của em
$MOD51
ORG 00H
MAIN:
MOV DPTR,#DATABASE ;DIA CHI NAP DU LIEU
AAA:
MOV R0,#5 ;TOC DO HIEN KY TU
BBB:
LCALL SCANDATA ;NAP DU LIEU
DJNZ R0,BBB
INC DPTR
MOV A,DPL
MOV R1,DPH
CJNE R1,#02H,AAA ;KIEM TRA KET THUC CHUOI ?
CJNE A,#25H,AAA
SJMP MAIN
SCANDATA:
PUSH ACC
PUSH 00H
PUSH 01H
MOV R0,#00H ;DIA CHI DU LIEU DAU TIEN TRON DATABASE
MOV R1,#01H ;HIEN THI RA COT DAU TIEN
SCAN:
MOV A,R0
MOVC A,@A+DPTR ;NAP DU LIEU TU DATABASE VAO A
MOV P2, A ;HIEN THI RA DONG TUONG UNG
MOV P1,R1 ;HIEN THI RA COT DAU TIEN
LCALL DELAY5MS ;CHUONG TRINH TAO TRE 5 MS
MOV R4,#40H ;CHONG LEM
MOV P1,#00H
INC R0 ;HIEN THI DU LIEU KE TIEP
MOV A,R1 ;CHUYEN SANG COT KE TIEP
RL A
MOV R1,A
CJNE R0,#8H,SCAN ;KIEM TRA QUET COT THU 8 CHUA
POP 01H
POP 00H
POP ACC
RET
DELAY5MS:
PUSH 00H
PUSH 01H
MOV R1,#10
CCC:
MOV R0,#250
DJNZ R0,$
DJNZ R1,CCC
POP 01H
POP 00H
RET
DATABASE:
DB 7H,0DFH,0AFH,77H,0BFH,47H,0FFH,87H,0DFH,0EFH,87H,0 FFH,7H,0DFH,0DFH,0E7H,0FFH,8FH,77H,77H,0AFH,0FFH,7 H,0DFH
DB 0DFH,0E7H,0FFH,0C7H,0AFH,0AFH,47H,0BFH,0CFH,0B7H,0 B7H,0CFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0 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AIN:
MOV DPTR,#DATABASE ;DIA CHI NAP DU LIEU
AAA:
MOV R0,#5 ;TOC DO HIEN KY TU
BBB:
LCALL SCANDATA ;NAP DU LIEU
DJNZ R0,BBB
INC DPTR
MOV A,DPL
MOV R1,DPH
CJNE R1,#02H,AAA ;KIEM TRA KET THUC CHUOI ?
CJNE A,#25H,AAA
SJMP MAIN
SCANDATA:
PUSH ACC
PUSH 00H
PUSH 01H
MOV R0,#00H ;DIA CHI DU LIEU DAU TIEN TRON DATABASE
MOV R1,#01H ;HIEN THI RA COT DAU TIEN
SCAN:
MOV A,R0
MOVC A,@A+DPTR ;NAP DU LIEU TU DATABASE VAO A
MOV P2, A ;HIEN THI RA DONG TUONG UNG
MOV P1,R1 ;HIEN THI RA COT DAU TIEN
LCALL DELAY5MS ;CHUONG TRINH TAO TRE 5 MS
MOV R4,#40H ;CHONG LEM
MOV P1,#00H
INC R0 ;HIEN THI DU LIEU KE TIEP
MOV A,R1 ;CHUYEN SANG COT KE TIEP
RL A
MOV R1,A
CJNE R0,#8H,SCAN ;KIEM TRA QUET COT THU 8 CHUA
POP 01H
POP 00H
POP ACC
RET
DELAY5MS:
PUSH 00H
PUSH 01H
MOV R1,#10
CCC:
MOV R0,#250
DJNZ R0,$
DJNZ R1,CCC
POP 01H
POP 00H
RET
DATABASE:
DB 7H,0DFH,0AFH,77H,0BFH,47H,0FFH,87H,0DFH,0EFH,87H,0 FFH,7H,0DFH,0DFH,0E7H,0FFH,8FH,77H,77H,0AFH,0FFH,7 H,0DFH
DB 0DFH,0E7H,0FFH,0C7H,0AFH,0AFH,47H,0BFH,0CFH,0B7H,0 B7H,0CFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0 FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH, 0FFH,0FFH,0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