12864中文字库液晶模块编程资料
目前市场上的12864中文字库液晶模块,大部分所用的驱动IC都是ST7920的,针对这类型的,下面介绍下编程资料,本人习惯用汇编的,供工程师朋友参考。
12864中文字库液晶模块的接口类型,可以选择串口,也可选择并口。先给大家提供下串口程序:
;st7920 This program is for 12864-12
; RS--------P3.3
; R/W-------P3.1
; E---------P3.0
CS EQU P3.3
SID EQU P3.1
SCLK 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
AJMP START
;LCALL DELAY
AJMP START
SETUP:
;初始化
MOV DPTR,#0000H
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
MOV A,#30H
LCALL WRITE_COM
LCALL DELAY1
MOV A,#30H
LCALL WRITE_COM
MOV A,#0CH
LCALL WRITE_COM
MOV A,#01H
LCALL WRITE_COM
MOV A,#06H
LCALL WRITE_COM
RET
;WRITE_COM: ;WRIT///cv
;WRITE COMMANDS TO ST7920
;LCALL DELAY1 ;INSTEAD OF CHECKING BF STATE
;LCALL DELAY
;LCALL DELAY
WRITE_COM: SETB CS
SETB SID
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.7
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.6
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.5
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.4
MOV SID,C
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.3
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.2
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.1
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.0
MOV SID,C
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR CS
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
RET
WRITE_DAT: SETB CS
SETB SID
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
SETB SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.7
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.6
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.5
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.4
MOV SID,C
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.3
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.2
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.1
MOV SID,C
NOP
SETB SCLK
CLR SCLK
MOV C,ACC.0
MOV SID,C
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR SID
NOP
SETB SCLK
CLR SCLK
CLR CS
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
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,0D2H,0BAH,0BEH,0A7H ;液晶模块
DB 0B0H,0A1H,0B0H,0A2H,0B0H,0A1H,0B0H,0A2H ;液晶模块
TAB_BMP1:
END
以上的资料仅供参考,更多信息,请咨询深圳驰宇微科技工程师
联系方式如下:
蒋工Tel:+86-755- 29446830
Mobile:13640934827
http://www.cywlcd.com/cjwtj.html
http://map.baidu.com/?newmap=1&s=inf%26uid%3Da52aa43e5a4db9839fec2b79%26wd%3D%E9%A9%B0%E5%AE%87%E5%BE%AE%E7%A7%91%E6%8A%80%26all%3D1%26c%3D340&from=alamap&tpl=map_singlepoint
Add:深圳市龙华新区大浪街道华宁路伟华达工业园C1栋七楼
驰宇微首页 | 图形点阵液晶模块 | 中文字库液晶模块 | 字符型液晶模块 | 段码液晶模块 | 产品列表 | 站点地图 | 关于驰宇微
公司名称: 深圳驰宇微科技有限公司
备案号:粤ICP备14047421号
公司地址:深圳市龙华区大浪街道华昌路241号鸿源工业区E栋5层
公司电话:0755-29446830 13640934827
邮 箱:18926046819@163.com Q Q:577895076
版权归深圳驰宇微科技所有