⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_back.s

📁 AVR单片机 C语言程序设计经典实用
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module LCD_back.c
	.area text(rom, con, rel)
	.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\点阵型LCD显示应用设计\LCD_back.c
	.dbfunc e Delay_ms _Delay_ms fV
;           time -> R20,R21
	.even
_Delay_ms::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 61
; //******************************************************************************
; // File Name : LCD.c
; // Author    : Steaven
; // Created   : 2008-07-27
; // Modified  : 
; // Revision  : V0.0
; //******************************************************************************
; 
; //PIN DESCRIPTION
; //01  2   3  4   5   6   7   8   9   10  11  12  13  14  15  16
; //GND VCC V0 RS  RW  EN  D0  D1  D2  D3  D4  D5  D6  D7  BLA BLK
; //GND +5V V0 PB0 PB1 PB2 PA0 PA1 PA2 PA3 PA4 PA5 PA6 PA7 GND +5V
; 
; #include "iom16v.h" 
; #include "DataType.h"
; #include "LCD.h"
; #include "macros.h" 
; 
; #define cLCD_X_MAX   64
; #define cLCD_Y_MAX  128
; 
; //local functions declaration
; void Set_DI(INT8U RS);
; void Set_RW(INT8U RW);
; void Set_EN(INT8U EN);
; void Set_CS1(INT8U CS1);
; void Set_CS2(INT8U CS2);
; void Set_RST(INT8U RST);
; void Set_Data(INT8U data);
; INT8U Get_Data(void);
; void DisplayOnOff(INT8U i);
; void SetStartLine(INT8U i);
; void LCD_Command_Set_X(INT8U x);
; void LCD_Command_Set_Y(INT8U y);
; void LCD_Command_WriteByte(INT8U data);
; INT8U Read_Byte(void);
; void LCD_Reset(void);
; void LCD_Clear_Line(INT8U wStartLine,INT8U wEndLine);
; void LCD_Init(void);
; void WriteWord(INT8U const *disp,INT8U x,INT8U y);
; void WriteCharacter(const INT8U *disp,INT8U x,INT8U y,INT8U cs);
; void WritePIC(const INT8U *disp);
; void LCD_Write_Char(INT8U y,INT8U x,const INT8U *pdata);
; void LCD_Write_Dot(INT8U x,INT8U y);
; INT8U LCD_Read_Data(INT8U x,INT8U y);
; void LCD_Write_Data(INT8U x,INT8U y,INT8U data);	
; void LCD_Write_Picture(INT8U x1,INT8U y1,INT8U x2,INT8U y2,const INT8U *pdata);
; 
; /*
; void nop(INT8U cnt)
; {
; 	while(cnt--) ;
; }
; 
; void Delay(INT8U cnt)
; {
; 	while(cnt--) ;
; }
; */
; void Delay_ms(INT16U time)
; {
	.dbline 62
;     for(;time!=0;time--)
	xjmp L5
L2:
	.dbline 63
	.dbline 64
	ldi R16,500
	ldi R17,1
	xcall _Delay
	.dbline 65
L3:
	.dbline 62
	subi R20,1
	sbci R21,0
L5:
	.dbline 62
	cpi R20,0
	cpc R20,R21
	brne L2
X0:
	.dbline -2
	.dbline 66
; 		{
; 		    Delay(500);
; 		}
; }
L1:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r time 20 i
	.dbend
	.dbfunc e Set_DI _Set_DI fV
;             RS -> R16
	.even
_Set_DI::
	.dbline -1
	.dbline 79
; 
; 
; #define nop(X) {;}
; #define Delay(X) {;}
; 
; //******************************************************************************
; // Function    : Set_RS
; // Input       : RS - RS Control Line Level
; // Output      : none
; // Description : LCD(1602) Low Level Interface Function
; //******************************************************************************
; void Set_DI(INT8U RS)
; {
	.dbline 80
; 	if(RS == 0)
	tst R16
	brne L7
	.dbline 81
; 	{
	.dbline 82
; 		PORTB &= ~0x01;
	cbi 0x18,0
	.dbline 83
; 	}
	xjmp L8
L7:
	.dbline 85
	.dbline 86
	sbi 0x18,0
	.dbline 87
L8:
	.dbline -2
	.dbline 88
; 	else
; 	{
; 		PORTB |= 0x01;
; 	}
; }
L6:
	.dbline 0 ; func end
	ret
	.dbsym r RS 16 c
	.dbend
	.dbfunc e Set_RW _Set_RW fV
;             RW -> R16
	.even
_Set_RW::
	.dbline -1
	.dbline 97
; 
; //******************************************************************************
; // Function    : Set_RW
; // Input       : RW - RW Control Line Level
; // Output      : none
; // Description : Low Level Interface Function
; //******************************************************************************
; void Set_RW(INT8U RW)
; {
	.dbline 98
; 	if(RW == 0)
	tst R16
	brne L10
	.dbline 99
; 	{
	.dbline 100
; 		PORTB &= ~0x02;
	cbi 0x18,1
	.dbline 101
; 	}
	xjmp L11
L10:
	.dbline 103
	.dbline 104
	sbi 0x18,1
	.dbline 105
L11:
	.dbline -2
	.dbline 106
; 	else
; 	{
; 		PORTB |= 0x02;
; 	}
; }
L9:
	.dbline 0 ; func end
	ret
	.dbsym r RW 16 c
	.dbend
	.dbfunc e Set_EN _Set_EN fV
;             EN -> R16
	.even
_Set_EN::
	.dbline -1
	.dbline 115
; 
; //******************************************************************************
; // Function    : Set_EN
; // Input       : RW - RW Control Line Level
; // Output      : none
; // Description : Low Level Interface Function
; //******************************************************************************
; void Set_EN(INT8U EN)
; {
	.dbline 116
; 	if(EN == 0)
	tst R16
	brne L13
	.dbline 117
; 	{
	.dbline 118
; 		PORTB &= ~0x04;
	cbi 0x18,2
	.dbline 119
; 	}
	xjmp L14
L13:
	.dbline 121
	.dbline 122
	sbi 0x18,2
	.dbline 123
L14:
	.dbline -2
	.dbline 124
; 	else
; 	{
; 		PORTB |= 0x04;
; 	}
; }
L12:
	.dbline 0 ; func end
	ret
	.dbsym r EN 16 c
	.dbend
	.dbfunc e Set_CS2 _Set_CS2 fV
;            CS2 -> R16
	.even
_Set_CS2::
	.dbline -1
	.dbline 133
; 
; //******************************************************************************
; // Function    : Set_CS2
; // Input       : CS2 - CS2 Control Line Level
; // Output      : none
; // Description : Low Level Interface Function
; //******************************************************************************
; void Set_CS2(INT8U CS2)
; {
	.dbline 134
; 	if(CS2 == 0) 
	tst R16
	brne L16
	.dbline 135
; 	{
	.dbline 136
; 		PORTC &= ~0x20;
	cbi 0x15,5
	.dbline 137
; 	}
	xjmp L17
L16:
	.dbline 139
	.dbline 140
	sbi 0x15,5
	.dbline 141
L17:
	.dbline -2
	.dbline 142
;  	else
;  	{
;  		PORTC |= 0x20;
;  	}
; }
L15:
	.dbline 0 ; func end
	ret
	.dbsym r CS2 16 c
	.dbend
	.dbfunc e Set_CS1 _Set_CS1 fV
;            CS1 -> R16
	.even
_Set_CS1::
	.dbline -1
	.dbline 151
; 
; //******************************************************************************
; // Function    : Set_CS1
; // Input       : CS1 - CS1 Control Line Level
; // Output      : none
; // Description : Low Level Interface Function
; //******************************************************************************
; void Set_CS1(INT8U CS1)
; {
	.dbline 152
; 	if(CS1 == 0)
	tst R16
	brne L19
	.dbline 153
; 	{
	.dbline 154
; 		PORTC &= ~0x40;
	cbi 0x15,6
	.dbline 155
; 	}
	xjmp L20
L19:
	.dbline 157
	.dbline 158
	sbi 0x15,6
	.dbline 159
L20:
	.dbline -2
	.dbline 160
; 	else
; 	{
; 		PORTC |= 0x40;
; 	}
; }
L18:
	.dbline 0 ; func end
	ret
	.dbsym r CS1 16 c
	.dbend
	.dbfunc e Set_RST _Set_RST fV
;            RST -> R16
	.even
_Set_RST::
	.dbline -1
	.dbline 165
; 
; 
; //sbit RST=PC7;
; void Set_RST(INT8U RST)
; {
	.dbline 166
; 	if(RST == 0)
	tst R16
	brne L22
	.dbline 167
; 	{
	.dbline 168
; 		PORTC &= ~0x80;
	cbi 0x15,7
	.dbline 169
; 	}
	xjmp L23
L22:
	.dbline 171
	.dbline 172
	sbi 0x15,7
	.dbline 173
L23:
	.dbline -2
	.dbline 174
; 	else
; 	{
; 		PORTC |= 0x80;
; 	}
; }
L21:
	.dbline 0 ; func end
	ret
	.dbsym r RST 16 c
	.dbend
	.dbfunc e Set_Data _Set_Data fV
;           data -> R16
	.even
_Set_Data::
	.dbline -1
	.dbline 183
;  
; //******************************************************************************
; // Function    : Set_Data
; // Input       : data - Data Line Level
; // Output      : none
; // Description : Low Level Interface Function
; //******************************************************************************
; void Set_Data(INT8U data)
; {
	.dbline 184
; 	PORTA  = data;
	out 0x1b,R16
	.dbline -2
	.dbline 185
; }
L24:
	.dbline 0 ; func end
	ret
	.dbsym r data 16 c
	.dbend
	.dbfunc e DisplayOnOff _DisplayOnOff fV
;          onoff -> R20
	.even
_DisplayOnOff::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 189
; 
; //显示开关控制命令,i=0开显示,i=1关显示//
; void DisplayOnOff(INT8U onoff)
; {
	.dbline 190
; 	Set_RW(0);
	clr R16
	xcall _Set_RW
	.dbline 191
; 	Set_DI(0);
	clr R16
	xcall _Set_DI
	.dbline 192
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline 193
; 	Set_Data(0x3E + onoff);
	mov R16,R20
	subi R16,194    ; addi 62
	xcall _Set_Data
	.dbline 194
; 	nop(10);
	.dbline 194
	.dbline 194
	.dbline 194
	.dbline 195
; 	Set_EN(1);
	ldi R16,1
	xcall _Set_EN
	.dbline 196
; 	nop(10);
	.dbline 196
	.dbline 196
	.dbline 196
	.dbline 197
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline -2
	.dbline 198
; }
L25:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r onoff 20 c
	.dbend
	.dbfunc e SetStartLine _SetStartLine fV
;           line -> R20
	.even
_SetStartLine::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 202
; 
; //设置显示起始行,i=0~63//
; void SetStartLine(INT8U line)
; {
	.dbline 203
; 	Set_RW(0);
	clr R16
	xcall _Set_RW
	.dbline 204
; 	Set_DI(0);																
	clr R16
	xcall _Set_DI
	.dbline 205
; 	Set_EN(0);																
	clr R16
	xcall _Set_EN
	.dbline 206
; 	Set_Data(0xC0 + line);
	mov R16,R20
	subi R16,64    ; addi 192
	xcall _Set_Data
	.dbline 207
; 	nop(10);																
	.dbline 207
	.dbline 207
	.dbline 207
	.dbline 208
; 	Set_EN(1);																
	ldi R16,1
	xcall _Set_EN
	.dbline 209
; 	nop(10);																																
	.dbline 209
	.dbline 209
	.dbline 209
	.dbline 210
; 	Set_EN(0);																
	clr R16
	xcall _Set_EN
	.dbline -2
	.dbline 211
; }
L26:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r line 20 c
	.dbend
	.dbfunc e LCD_Command_Set_X _LCD_Command_Set_X fV
;            row -> R20
	.even
_LCD_Command_Set_X::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 215
; 
; //设置页(行)地址,i=0~7//
; void LCD_Command_Set_X(INT8U row)
; {
	.dbline 216
; 	Set_RW(0);
	clr R16
	xcall _Set_RW
	.dbline 217
; 	Set_DI(0);
	clr R16
	xcall _Set_DI
	.dbline 218
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline 219
; 	Set_Data(0xB8 + row);
	mov R16,R20
	subi R16,72    ; addi 184
	xcall _Set_Data
	.dbline 220
; 	nop(10);
	.dbline 220
	.dbline 220
	.dbline 220
	.dbline 221
; 	Set_EN(1);
	ldi R16,1
	xcall _Set_EN
	.dbline 222
; 	nop(10);
	.dbline 222
	.dbline 222
	.dbline 222
	.dbline 223
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline -2
	.dbline 224
; }
L27:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r row 20 c
	.dbend
	.dbfunc e LCD_Command_Set_Y _LCD_Command_Set_Y fV
;         column -> R20
	.even
_LCD_Command_Set_Y::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 228
; 
; //设置Y(列)地址,i=0~127//
; void LCD_Command_Set_Y(INT8U column)
; {
	.dbline 229
; 	Set_RW(0);
	clr R16
	xcall _Set_RW
	.dbline 230
; 	Set_DI(0);
	clr R16
	xcall _Set_DI
	.dbline 231
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline 232
; 	Set_Data(0x40 + column);
	mov R16,R20
	subi R16,192    ; addi 64
	xcall _Set_Data
	.dbline 233
; 	nop(10);
	.dbline 233
	.dbline 233
	.dbline 233
	.dbline 234
; 	Set_EN(1);
	ldi R16,1
	xcall _Set_EN
	.dbline 235
; 	nop(10);
	.dbline 235
	.dbline 235
	.dbline 235
	.dbline 236
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline -2
	.dbline 237
; }
L28:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r column 20 c
	.dbend
	.dbfunc e LCD_Command_WriteByte _LCD_Command_WriteByte fV
;           data -> R20
	.even
_LCD_Command_WriteByte::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 241
; 
; //写显示数据,i为送DDRAM的数据
; void LCD_Command_WriteByte(INT8U data)
; {
	.dbline 242
; 	Set_RW(0);
	clr R16
	xcall _Set_RW
	.dbline 243
; 	Set_DI(1);
	ldi R16,1
	xcall _Set_DI
	.dbline 244
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline 245
; 	Set_Data(data);
	mov R16,R20
	xcall _Set_Data
	.dbline 246
; 	nop(10);
	.dbline 246
	.dbline 246
	.dbline 246
	.dbline 247
; 	Set_EN(1);
	ldi R16,1
	xcall _Set_EN
	.dbline 248
; 	nop(10);
	.dbline 248
	.dbline 248
	.dbline 248
	.dbline 249
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline -2
	.dbline 250
; }
L29:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 c
	.dbend
	.dbfunc e Read_Byte _Read_Byte fc
;           data -> R20
	.even
_Read_Byte::
	xcall push_gset1
	.dbline -1
	.dbline 253
; 
; INT8U Read_Byte(void)
; {
	.dbline 255
; 	INT8U data;
; 	DDRA = 0x00;
	clr R2
	out 0x1a,R2
	.dbline 256
; 	PORTA = 0x00;
	out 0x1b,R2
	.dbline 257
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline 258
; 	Set_RW(1);
	ldi R16,1
	xcall _Set_RW
	.dbline 259
; 	Set_DI(1);
	ldi R16,1
	xcall _Set_DI
	.dbline 261
; //	Set_EN(0);
; 	nop(100);
	.dbline 261
	.dbline 261
	.dbline 261
	.dbline 262
; 	Set_EN(1);
	ldi R16,1
	xcall _Set_EN
	.dbline 263
; 	nop(100);
	.dbline 263
	.dbline 263
	.dbline 263
	.dbline 265
; 	//data = Get_Data();
; 	data = PINA;
	in R20,0x19
	.dbline 266
; 	Set_EN(0);
	clr R16
	xcall _Set_EN
	.dbline 267
; 	return(data);
	mov R16,R20
	.dbline -2
L30:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 c
	.dbend
	.dbfunc e LCD_Reset _LCD_Reset fV
	.even
_LCD_Reset::

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -