LCD1602显示全部字库字符
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
LCD1602显示全部字库字符、看门狗定时器测试
LCD1602液晶内含有192个字符字库,这个程序是分6屏进行显示,整个显示过程长约7秒,看门狗定时器设置时间为8.38秒,刚好显示完全部字符,修改看门狗就可以看到在显示中途重启,比较直观
LCD_E BIT P3.4 ;LCD片选
LCD_RS BIT P3.5 ;指令、数据位
LCD_RW BIT P3.6 ;读、写位
PORT EQU P0 ;端口定义
WDT_COUNT EQU 0E1H ;看门狗
START: LCALL LCD_INIT
LCALL WDT_INIT
MOV A,#01H ;清屏
LCALL WR_CMD
DISP_LOOP: MOV R0,#06H ;循环计数器
MOV R1,#80H ;LCD地址计数器
MOV R2,#00H ;字符表指针计数器
MOV DPTR,#TAB
WR_DAT_LOOP: MOV A,R1 ;地址命令
LCALL WR_CMD
INC R1 ;地址加一
MOV A,R2 ;表指针
MOVC A,@A+DPTR
LCALL WR_DA T
LCALL DELAY100MS
INC R2 ;表指针加一
CJNE R1,#90H,BIJIAO ;字符是否到16
MOV R1,#0C0H ;到16,换地址
BIJIAO: CJNE R1,#0D0H,WR_DAT_LOOP ;字符数是否到32
MOV R1,#80H ;地址回归
LCALL DELAY1S
MOV A,#1B ;清屏
LCALL WR_CMD
DJNZ R0,WR_DA T_LOOP
MOV WDT_COUNT,#00110111B
LJMP DISP_LOOP
LCD_INIT: MOV A,#111000B ;8位总线
LCALL WR_CMD
MOV A,#10B ;数据指针清零
LCALL WR_CMD
MOV A,#01H ;清屏
LCALL WR_CMD
MOV A,#1111B ;显示开,光标开,闪烁开
LCALL WR_CMD
MOV A,#10000000B ;设置显示地址00H
LCALL WR_CMD
RET
WDT_INIT: MOV WDT_COUNT,#00110111B ;看门狗定时器设置时间1.1秒RET
CHK_BUSY: SETB PORT.7
CLR LCD_RS
SETB LCD_RW
WAIT1: SETB LCD_E
MOV C,PORT.7
JC WAIT1
CLR LCD_E
RET
WR_CMD: LCALL CHK_BUSY
CLR LCD_RS
CLR LCD_RW
SETB LCD_E
MOV PORT,A
CLR LCD_E
RET
WR_DAT: LCALL CHK_BUSY
SETB LCD_RS
CLR LCD_RW
SETB LCD_E
MOV PORT,A
CLR LCD_E
RET
DELAY100MS: MOV R7,#10
DL5: MOV R6,#250
DL4: NOP
NOP
DJNZ R6,DL4
DJNZ R7,DL5
RET
DELAY1S: MOV R7,#10
DL1: MOV R6,#200
DL2: MOV R5,#248
DL3: DJNZ R5,DL3
DJNZ R6,DL2
DJNZ R7,DL1
RET
TAB: DB 20H,21H,22H,23H,24H,25H,26H,27H,28H,29H,2AH,2BH,2CH,2DH,2EH,2FH
DB
30H,31H,32H,33H,34H,35H,36H,37H,38H,39H,3AH,3BH,3CH,3DH,3EH,3FH
DB
40H,41H,42H,43H,44H,45H,46H,47H,48H,49H,4AH,4BH,4CH,4DH,4EH,4FH
DB
50H,51H,52H,53H,54H,55H,56H,57H,58H,59H,5AH,5BH,5CH,5DH,5EH,5FH
DB
60H,61H,62H,63H,64H,65H,66H,67H,68H,69H,6AH,6BH,6CH,6DH,6EH,6FH
DB
70H,71H,72H,73H,74H,75H,76H,77H,78H,79H,7AH,7BH,7CH,7DH,7EH,7FH
DB
0A0H,0A1H,0A2H,0A3H,0A4H,0A5H,0A6H,0A7H,0A8H,0A9H,0AAH,0ABH,0ACH,0ADH,0 AEH,0AFH
DB
0B0H,0B1H,0B2H,0B3H,0B4H,0B5H,0B6H,0B7H,0B8H,0B9H,0BAH,0BBH,0BCH,0BDH,0BE H,0BFH
DB
0C0H,0C1H,0C2H,0C3H,0C4H,0C5H,0C6H,0C7H,0C8H,0C9H,0CAH,0CBH,0CCH,0CDH,0CE H,0CFH
DB
0D0H,0D1H,0D2H,0D3H,0D4H,0D5H,0D6H,0D7H,0D8H,0D9H,0DAH,0DBH,0DCH,0DDH,0 DEH,0DFH
DB
0E0H,0E1H,0E2H,0E3H,0E4H,0E5H,0E6H,0E7H,0E8H,0E9H,0EAH,0EBH,0ECH,0EDH,0EEH ,0EFH
DB
0F0H,0F1H,0F2H,0F3H,0F4H,0F5H,0F6H,0F7H,0F8H,0F9H,0FAH,0FBH,0FCH,0FDH,0FEH,0 FFH
END