深圳市炜烨兴电子有限公司|LCD在线|智能串口液晶
注册| 登录| 通行证 生产液晶显示模块哪家强?Wayeah LCM!专业的液晶显示模块研发、生产厂家!

首页 新闻 字符型| 图形型| 定制型| 智能型| 技术应用 留言反馈 联系方式 |

当前位置液晶应用技术 >> 汇编驱动内置ST7920的字库液晶程序|LCD12864,ST7920,

汇编驱动内置ST7920的字库液晶程序|LCD12864,ST7920,

 

;以下是内置ST7920的KM12864-12中文液晶显示模块的汇编程序
;This program is for KM12864-12
; RS--------P3.3     ;控制定义IO口
; R/W-------P3.1
; E---------P3.0
; DB0~7-----P1    ;8位数据线

RS  EQU P3.3
RW EQU P3.1
E     EQU P3.0

ORG 0000H
AJMP START
ORG 0080H

START:
            mov SP, #67h
            LCALL DELAY
            LCALL DELAY
            LCALL SETUP
            LCALL DEF_CHAR
            MOV A,#80H
            LCALL WRITE_COM
            MOV R3,#8
TEST11: 
            MOV DPTR,#CGRAM1 ;CGRAM TEST
            LCALL WRITE_CGRAM
            DJNZ R3,TEST11
            MOV A,#90H
            LCALL WRITE_COM
            MOV R3,#8
TEST12:
             MOV DPTR,#CGRAM1
            LCALL WRITE_CGRAM
            DJNZ R3,TEST12
            MOV A,#88H
            LCALL WRITE_COM
            MOV R3,#8
TEST13: 
            MOV DPTR,#CGRAM1
            LCALL WRITE_CGRAM
            DJNZ R3,TEST13
            MOV A,#98H
            LCALL WRITE_COM
            MOV R3,#8
TEST14: 
            MOV DPTR,#CGRAM1
            LCALL WRITE_CGRAM
            DJNZ R3,TEST14
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            MOV A,#80H
            LCALL WRITE_COM
            MOV R3,#8
TEST21:
             MOV DPTR,#CGRAM2
            LCALL WRITE_CGRAM
            DJNZ R3,TEST21
            MOV A,#90H
            LCALL WRITE_COM
            MOV R3,#8
TEST22: 
            MOV DPTR,#CGRAM2
            LCALL WRITE_CGRAM
            DJNZ R3,TEST22
            MOV A,#88H
            LCALL WRITE_COM
            MOV R3,#8
TEST23: 
            MOV DPTR,#CGRAM2
            LCALL WRITE_CGRAM
            DJNZ R3,TEST23
            MOV A,#98H
            LCALL WRITE_COM
            MOV R3,#8
TEST24: 
            MOV DPTR,#CGRAM2
            LCALL WRITE_CGRAM
            DJNZ R3,TEST24
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            MOV A,#80H
            LCALL WRITE_COM 
            MOV R3,#8
TEST31: 
            MOV DPTR,#CGRAM3
            LCALL WRITE_CGRAM
            DJNZ R3,TEST31
            MOV A,#90H
            LCALL WRITE_COM
            MOV R3,#8
TEST32: 
            MOV DPTR,#CGRAM3
            LCALL WRITE_CGRAM
            DJNZ R3,TEST32
            MOV A,#88H
            LCALL WRITE_COM 
            MOV R3,#8
TEST33: 
            MOV DPTR,#CGRAM3
            LCALL WRITE_CGRAM
            DJNZ R3,TEST33
            MOV A,#98H
            LCALL WRITE_COM 
            MOV R3,#8
TEST34: 
            MOV DPTR,#CGRAM3
            LCALL WRITE_CGRAM
            DJNZ R3,TEST34
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            MOV A,#80H
            LCALL WRITE_COM 
            MOV R3,#8
TEST41: 
            MOV DPTR,#CGRAM4
            LCALL WRITE_CGRAM
            DJNZ R3,TEST41
            MOV A,#90H
            LCALL WRITE_COM
            MOV R3,#8
TEST42: 
            MOV DPTR,#CGRAM4
            LCALL WRITE_CGRAM
            DJNZ R3,TEST42
            MOV A,#88H
            LCALL WRITE_COM 
            MOV R3,#8
TEST43: 
            MOV DPTR,#CGRAM4
            LCALL WRITE_CGRAM
            DJNZ R3,TEST43
            MOV A,#98H
            LCALL WRITE_COM 
            MOV R3,#8
TEST44:
             MOV DPTR,#CGRAM4
            LCALL WRITE_CGRAM
            DJNZ R3,TEST44
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY

            MOV A,#80H ;WORD TEST
            LCALL WRITE_COM
            MOV DPTR,#TABLE1
            LCALL WRITE_ASCII
            MOV A,#90H
            LCALL WRITE_COM
            MOV DPTR,#TABLE1
            LCALL WRITE_ASCII
            MOV A,#88H ;WORD TEST
            LCALL WRITE_COM
            MOV DPTR,#TABLE1
            LCALL WRITE_ASCII
            MOV A,#98H
            LCALL WRITE_COM
            MOV DPTR,#TABLE1
            LCALL WRITE_ASCII
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            MOV A,#80H
            LCALL WRITE_COM
            MOV DPTR,#CHINESE
            LCALL WRITE_HZ
            MOV A,#90H
            LCALL WRITE_COM
            MOV DPTR,#chinese
            LCALL WRITE_hz
            MOV A,#88H
            LCALL WRITE_COM
            MOV DPTR,#CHINESE
            LCALL WRITE_HZ
            MOV A,#98H
            LCALL WRITE_COM
            MOV DPTR,#chinese
            LCALL WRITE_hz
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
            LCALL DELAY
AAA:   LJMP START

SETUP:    ;初始化液晶控制器
            LCALL DELAY
            MOV A,#01H ;CLEAR DISPLAY
            LCALL WRITE_COM
            MOV A,#00110000B ;FUNCTION SETTING
            LCALL WRITE_COM
            MOV A,#00000010B ;DDRAM SET TO '00H'
            LCALL WRITE_COM
            MOV A,#00000100B ;
            LCALL WRITE_COM
            MOV A,#00001100B ;DISPLAY ON
            LCALL WRITE_COM
            MOV A,#00000001B ;CLEARING SCREEN
            LCALL WRITE_COM
            MOV A,#10000000B ;SET DDRAM ADDRESS
            LCALL WRITE_COM
            RET

WRITE_COM: ;WRIT///cv ;WRITE COMMANDS TO ST7920
            LCALL DELAY1 ;INSTEAD OF CHECKING BF STATE
            CLR RS
            CLR RS
            CLR RW
            CLR RW
            MOV P1,A
            MOV P1,A
            SETB E
            SETB E
            NOP
            NOP
            CLR E
            CLR E
            RET
WRITE_DAT: ;WRITE DISPLAY DATAS TO ST79220
            LCALL DELAY1
            SETB RS
            SETB RS
            CLR RW
            CLR RW
            MOV P1,A
            MOV P1,A
            SETB E
            SETB E
            NOP
            NOP
            CLR E
            CLR E
            RET

DELAY1:
            MOV R7,#010H
D11:   MOV R6,#010H
            DJNZ R6,$
            DJNZ R7,D11
            RET

DELAY:
            MOV R1,#00H
D2:     MOV R2,#00H
            DJNZ R2,$
            DJNZ R1,D2
            RET

DEF_CHAR: ;WRITE TO CGRAM
            MOV A,#01000000B ;SET CGRAM ADDRESS
            LCALL WRITE_COM 
            MOV R3,#8
DEF1: 
            MOV A,#000H
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            MOV A,#0FFH
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            DJNZ R3,DEF1
            MOV R3,#8
DEF2: 
            MOV A,#0AAH
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            MOV A,#0AAH
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            DJNZ R3,DEF2
            MOV R3,#8
DEF3: 
            MOV A,#055H
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            MOV A,#0AAH
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            DJNZ R3,DEF3
            mov R3,#8
DEF4: 
            MOV A,#0FFH
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            LCALL WRITE_DAT
            DJNZ R3,DEF4
            RET
WRITE_ASCII:
            MOV R4,#16
DDDD: CLR A
            MOVC A,@A+DPTR
            LCALL WRITE_DAT
            INC DPTR
            DJNZ R4,DDDD
            RET
WRITE_HZ: ;WRITE 8 CHINESE TO LCD
            MOV R4,#8
DD: CLR A
            MOVC A,@A+DPTR
            INC DPTR
            LCALL WRITE_DAT
            CLR A
            MOVC A,@A+DPTR
            INC DPTR
            LCALL WRITE_DAT
            DJNZ R4,DD
            RET

WRITE_CGRAM: ;CGRAM TESTING
            CLR A
            MOVC A,@A+DPTR
            LCALL WRITE_DAT
            INC DPTR
            CLR A
            MOVC A,@A+DPTR
            LCALL WRITE_DAT
            RET


TABLE1:
DB 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P'
DB 'R','S','T','U','V','W','1','2','3','4','5','6','7','8','9','0'
CGRAM1: DB 000H,000H
CGRAM2: DB 000H,002H
CGRAM3: DB 000H,004H
CGRAM4: DB 000H,006H
CHINESE:
DB 0D2H,0BAH,0BEH,0A7H,0C4H,0A3H,0BFH,0E9H ;液晶模块
DB 0D2H,0BAH,0BEH,0A7H,0C4H,0A3H,0BFH,0E9H ;液晶模块

END
硬件连接图参考:
KM12864-12/KM12232F硬件连接图


这些内容来自LCD在线(http://www.lcdinline.com),如需转载,请联系网站管理QQ:56154083
[来源:深圳市炜烨兴电子有限公司] [作者:wayeah] [日期:09-07-30] [热度:]

评论

© 2004-2015 Wayeah LCM All rights reserved.

Powered by: KingCMS 5.1.0.0812

|2009旧版 | 联系方式 | 付款方式 | 淘宝店|