📄 lcddrive.s
字号:
.module LcdDrive.c
.area text(rom, con, rel)
; i -> R16,R17
.even
_LCD_Delay::
; #include "SYS_Config.H"
; #include "GUI_Config.H"
;
; INT8U LCD_BGColor;
; INT8U LCD_PenColor;
;
; void LCD_Delay(void)
; {
; INT16U i;
; for(i = 0; i < 50; i ++)
clr R16
clr R17
xjmp L5
L2:
NOP
L3:
subi R16,255 ; offset = 1
sbci R17,255
L5:
cpi R16,50
ldi R30,0
cpc R17,R30
brlo L2
L1:
.dbline 0 ; func end
ret
.even
_LCD_Reset::
; asm("NOP");
; }
;
; void LCD_Reset(void)
; {
; clr_bit(LCD_RST_PORT, LCD_RST); //set RST = L
cbi 0x15,0
; LCD_Delay();
xcall _LCD_Delay
; set_bit(LCD_RST_PORT, LCD_RST); //set RST = H
sbi 0x15,0
; LCD_Delay();
xcall _LCD_Delay
L6:
.dbline 0 ; func end
ret
; cmd -> R16
.even
_LCD_SendCommand::
; }
;
; void LCD_SendCommand(INT8U cmd)
; {
; set_bit(LCD_SIO_DDR, LCD_SIO); //set SDI.DDR = 1
sbi 0x14,2
; clr_bit(LCD_CS_PORT, LCD_CS); //set CS = L
cbi 0x15,1
; clr_bit(LCD_SCL_PORT,LCD_SCL); //set SCK = L
cbi 0x15,3
; clr_bit(LCD_SIO_PORT,LCD_SIO); //send 0, for command
cbi 0x15,2
; set_bit(LCD_SCL_PORT,LCD_SCL); //set SCK = H, latch data
sbi 0x15,3
;
; //Bit 0(MSB)
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x80)
sbrs R16,7
rjmp L8
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L9
L8:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L9:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 1
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x40)
sbrs R16,6
rjmp L10
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L11
L10:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L11:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 2
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x20)
sbrs R16,5
rjmp L12
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L13
L12:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L13:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 3
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x10)
sbrs R16,4
rjmp L14
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L15
L14:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L15:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 4
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x08)
sbrs R16,3
rjmp L16
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L17
L16:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L17:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 5
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x04)
sbrs R16,2
rjmp L18
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L19
L18:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L19:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 6
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x02)
sbrs R16,1
rjmp L20
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L21
L20:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L21:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 7(LSB)
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(cmd & 0x01)
sbrs R16,0
rjmp L22
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L23
L22:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L23:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
L7:
.dbline 0 ; func end
ret
; data -> R16
.even
_LCD_SendData::
; //done
; }
;
;
; void LCD_SendData(INT8U data)
; {
; set_bit(LCD_SIO_DDR, LCD_SIO); //set SDI.DDR = 1
sbi 0x14,2
; clr_bit(LCD_CS_PORT, LCD_CS); //set CS = L
cbi 0x15,1
;
; clr_bit(LCD_SCL_PORT, LCD_SCL); //set SCK = L
cbi 0x15,3
; set_bit(LCD_SIO_PORT, LCD_SIO); //send 1, for data
sbi 0x15,2
; set_bit(LCD_SCL_PORT, LCD_SCL); //set SCK = H, latch data
sbi 0x15,3
;
; //Bit 0(MSB)
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x80)
sbrs R16,7
rjmp L25
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L26
L25:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L26:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 1
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x40)
sbrs R16,6
rjmp L27
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L28
L27:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L28:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 2
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x20)
sbrs R16,5
rjmp L29
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L30
L29:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L30:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 3
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x10)
sbrs R16,4
rjmp L31
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L32
L31:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L32:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 4
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x08)
sbrs R16,3
rjmp L33
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L34
L33:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L34:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 5
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x04)
sbrs R16,2
rjmp L35
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L36
L35:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L36:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 6
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x02)
sbrs R16,1
rjmp L37
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L38
L37:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L38:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
;
; //Bit 7(LSB)
; clr_bit(LCD_SCL_PORT, LCD_SCL);
cbi 0x15,3
; if(data & 0x01)
sbrs R16,0
rjmp L39
; set_bit(LCD_SIO_PORT, LCD_SIO);
sbi 0x15,2
xjmp L40
L39:
; else
; clr_bit(LCD_SIO_PORT, LCD_SIO);
cbi 0x15,2
L40:
; set_bit(LCD_SCL_PORT, LCD_SCL);
sbi 0x15,3
L24:
.dbline 0 ; func end
ret
; i -> R20
.even
_LCD_Init::
xcall push_gset1
; //done
; }
;
; void LCD_Init(void)
; {
; INT8U i;
;
; set_bit(LCD_RST_PORT, LCD_RST); //set RST = H
sbi 0x15,0
; set_bit(LCD_RST_DDR, LCD_RST); //set RST.DDR = 1
sbi 0x14,0
;
; set_bit(LCD_CS_PORT, LCD_CS); //set CS = H
sbi 0x15,1
; set_bit(LCD_CS_DDR, LCD_CS); //set CS.DDR = 1
sbi 0x14,1
;
; clr_bit(LCD_SIO_PORT,LCD_SIO); //set SDI = L
cbi 0x15,2
; clr_bit(LCD_SIO_DDR, LCD_SIO); //set SDI.DDR = 0
cbi 0x14,2
;
; set_bit(LCD_SCL_PORT,LCD_SCL); //set SCK = H
sbi 0x15,3
; set_bit(LCD_SCL_DDR, LCD_SCL); //set SCK.DDR = 1
sbi 0x14,3
;
; clr_bit(LCD_GND_PORT,LCD_GND); //set GND = L
cbi 0x15,4
; set_bit(LCD_GND_DDR, LCD_GND); //set GND.DDR = 1
sbi 0x14,4
;
; set_bit(LCD_VCC_PORT,LCD_VCC); //set VCC = H
sbi 0x15,5
; set_bit(LCD_VCC_DDR, LCD_VCC); //set VCC.DDR = 1
sbi 0x14,5
;
; LCD_Reset();
xcall _LCD_Reset
;
; LCD_SendCommand(0x01); //software reset
ldi R16,1
xcall _LCD_SendCommand
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xc6); //initial escape
ldi R16,198
xcall _LCD_SendCommand
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xb9); //refresh set
ldi R16,185
xcall _LCD_SendCommand
; LCD_SendData(0x00);
clr R16
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xb6); //display control
ldi R16,182
xcall _LCD_SendCommand
; LCD_SendData(0x80);
ldi R16,128
xcall _LCD_SendData
; LCD_SendData(0x80);
ldi R16,128
xcall _LCD_SendData
; LCD_SendData(0x81);
ldi R16,129
xcall _LCD_SendData
; LCD_SendData(0x7f);
ldi R16,127
xcall _LCD_SendData
; LCD_SendData(0x14);
ldi R16,20
xcall _LCD_SendData
; LCD_SendData(84);
ldi R16,84
xcall _LCD_SendData
; LCD_SendData(69);
ldi R16,69
xcall _LCD_SendData
; LCD_SendData(82);
ldi R16,82
xcall _LCD_SendData
; LCD_SendData(67);
ldi R16,67
xcall _LCD_SendData
; LCD_DataOver();
sbi 0x15,1
; LCD_Delay();
xcall _LCD_Delay
;
; LCD_SendCommand(0xb3); //gray scale position set
ldi R16,179
xcall _LCD_SendCommand
; LCD_SendData(1);
ldi R16,1
xcall _LCD_SendData
; LCD_SendData(2);
ldi R16,2
xcall _LCD_SendData
; LCD_SendData(4);
ldi R16,4
xcall _LCD_SendData
; LCD_SendData(8);
ldi R16,8
xcall _LCD_SendData
; LCD_SendData(16);
ldi R16,16
xcall _LCD_SendData
; LCD_SendData(30);
ldi R16,30
xcall _LCD_SendData
; LCD_SendData(40);
ldi R16,40
xcall _LCD_SendData
; LCD_SendData(50);
ldi R16,50
xcall _LCD_SendData
; LCD_SendData(60);
ldi R16,60
xcall _LCD_SendData
; LCD_SendData(70);
ldi R16,70
xcall _LCD_SendData
; LCD_SendData(80);
ldi R16,80
xcall _LCD_SendData
; LCD_SendData(90);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -