📄 lcd.s
字号:
.module lcd.c
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\12864-ICC/delay.h
.dbfunc e delay_nus _delay_nus fV
; tt -> R16
.even
_delay_nus::
.dbline -1
.dbline 28
; #include <iom16v.h>
; #include "lcd.h"
; #include "delay.h"
; #include "font.h"
; unsigned char CurOffset,CurRow,CurPage,CurCol;//当前指针位置
;
; //--------------复位函数---------------------
; void LCD_reset(void)
; {
; LCD_RST_DDR |= LCD_RST_BIT;
; CLEAR_LCD_RST;
; delay_nms(10);
; SET_LCD_RST;
; }
;
; //-------------忙信号检测函数----------------
; void LCD_BUSY(unsigned char lr) //判断忙标志
; {
; //unsigned char status;
; asm("cli");
; if(lr==RIGHT)
; {
; CLEAR_LCD_CS2; //cs2=0
; SET_LCD_CS1; //cs1=1
; }
; else
; {
; SET_LCD_CS2; //cs2=1
.dbline 29
; CLEAR_LCD_CS1; //cs1=0
_L2: subi R16,1
.dbline 30
; }
nop
brne _L2
.dbline 32
; SET_LCD_CMD;
; LCD_DIR_PORT = 0x00;
nop
.dbline 33
; LCD_OP_PORT = 0xff;
ret
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbsym r tt 16 c
.dbend
.dbfunc e delay_1ms _delay_1ms fV
; i -> R16,R17
.even
_delay_1ms::
.dbline -1
.dbline 44
; SET_LCD_READ;
; SET_LCD_E;
; delay_nus(250);
; delay_nus(250);
; while((LCD_IP_PORT) & LCD_STATUS_BUSY)
; {
; CLEAR_LCD_E;
; delay_nus(250);
; delay_nus(250);
; SET_LCD_E;
; delay_nus(250);
.dbline 46
clr R16
clr R17
xjmp L6
L3:
.dbline 46
L4:
.dbline 46
subi R16,255 ; offset = 1
sbci R17,255
L6:
.dbline 46
; delay_nus(250);
; }
cpi R16,58
ldi R30,2
cpc R17,R30
brlo L3
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbend
.dbfunc e delay_nms _delay_nms fV
; i -> R20,R21
; num -> R22,R23
.even
_delay_nms::
xcall push_gset2
movw R22,R16
.dbline -1
.dbline 50
; CLEAR_LCD_E;
; SET_LCD_WRITE;
; LCD_OP_PORT = 0xff;
; asm("sei");
.dbline 52
clr R20
clr R21
xjmp L11
L8:
.dbline 52
xcall _delay_1ms
L9:
.dbline 52
subi R20,255 ; offset = 1
sbci R21,255
L11:
.dbline 52
;
; }
cp R20,R22
cpc R21,R23
brlo L8
.dbline -2
L7:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r num 22 i
.dbend
.area lit(rom, con, rel)
_ASC_16::
.byte 49
.byte 0,0
.byte 8,8
.byte 252,0
.byte 0,0
.byte 0,0
.byte 4,4
.byte 7,4
.byte 4,0
.byte 50
.byte 0,0
.byte 8,4
.byte 132,'D
.byte 56,0
.byte 0,0
.byte 6,5
.byte 4,4
.byte 4,0
.byte 51
.byte 0,0
.byte 8,4
.byte 'D,'D
.byte 184,0
.byte 0,0
.byte 2,4
.byte 4,4
.byte 3,0
.byte 52
.byte 0,0
.byte 128,96
.byte 24,252
.byte 0,0
.byte 0,0
.byte 1,1
.byte 5,7
.byte 5,0
.byte 53
.byte 0,0
.byte 124,'D
.byte 'D,'D
.byte 132,0
.byte 0,0
.byte 2,4
.byte 4,4
.byte 3,0
.byte 54
.byte 0,0
.byte 240,'H
.byte 'D,'D
.byte 128,0
.byte 0,0
.byte 3,4
.byte 4,4
.byte 3,0
.byte 55
.byte 0,0
.byte 12,4
.byte 132,'d
.byte 28,0
.byte 0,0
.byte 0,6
.byte 1,0
.byte 0,0
.byte 56
.byte 0,0
.byte 184,'D
.byte 'D,'D
.byte 184,0
.byte 0,0
.byte 3,4
.byte 4,4
.byte 3,0
.byte 57
.byte 0,0
.byte 56,'D
.byte 'D,'D
.byte 248,0
.byte 0,0
.byte 0,4
.byte 4,2
.byte 1,0
.byte 48
.byte 0,0
.byte 248,4
.byte 4,4
.byte 248,0
.byte 0,0
.byte 3,4
.byte 4,4
.byte 3,0
.byte 46
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 4,0
.byte 0,0
.byte 44
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,8
.byte 4,0
.byte 0,0
.byte 58
.byte 0,0
.byte 0,0
.byte 32,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 4,0
.byte 0,0
.byte 59
.byte 0,0
.byte 0,0
.byte 32,0
.byte 0,0
.byte 0,0
.byte 0,8
.byte 4,0
.byte 0,0
.byte 45
.byte 0,128
.byte 128,128
.byte 128,128
.byte 128,128
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 95
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 16,16
.byte 16,16
.byte 16,16
.byte 16,16
.byte 'A
.byte 0,0
.byte 128,'d
.byte 28,96
.byte 128,0
.byte 0,4
.byte 7,5
.byte 1,5
.byte 7,4
.byte 'B
.byte 0,4
.byte 252,'D
.byte 'D,'D
.byte 'D,184
.byte 0,4
.byte 7,4
.byte 4,4
.byte 4,3
.byte 'C
.byte 0,240
.byte 8,4
.byte 4,4
.byte 4,8
.byte 0,1
.byte 2,4
.byte 4,4
.byte 4,2
.byte 'D
.byte 0,4
.byte 252,4
.byte 4,4
.byte 8,240
.byte 0,4
.byte 7,4
.byte 4,4
.byte 2,1
.byte 'E
.byte 0,4
.byte 252,'D
.byte 'D,228
.byte 4,12
.byte 0,4
.byte 7,4
.byte 4,4
.byte 4,6
.byte 'F
.byte 0,4
.byte 252,'D
.byte 'D,228
.byte 4,12
.byte 0,4
.byte 7,4
.byte 4,0
.byte 0,0
.byte 32
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 61
.byte 0,0
.byte 160,160
.byte 160,160
.byte 160,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 40
.byte 0,0
.byte 0,224
.byte 24,4
.byte 0,0
.byte 0,0
.byte 0,3
.byte 12,16
.byte 0,0
.byte 41
.byte 0,0
.byte 0,4
.byte 24,224
.byte 0,0
.byte 0,0
.byte 0,16
.byte 12,3
.byte 0,0
.byte 'V
.byte 0,4
.byte 60,196
.byte 0,196
.byte 60,4
.byte 0,0
.byte 0,1
.byte 6,1
.byte 0,0
.byte 'm
.byte 0,32
.byte 224,32
.byte 192,32
.byte 192,0
.byte 0,4
.byte 7,0
.byte 7,0
.byte 7,4
.byte 'H
.byte 0,4
.byte 252,'D
.byte 64,'D
.byte 252,4
.byte 0,4
.byte 7,4
.byte 0,4
.byte 7,4
.byte 42
.byte 144,144
.byte 96,252
.byte 96,144
.byte 144,0
.byte 0,0
.byte 0,3
.byte 0,0
.byte 0,0
.dbfile C:\DOCUME~1\Administrator\桌面\12864-ICC/font.h
.dbstruct 0 17 typFNT_ASC16
.dbfield 0 Index A[1:1]c
.dbfield 1 Msk A[16:16]c
.dbend
.dbsym e ASC_16 _ASC_16 A[510:30]kS[typFNT_ASC16]
_GB_16::
.byte 210,186
.byte 25,226
.byte 20,'B
.byte 242,46
.byte 'r,143
.byte 170,'z
.byte 2,0
.byte 1,7
.byte 0,0
.byte 7,4
.byte 4,2
.byte 1,2
.byte 4,0
.byte 190,167
.byte 0,192
.byte 64,95
.byte 213,21
.byte 213,'U
.byte 95,64
.byte 192,0
.byte 0,7
.byte 5,5
.byte 7,0
.byte 7,5
.byte 5,5
.byte 7,0
.byte 207,212
.byte 0,64
.byte 159,21
.byte 213,21
.byte 213,21
.byte 31,192
.byte 0,0
.byte 4,4
.byte 5,4
.byte 7,4
.byte 7,6
.byte 5,4
.byte 4,0
.byte 202,190
.byte 16,18
.byte 146,'R
.byte 18,242
.byte 18,18
.byte 'S,146
.byte 16,0
.byte 2,1
.byte 0,4
.byte 4,7
.byte 0,0
.byte 0,0
.byte 3,0
.byte 181,196
.byte 252,'D
.byte 'F,'E
.byte 252,16
.byte 44,199
.byte 4,4
.byte 252,0
.byte 7,2
.byte 2,2
.byte 7,0
.byte 0,4
.byte 4,4
.byte 3,0
.byte 181,218
.byte 4,234
.byte 171,174
.byte 170,252
.byte 170,171
.byte 174,186
.byte 130,0
.byte 4,4
.byte 2,1
.byte 0,7
.byte 0,2
.byte 2,2
.byte 1,0
.byte 210,187
.byte 32,32
.byte 32,32
.byte 32,32
.byte 32,32
.byte 32,48
.byte 32,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 208,208
.byte 'H,36
.byte 243,8
.byte 9,9
.byte 9,9
.byte 249,9
.byte 8,0
.byte 0,0
.byte 7,0
.byte 0,4
.byte 4,4
.byte 7,0
.byte 0,0
.byte 182,254
.byte 0,4
.byte 4,4
.byte 4,4
.byte 4,4
.byte 6,4
.byte 0,0
.byte 2,2
.byte 2,2
.byte 2,2
.byte 2,2
.byte 2,2
.byte 2,0
.byte 200,253
.byte 0,2
.byte 34,34
.byte 34,34
.byte 34,34
.byte 35,2
.byte 0,0
.byte 4,4
.byte 4,4
.byte 4,4
.byte 4,4
.byte 4,6
.byte 4,0
.byte 203,196
.byte 0,255
.byte 129,'A
.byte 63,1
.byte 1,255
.byte 129,129
.byte 255,0
.byte 0,7
.byte 2,2
.byte 2,2
.byte 2,2
.byte 2,2
.byte 7,0
.byte 206,229
.byte 0,17
.byte 17,145
.byte 127,17
.byte 17,17
.byte 241,1
.byte 0,0
.byte 4,4
.byte 4,7
.byte 4,4
.byte 4,4
.byte 7,4
.byte 4,0
.dbstruct 0 26 typFNT_GB16
.dbfield 0 Index A[2:2]c
.dbfield 2 Msk A[24:24]c
.dbend
.dbsym e GB_16 _GB_16 A[312:12]kS[typFNT_GB16]
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\12864-ICC/font.h
.dbfile C:\DOCUME~1\Administrator\桌面\12864-ICC\lcd.c
.dbfunc e LCD_reset _LCD_reset fV
.even
_LCD_reset::
.dbline -1
.dbline 9
.dbline 10
sbi 0x17,5
.dbline 11
cbi 0x18,5
.dbline 12
ldi R16,10
ldi R17,0
xcall _delay_nms
.dbline 13
sbi 0x18,5
.dbline -2
L12:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_BUSY _LCD_BUSY fV
; lr -> R20
.even
_LCD_BUSY::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 18
.dbline 20
cli
.dbline 21
cpi R20,1
brne L14
.dbline 22
.dbline 23
cbi 0x18,4
.dbline 24
sbi 0x18,3
.dbline 25
xjmp L15
L14:
.dbline 27
.dbline 28
sbi 0x18,4
.dbline 29
cbi 0x18,3
.dbline 30
L15:
.dbline 31
cbi 0x18,0
.dbline 32
clr R2
out 0x1a,R2
.dbline 33
ldi R24,255
out 0x1b,R24
.dbline 34
sbi 0x18,1
.dbline 35
sbi 0x18,2
.dbline 36
ldi R16,250
xcall _delay_nus
.dbline 37
ldi R16,250
xcall _delay_nus
xjmp L17
L16:
.dbline 39
.dbline 40
cbi 0x18,2
.dbline 41
ldi R16,250
xcall _delay_nus
.dbline 42
ldi R16,250
xcall _delay_nus
.dbline 43
sbi 0x18,2
.dbline 44
ldi R16,250
xcall _delay_nus
.dbline 45
ldi R16,250
xcall _delay_nus
.dbline 46
L17:
.dbline 38
sbic 0x19,7
rjmp L16
.dbline 47
cbi 0x18,2
.dbline 48
cbi 0x18,1
.dbline 49
ldi R24,255
out 0x1b,R24
.dbline 50
sei
.dbline -2
L13:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r lr 20 c
.dbend
.dbfunc e write_LCD _write_LCD fV
; data -> y+4
; cd -> R20
; lr -> R22
.even
_write_LCD::
xcall push_gset2
mov R20,R18
mov R22,R16
.dbline -1
.dbline 56
;
; //------------写指令(数据)函数---------------------
; void write_LCD(unsigned char lr,unsigned char cd,unsigned char data)
; {
.dbline 57
; asm("cli");
cli
.dbline 58
; LCD_BUSY(lr);
mov R16,R22
xcall _LCD_BUSY
.dbline 59
; if(cd==CMD)
tst R20
brne L20
.dbline 60
; SET_LCD_CMD;
cbi 0x18,0
xjmp L21
L20:
.dbline 62
; else
; SET_LCD_DATA;
sbi 0x18,0
L21:
.dbline 63
; SET_LCD_WRITE;
cbi 0x18,1
.dbline 64
; SET_LCD_E;
sbi 0x18,2
.dbline 65
; LCD_DIR_PORT = 0xff;
ldi R24,255
out 0x1a,R24
.dbline 66
; LCD_OP_PORT = data;
ldd R0,y+4
out 0x1b,R0
.dbline 67
; delay_nus(250);
ldi R16,250
xcall _delay_nus
.dbline 68
; delay_nus(250);
ldi R16,250
xcall _delay_nus
.dbline 69
; CLEAR_LCD_E;
cbi 0x18,2
.dbline 70
; LCD_OP_PORT = 0xff;
ldi R24,255
out 0x1b,R24
.dbline 71
; asm("sei");
sei
.dbline -2
L19:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l data 4 c
.dbsym r cd 20 c
.dbsym r lr 22 c
.dbend
.dbfunc e read_LCD _read_LCD fc
; data -> R20
; lr -> R22
.even
_read_LCD::
xcall push_gset2
mov R22,R16
.dbline -1
.dbline 77
;
; }
;
; //--------------读数据函数-------------------
; unsigned char read_LCD(unsigned char lr)
; {
.dbline 80
; unsigned char data;
;
; asm("cli");
cli
.dbline 81
; LCD_BUSY(lr);
mov R16,R22
xcall _LCD_BUSY
.dbline 82
; SET_LCD_DATA;
sbi 0x18,0
.dbline 83
; LCD_DIR_PORT = 0x00;
clr R2
out 0x1a,R2
.dbline 84
; LCD_OP_PORT = 0xff;
ldi R24,255
out 0x1b,R24
.dbline 85
; SET_LCD_READ;
sbi 0x18,1
.dbline 86
; SET_LCD_E;
sbi 0x18,2
.dbline 87
; delay_nms(1);
ldi R16,1
ldi R17,0
xcall _delay_nms
.dbline 88
; data=LCD_IP_PORT;
in R20,0x19
.dbline 89
; CLEAR_LCD_E;
cbi 0x18,2
.dbline 90
; SET_LCD_WRITE;
cbi 0x18,1
.dbline 92
;
; LCD_BUSY(lr);
mov R16,R22
xcall _LCD_BUSY
.dbline 93
; SET_LCD_DATA;
sbi 0x18,0
.dbline 94
; LCD_DIR_PORT = 0x00;
clr R2
out 0x1a,R2
.dbline 95
; LCD_OP_PORT = 0xff;
ldi R24,255
out 0x1b,R24
.dbline 96
; SET_LCD_READ;
sbi 0x18,1
.dbline 97
; SET_LCD_E;
sbi 0x18,2
.dbline 98
; delay_nus(250);
ldi R16,250
xcall _delay_nus
.dbline 99
; delay_nus(250);
ldi R16,250
xcall _delay_nus
.dbline 100
; data=LCD_IP_PORT;
in R20,0x19
.dbline 101
; CLEAR_LCD_E;
cbi 0x18,2
.dbline 102
; SET_LCD_WRITE;
cbi 0x18,1
.dbline 103
; delay_nus(250);
ldi R16,250
xcall _delay_nus
.dbline 104
; delay_nus(250);
ldi R16,250
xcall _delay_nus
.dbline 105
; asm("sei");
sei
.dbline 106
; return data;
mov R16,R20
.dbline -2
L22:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r data 20 c
.dbsym r lr 22 c
.dbend
.dbfunc e set_start_line_L _set_start_line_L fV
; line -> R20
.even
_set_start_line_L::
xcall push_gset1
mov R20,R16
sbiw R28,1
.dbline -1
.dbline 111
; }
;
; //-----------------行列页选择函数------------------
; void set_start_line_L(unsigned char line) /*设置显示起始行*/ //0-63
; {
.dbline 112
; write_LCD(LEFT,CMD,0xc0|line);
mov R24,R20
ori R24,192
std y+0,R24
clr R18
clr R16
xcall _write_LCD
.dbline -2
L23:
adiw R28,1
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r line 20 c
.dbend
.dbfunc e set_start_line_R _set_start_line_R fV
; line -> R20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -