📄 can
字号:
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 40,'D
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 0,28
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 160,160
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 160,124
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 0,'D
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 'd,'T
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 'L,'D
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 20,20
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 20,20
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.blkb 2
.area idata
.byte 20,20
.area data(ram, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.dbsym e font6x8 _font6x8 A[552:92:6]c
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd/code_table.c
.dbfile C:\DOCUME~1\Administrator\桌面\nokia5110lcd\nokia.c
.dbfunc e delay_us _delay_us fV
; i -> R20,R21
; j -> R22,R23
; t -> R16,R17
.even
_delay_us::
xcall push_gset2
.dbline -1
.dbline 38
; /***********************************************************************
; 程序名称: nokia.c
; 程序功能: nokia5110驱动程序
; 程序说明:
; /**********************************************************************/
; #include <iom128v.h>
; #include <macros.h>
; #include <BIT.h>
; #include"code_table.c"
;
; #define uchar unsigned char
; #define uint unsigned int
;
; //位操作定义
; #define SCLK _PA5
; #define SDIN _PA4
; #define LCD_DC _PA3
; #define LCD_CE _PA2
; #define LCD_RST _PA1
;
; //函数声明
; void delay_us(uint t);
; void delay_ms(uint t);
; void LCD_init(void);
; void LCD_clear(void);
; void LCD_write_english_string(uchar X,uchar Y,char *s);
; void LCD_write_char(uchar c);
; void LCD_write_byte(uchar dat, uchar dc);
; void LCD_set_XY(uchar X, uchar Y);
;
; /***********************************************************************
; * 函数名称:delay_us()
; * 函数功能:16M晶振,延时t微秒
; * 入口参数:t 延时t微秒
; * 出口参数:无
; ***********************************************************************/
; void delay_us(uint t)
; {
.dbline 40
; uint i,j;
; for(i=t;i>0;i--)
movw R20,R16
xjmp L5
L2:
.dbline 41
ldi R22,1
ldi R23,0
xjmp L9
L6:
.dbline 41
L7:
.dbline 41
subi R22,1
sbci R23,0
L9:
.dbline 41
cpi R22,0
cpc R22,R23
brne L6
X0:
L3:
.dbline 40
subi R20,1
sbci R21,0
L5:
.dbline 40
cpi R20,0
cpc R20,R21
brne L2
X1:
.dbline -2
L1:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r j 22 i
.dbsym r t 16 i
.dbend
.dbfunc e delay_ms _delay_ms fV
; i -> R20,R21
; j -> R22,R23
; t -> R16,R17
.even
_delay_ms::
xcall push_gset2
.dbline -1
.dbline 51
; for(j=1;j>0;j--);
; }
;
; /**********************************************************************
; * 函数名称:delay_ms()
; * 函数功能:16M晶振,延时t毫秒
; * 入口参数:t 延时t毫秒
; * 出口参数:无
; ***********************************************************************/
; void delay_ms(uint t)
; {
.dbline 53
; uint i,j;
; for(i=t;i>0;i--)
movw R20,R16
xjmp L14
L11:
.dbline 54
ldi R22,2670
ldi R23,10
xjmp L18
L15:
.dbline 54
L16:
.dbline 54
subi R22,1
sbci R23,0
L18:
.dbline 54
cpi R22,0
cpc R22,R23
brne L15
X2:
L12:
.dbline 53
subi R20,1
sbci R21,0
L14:
.dbline 53
cpi R20,0
cpc R20,R21
brne L11
X3:
.dbline -2
L10:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r j 22 i
.dbsym r t 16 i
.dbend
.dbfunc e LCD_init _LCD_init fV
.even
_LCD_init::
.dbline -1
.dbline 64
; for(j=2670;j>0;j--);
; }
;
; /**********************************************************************
; * 函数名称:LCD_init()
; * 函数功能:初始化nokia5110
; * 入口参数:无
; * 出口参数:无
; **********************************************************************/
; void LCD_init(void)
; {
.dbline 65
; LCD_RST = 0; // 产生一个让LCD复位的低电平脉冲
in R24,0x1b
andi R24,253
out 0x1b,R24
.dbline 66
; delay_us(1);
ldi R16,1
ldi R17,0
xcall _delay_us
.dbline 67
; LCD_RST = 1;
in R24,0x1b
ori R24,2
out 0x1b,R24
.dbline 68
; LCD_CE = 0;// 关闭LCD
in R24,0x1b
andi R24,251
out 0x1b,R24
.dbline 69
; delay_us(1);
ldi R16,1
ldi R17,0
xcall _delay_us
.dbline 70
; LCD_CE = 1;// 使能LCD
in R24,0x1b
ori R24,4
out 0x1b,R24
.dbline 71
; delay_us(1);
ldi R16,1
ldi R17,0
xcall _delay_us
.dbline 72
; LCD_write_byte(0x21, 0); // 使用扩展命令设置LCD模式
clr R18
ldi R16,33
xcall _LCD_write_byte
.dbline 73
; LCD_write_byte(0xc8, 0); // 设置偏置电压
clr R18
ldi R16,200
xcall _LCD_write_byte
.dbline 74
; LCD_write_byte(0x06, 0); // 温度校正
clr R18
ldi R16,6
xcall _LCD_write_byte
.dbline 75
; LCD_write_byte(0x13, 0); // 1:48
clr R18
ldi R16,19
xcall _LCD_write_byte
.dbline 76
; LCD_write_byte(0x20, 0); // 使用基本命令
clr R18
ldi R16,32
xcall _LCD_write_byte
.dbline 77
; LCD_clear(); // 清屏
xcall _LCD_clear
.dbline 78
; LCD_write_byte(0x0c, 0); // 设定显示模式,正常显示
clr R18
ldi R16,12
xcall _LCD_write_byte
.dbline 79
; LCD_CE = 0; // 关闭LCD
in R24,0x1b
andi R24,251
out 0x1b,R24
.dbline -2
L19:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LCD_clear _LCD_clear fV
; i -> R20,R21
.even
_LCD_clear::
xcall push_gset1
.dbline -1
.dbline 89
; }
;
; /**********************************************************************
; * 函数名称:LCD_clear()
; * 函数功能:液晶清屏
; * 入口参数:无
; * 出口参数:无
; **********************************************************************/
; void LCD_clear(void)
; {
.dbline 91
; uint i;
; LCD_write_byte(0x0c, 0);
clr R18
ldi R16,12
xcall _LCD_write_byte
.dbline 92
; LCD_write_byte(0x80, 0);
clr R18
ldi R16,128
xcall _LCD_write_byte
.dbline 93
; for (i=0; i<504; i++)
clr R20
clr R21
xjmp L24
L21:
.dbline 94
ldi R18,1
clr R16
xcall _LCD_write_byte
L22:
.dbline 93
subi R20,255 ; offset = 1
sbci R21,255
L24:
.dbline 93
cpi R20,248
ldi R30,1
cpc R21,R30
brlo L21
.dbline -2
L20:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbend
.dbfunc e LCD_set_XY _LCD_set_XY fV
; Y -> R22
; X -> R20
.even
_LCD_set_XY::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 104
; LCD_write_byte(0, 1);
; }
;
; /**********************************************************************
; * 函数名称:LCD_set_XY()
; * 函数功能:光标定位x行y列
; * 入口参数:X,Y x行y列
; * 出口参数:无
; **********************************************************************/
; void LCD_set_XY(uchar X, uchar Y)
; {
.dbline 105
; LCD_write_byte(0x40 | Y, 0); // column
clr R18
mov R16,R22
ori R16,64
xcall _LCD_write_byte
.dbline 106
; LCD_write_byte(0x80 | X, 0); // row
clr R18
mov R16,R20
ori R16,128
xcall _LCD_write_byte
.dbline -2
L25:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r Y 22 c
.dbsym r X 20 c
.dbend
.dbfunc e LCD_write_char _LCD_write_char fV
; line -> R20
; c -> R22
.even
_LCD_write_char::
xcall push_gset2
mov R22,R16
.dbline -1
.dbline 116
; }
;
; /***********************************************************************
; * 函数名称:LCD_write_char()
; * 函数功能:写入1个字符
; * 入口参数:c 要写入的数据
; * 出口参数:无
; **********************************************************************/
; void LCD_write_char(uchar c)
; {
.dbline 118
; uchar line;
; c -= 32;
subi R22,32
.dbline 119
; for (line=0; line<6; line++)
clr R20
xjmp L30
L27:
.dbline 120
ldi R18,1
ldi R24,6
mul R24,R22
movw R2,R0
ldi R24,<_font6x8
ldi R25,>_font6x8
add R2,R24
adc R3,R25
mov R30,R20
clr R31
add R30,R2
adc R31,R3
ldd R16,z+0
xcall _LCD_write_byte
L28:
.dbline 119
inc R20
L30:
.dbline 119
cpi R20,6
brlo L27
.dbline -2
L26:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r line 20 c
.dbsym r c 22 c
.dbend
.dbfunc e LCD_write_english_string _LCD_write_english_string fV
; s -> R20,R21
; Y -> R10
; X -> R22
.even
_LCD_write_english_string::
xcall push_gset3
mov R10,R18
mov R22,R16
ldd R20,y+6
ldd R21,y+7
.dbline -1
.dbline 130
; LCD_write_byte(font6x8[c][line], 1);//从ACSII码表中读取字节,然后写入液晶
; }
;
; /***********************************************************************
; * 函数名称
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -