# 5-3 8x8矩陣LED控制實習.

## Presentation on theme: "5-3 8x8矩陣LED控制實習."— Presentation transcript:

5-3 8x8矩陣LED控制實習

Sharlight CMD3881300：Dot Matrix Led Display

Column = cathode Column = anode Note: MTS-51 uses common-cathode type.

P2 8051 P0 P1.7 LCM Active low 共陰式 Data flow: P2  Row P0  Column
Manual operation: Turn On SW2_7 LCM DB0~7 EN CLR P1.7

74LS145 Octal Bus Transceiver 2803 HIGH-VOLTAGE, HIGH-CURRENT DARLINGTON ARRAYS

LCM connection (in Section 5-12)
SW2 Instruction “ CLR P1.7 ” makes DB0~7 of the LCM high impedance. P P1 8051

8矩陣LED控制

Program I5_3_1.asm 觀察： 行和列哪個比較亮？Why?
.SYMBOLS ON ORG 0000H JMP MAIN ORG 0050H MAIN: CLR P ; To disable the LCM START: MOV R0,#64 MOV P2,#FFH MOV A,# B NEXT_COL: MOV P0,A CALL DELAY RR A DJNZ R0,NEXT_COL MOV P0,#FFH NEXT_ROW: MOV P2,A DJNZ R0,NEXT_ROW JMP START ;============================== ; DELAY 0.1S DELAY: MOV R6,#200 DL1: MOV R7,#249 DJNZ R7,\$ DJNZ R6,DL1 RET END 觀察： 行和列哪個比較亮？Why? Q: What is the purpose of CLR P1.7 in this program？

8矩陣LED靜態文字顯示(一)

Program I5_3_2.asm comment .SYMBOLS ON ORG 0000H JMP MAIN ORG 0050H
CLR P1.7 START: MOV DPTR,#TABLE MOV R2,# B MOV R1,#0 NEXT: MOV A,R1 MOVC MOV P2,A MOV A,R2 MOV P0,A CALL DELAY RR A MOV R2,A INC R1 CJNE R1,#5,NEXT JMP START ;============================== ; DELAY 5mS DELAY: MOV R6,#10 DL1: MOV R7,#249 DJNZ R7,\$ DJNZ R6,DL1 RET TABLE: DB 3EH,48H,88H,48H,3EH END

8矩陣LED靜態文字顯示(二) A B C . Z 1 2 9

Program I5_3_3.asm comment .SYMBOLS ON ORG 0000H JMP MAIN ORG 0050H
CLR P1.7 START: MOV DPTR,#TABLE MOV R0,#36 ; R0 = TOTAL 36 CHAR. NEXTC: MOV R3,#20 ; R3 = Display time of each char REPEAT: MOV R2,# B ; R2 = COLUMN control MOV R1,#0 NEXT: ; Next column within a character MOV A,R1 ; R1 = Column data pointer MOVC MOV P2,A MOV A,R2 MOV P0,A CALL DELAY RR A MOV R2,A MOV P0,#00H ;TURN OFF LED INC R1 CJNE R1,#5,NEXT DJNZ R3,REPEAT INC DPTR ;NEXT CHAR. INC DPTR DJNZ R0,NEXTC JMP START

Program I5_3_3.asm (cont.) comment
;========================================= TABLE DB 3EH,48H,88H,48H,3EH ;A DB FEH,92H,92H,92H,6CH ;B DB 7CH,82H,82H,82H,44H ;C DB FEH,82H,82H,44H,38H ;D DB FEH,92H,92H,92H,82H ;E DB FEH,90H,90H,90H,80H ;F DB 7CH,82H,92H,94H,5EH ;G DB FEH,10H,10H,10H,FEH ;H DB 00H,82H,FEH,82H,00H ;I DB 04H,02H,82H,FCH,80H ;J DB FEH,10H,28H,44H,82H ;K DB FEH,02H,02H,02H,02H ;L DB FEH,40H,30H,40H,FEH ;M DB FEH,20H,10H,08H,FEH ;N DB 7CH,82H,82H,82H,7CH ;O DB FEH,90H,90H,90H,60H ;P DB 7CH,82H,8AH,84H,7AH ;Q DB FEH,90H,98H,94H,62H ;R DB 64H,92H,92H,92H,4CH ;S DB 80H,80H,FEH,80H,80H ;T DB FCH,02H,02H,02H,FCH ;U DB F8H,04H,02H,04H,F8H ;V DB FCH,02H,1CH,02H,FCH ;W DB C6H,28H,10H,28H,C6H ;X DB E0H,10H,0EH,10H,E0H ;Y DB 86H,8AH,92H,A2H,C2H ;Z DB 7CH,8AH,92H,A2H,7CH ;0 DB 00H,42H,FEH,02H,00H ;1 DB 42H,86H,8AH,92H,62H ;2 DB 84H,82H,A2H,D2H,8CH ;3 DB 18H,28H,48H,FEH,08H ;4 DB E4H,A2H,A2H,A2H,9CH ;5 DB 3CH,52H,92H,92H,0CH ;6 DB 80H,8EH,90H,A0H,C0H ;7 DB 6CH,92H,92H,92H,6CH ;8 DB 60H,92H,92H,94H,78H ;9 ;========================================= ; DELAY 5mS DELAY: MOV R6,#10 DL1: MOV R7,#249 DJNZ R7,\$ DJNZ R6,DL1 RET END

8矩陣LED動態文字顯示

Program I5_3_4.asm comment .SYMBOLS ON ORG 0000H JMP MAIN ORG 0050H
CLR P1.7 START: ; Begin the 224-column cycle MOV DPTR,#TABLE MOV R0,# ; # of displayed column per cycle. = 6 * = 224 NEXTC: MOV R3,# ; Repeating time of each screen REPEAT: MOV R2,# B ; R2 selects the LED COLUMN to display MOV R1,# ; NEXT: MOV A,R ; R1 is the index to the byte in the table MOVC MOV P2,A MOV A,R2 MOV P0,A CALL DELAY RR A MOV R2,A MOV P0,#00H ;TURN OFF LED INC R1 CJNE R1,#8,NEXT DJNZ R3,REPEAT INC DPTR DJNZ R0,NEXTC JMP START

Program I5_3_4.asm 36 char  6 col./char + 8 col. of 00H
;============================================== TABLE DB 00H,00H,00H,00H,00H,00H,00H,00H DB 3EH,48H,88H,48H,3EH,00H ;A DB FEH,92H,92H,92H,6CH,00H ;B DB 7CH,82H,82H,82H,44H,00H ;C DB FEH,82H,82H,44H,38H,00H ;D DB FEH,92H,92H,92H,82H,00H ;E DB FEH,90H,90H,90H,80H,00H ;F DB 7CH,82H,92H,94H,5EH,00H ;G DB FEH,10H,10H,10H,FEH,00H ;H DB 00H,82H,FEH,82H,00H,00H ;I DB 04H,02H,82H,FCH,80H,00H ;J DB FEH,10H,28H,44H,82H,00H ;K DB FEH,02H,02H,02H,02H,00H ;L DB FEH,40H,30H,40H,FEH,00H ;M DB FEH,20H,10H,08H,FEH,00H ;N DB 7CH,82H,82H,82H,7CH,00H ;O DB FEH,90H,90H,90H,60H,00H ;P DB 7CH,82H,8AH,84H,7AH,00H ;Q DB FEH,90H,98H,94H,62H,00H ;R DB 64H,92H,92H,92H,4CH,00H ;S DB 80H,80H,FEH,80H,80H,00H ;T DB FCH,02H,02H,02H,FCH,00H ;U DB F8H,04H,02H,04H,F8H,00H ;V DB FCH,02H,1CH,02H,FCH,00H ;W DB C6H,28H,10H,28H,C6H,00H ;X DB E0H,10H,0EH,10H,E0H,00H ;Y DB 86H,8AH,92H,A2H,C2H,00H ;Z DB 7CH,8AH,92H,A2H,7CH,00H ;0 DB 00H,42H,FEH,02H,00H,00H ;1 DB 42H,86H,8AH,92H,62H,00H ;2 DB 84H,82H,A2H,D2H,8CH,00H ;3 DB 18H,28H,48H,FEH,08H,00H ;4 DB E4H,A2H,A2H,A2H,9CH,00H ;5 DB 3CH,52H,92H,92H,0CH,00H ;6 DB 80H,8EH,90H,A0H,C0H,00H ;7 DB 6CH,92H,92H,92H,6CH,00H ;8 DB 60H,92H,92H,94H,78H,00H ;9 DB 00H,00H,00H,00H,00H,00H,00H,00H 36 char  6 col./char + 8 col. of 00H = 216 col. + 8 col. = 224 col. ;============================================== ; DELAY 2mS DELAY: MOV R6,#4 DL1: MOV R7,#249 DJNZ R7,\$ DJNZ R6,DL1 RET END