2232f LCD顯示屏串口寫指令和數(shù)據(jù)的子程序
;以下為串口寫指令和數(shù)據(jù)的子程序:
;Thisprogramisfor12232-9串行
;CS--------P2.0
;SID-------P2.1
;CLK---------P2.2
CSEQUP2.0
SIDEQUP2.1
CLKEQUP2.2
ORG0000H
AJMPSTART
ORG0010H
START:
LCALLSETUP
LCALLDEF_CHAR
MOV A,#80H
LCALLWRITE_COM
MOV R3,#8
TEST11:
MOV DPTR,#CGRAM1;CGRAMTEST
LCALLWRITE_CGRAM
DJNZR3,TEST11
MOV A,#90H
LCALLWRITE_COM
MOV R3,#8
TEST12:
MOV DPTR,#CGRAM1
LCALLWRITE_CGRAM
DJNZR3,TEST12
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
MOV A,#80H
LCALLWRITE_COM
MOV R3,#8
TEST21:
MOV DPTR,#CGRAM2
LCALLWRITE_CGRAM
DJNZR3,TEST21
MOV A,#90H
LCALLWRITE_COM
MOV R3,#8
TEST22:
MOV DPTR,#CGRAM2
LCALLWRITE_CGRAM
DJNZR3,TEST22
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
MOV A,#80H
LCALLWRITE_COM
MOV R3,#8
TEST31:
MOV DPTR,#CGRAM3
LCALLWRITE_CGRAM
DJNZR3,TEST31
MOV A,#90H
LCALLWRITE_COM
MOV R3,#8
TEST32:
MOV DPTR,#CGRAM3
LCALLWRITE_CGRAM
DJNZR3,TEST32
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
MOV A,#80H
LCALLWRITE_COM
MOV R3,#8
TEST41:
MOV DPTR,#CGRAM4
LCALLWRITE_CGRAM
DJNZR3,TEST41
MOV A,#90H
LCALLWRITE_COM
MOV R3,#8
TEST42:
MOV DPTR,#CGRAM4
LCALLWRITE_CGRAM
DJNZR3,TEST42
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
MOV A,#80H;WORDTEST
LCALLWRITE_COM
MOV DPTR,#CHINESE
LCALLWRITE_Hz
MOV A,#90H
LCALLWRITE_COM
MOV DPTR,#TABLE1
LCALLWRITE_ASCII
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
MOV A,#80H
LCALLWRITE_COM
MOV DPTR,#table1
LCALLWRITE_ascii
MOV A,#90H
LCALLWRITE_COM
MOV DPTR,#chinese
LCALLWRITE_hz
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
LCALLDELAY
AAA:LJMPSTART
SETUP:
LCALLDELAY
LCALLDELAY
LCALLDELAY
MOV A,#01H;CLEARDISPLAY
LCALLWRITE_COM
MOV A,#00110000B;FUNCTIONSETTING
LCALLWRITE_COM
MOV A,#00000010B;DDRAMSETTO’00H’
LCALLWRITE_COM
MOV A,#00000100B;
LCALLWRITE_COM
MOV A,#00001100B;DISPLAYON
LCALLWRITE_COM
MOV A,#00000001B;CLEARINGSCREEN
LCALLWRITE_COM
MOV A,#10000000B;SETDDRAMADDRESS
LCALLWRITE_COM
RET
WRITE_COM:
LCALLDELAY1;INSTEADOFCHECKINGBFSTATE
SETBCS
PUSHACC
MOV R0,#8
MOV A,#11111000B
COMM1:
CLRC
RLCA
MOV SID,C
CLRCLK
SETBCLK
DJNZR0,COMM1
POPACC
MOV R5,A
ANLA,#0F0H
MOV R0,#8
COMM2:CLRC
RLCA
MOV SID,C
CLRCLK
SETBCLK
DJNZR0,COMM2
MOV A,R5
SWAPA
ANLA,#0F0H
MOV R0,#8
COMM3:CLRC
RLCA
MOV SID,C
CLRCLK
SETBCLK
DJNZR0,COMM3
CLRCS
RET
WRITE_DAT:
LCALLDELAY1
SETBCS
PUSHACC
MOV R0,#8
MOV A,#11111010B
DATA1:CLRC
RLCA
MOV SID,C
CLRCLK
SETBCLK
DJNZR0,DATA1
POPACC
MOV R5,A
ANLA,#0F0H
MOV R0,#8
DATA2:CLRC
RLCA
MOV SID,C
CLRCLK
SETBCLK
DJNZR0,DATA2
MOV A,R5
SWAPA
ANLA,#0F0H
MOV R0,#8
DATA3:CLRC
RLCA
MOV SID,C
CLRCLK
SETBCLK
DJNZR0,DATA3
CLRCS
RET
DELAY1:
MOV R7,#010H
D11:
MOV R6,#010H
DJNZR6,$
DJNZR7,D11
RET
DELAY:
MOV R1,#00H
D2:
MOV R2,#00H
DJNZR2,$
DJNZR1,D2
RET
DEF_CHAR:;WRITETOCGRAM
MOV A,#01000000B;SETCGRAMADDRESS
LCALLWRITE_COM
MOV R3,#8
DEF1:
MOV A,#000H
LCALLWRITE_DAT
LCALLWRITE_DAT
MOV A,#0FFH
LCALLWRITE_DAT
LCALLWRITE_DAT
DJNZR3,DEF1
MOV R3,#8
DEF2:
MOV A,#0AAH
LCALLWRITE_DAT
LCALLWRITE_DAT
MOV A,#0AAH
LCALLWRITE_DAT
LCALLWRITE_DAT
DJNZR3,DEF2
MOV R3,#8
DEF3:
MOV A,#055H
LCALLWRITE_DAT
LCALLWRITE_DAT
MOV A,#0AAH
LCALLWRITE_DAT
LCALLWRITE_DAT
DJNZR3,DEF3
MOV R3,#8
DEF4:
MOV A,#0FFH
LCALLWRITE_DAT
LCALLWRITE_DAT
LCALLWRITE_DAT
LCALLWRITE_DAT
DJNZR3,DEF4
RET
WRITE_ASCII:
MOV R4,#16
DDDD:CLRA
MOV CA,@A+DPTR
LCALLWRITE_DAT
INCDPTR
DJNZR4,DDDD
RET
WRITE_HZ:;WRITE8CHINESETOLCD
MOV R4,#8
DD:
CLRA
MOV CA,@A+DPTR
INCDPTR
LCALLWRITE_DAT
CLRA
MOV CA,@A+DPTR
INCDPTR
LCALLWRITE_DAT
DJNZR4,DD
RET
WRITE_CGRAM:;CGRAMTESTING
CLRA
MOV CA,@A+DPTR
LCALLWRITE_DAT
INCDPTR
CLRA
MOV CA,@A+DPTR
LCALLWRITE_DAT
RET
TABLE1:
DB0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37
DB0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F
;“這里是16*8點陣的字符代碼”
CGRAM1:DB00H,00H;這里是自造字符地址表
CGRAM2:DB00H,02H
CGRAM3:DB00H,04H
CGRAM4:DB00H,06H
CHINESE:
DB0B3H,0A7H,0B3H,0A8H,0B3H,0A9H,0B3H,0AAH,0B3H,0ABH,0B3H,0ACH
;“這里是16*16點陣的漢字代碼表”
END