5-3 8x8矩陣LED控制實習
自我練習 Section 5-3-1 5-3-1-1 請修改程式,將延遲時間改為5 ms,則執行結果將會變為如何? 5-3-2 5-3-2-1 請修改程式,使用5 x 7的字型,讓矩陣LED重覆的連續出現W、E、L、C、O、M、E等七個字,每個字停留的時間為0.5秒。 5-3-2-2 設計程式使LED的顯示好似霹靂燈一般,從行開始,由最左邊整行亮到最右邊,再由最左邊亮回最右邊,然後換列由最上面整列亮到最下面,再由最下面亮回最上面。 5-3-3 5-3-3-1 修改程式使文字均顯示在8 x 8矩陣LED的第四行到第八行位置。 5-3-3-2修改程式使每個文字顯示完畢之後,8 x 8矩陣LED熄滅0.5秒以後,再顯示下一個文字。 5-3-4 5-3-4-1 由8 x 8矩陣LED的右邊開始,依序顯示”WELCOME”的流動文字。 5-3-4-2 將上題”WELCOME”文字的流動方向改成由左邊開始,向右移動。 5-3-4-3 設計一程式,在8 x 8矩陣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. P0 P1 8051
5-3-1 88矩陣LED控制
Program I5_3_1.asm 觀察: 行和列哪個比較亮?Why? .SYMBOLS ON ORG 0000H JMP MAIN ORG 0050H MAIN: CLR P1.7 ; To disable the LCM START: MOV R0,#64 MOV P2,#FFH MOV A,#10000000B 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?
5-3-2 88矩陣LED靜態文字顯示(一)
Program I5_3_2.asm comment .SYMBOLS ON ORG 0000H JMP MAIN ORG 0050H CLR P1.7 START: MOV DPTR,#TABLE MOV R2,#10000000B MOV R1,#0 NEXT: MOV A,R1 MOVC A,@A+DPTR 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
圖5-3-2 5 7 英文字型
5-3-3 88矩陣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,#10000000B ; R2 = COLUMN control MOV R1,#0 NEXT: ; Next column within a character MOV A,R1 ; R1 = Column data pointer MOVC A,@A+DPTR 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
5-3-4 88矩陣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,#224 ; # of displayed column per cycle. = 6 * 36 + 8 = 224 NEXTC: MOV R3,#8 ; Repeating time of each screen REPEAT: MOV R2,#10000000B ; R2 selects the LED COLUMN to display MOV R1,#0 ; NEXT: MOV A,R1 ; R1 is the index to the byte in the table MOVC A,@A+DPTR 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