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

📄 ps.s

📁 AVRkaifashili.rar
💻 S
📖 第 1 页 / 共 4 页
字号:
;              i -> R16
	.even
_Set_DI::
	.dbline -1
	.dbline 117
; }
; 
; //sbit KEY_CLK=PD^3  //PS/2接口时钟线   
; //sbit KEY_DATA=PD^2;//Interrupt
; 
; //***************************LCD函数开始********************// 
; //sbit DI=PB^0;  
; void Set_DI(uchar i)
; {if(i==1) PORTB=PORTB|0x01;
	.dbline 117
	cpi R16,1
	brne L31
	.dbline 117
	sbi 0x18,0
	rjmp L32
L31:
	.dbline 118
	in R24,0x18
	andi R24,254
	out 0x18,R24
L32:
	.dbline -2
	.dbline 118
;  else     PORTB=PORTB&0xfe;}
L30:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e Set_RW _Set_RW fV
;              i -> R16
	.even
_Set_RW::
	.dbline -1
	.dbline 122
;  
; //sbit RW=PB^1;
; void Set_RW(uchar i)
; {if(i==1) PORTB=PORTB|0x02;
	.dbline 122
	cpi R16,1
	brne L34
	.dbline 122
	sbi 0x18,1
	rjmp L35
L34:
	.dbline 123
	in R24,0x18
	andi R24,253
	out 0x18,R24
L35:
	.dbline -2
	.dbline 123
;  else     PORTB=PORTB&0xfd;}
L33:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e Set_EN _Set_EN fV
;              i -> R16
	.even
_Set_EN::
	.dbline -1
	.dbline 127
;  
; //sbit ENABLE=PB^2;
; void Set_EN(uchar i)
; {if(i==1) PORTB=PORTB|0x04;
	.dbline 127
	cpi R16,1
	brne L37
	.dbline 127
	sbi 0x18,2
	rjmp L38
L37:
	.dbline 128
	in R24,0x18
	andi R24,251
	out 0x18,R24
L38:
	.dbline -2
	.dbline 128
;  else     PORTB=PORTB&0xfb;}
L36:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e Set_CS1 _Set_CS1 fV
;              i -> R16
	.even
_Set_CS1::
	.dbline -1
	.dbline 132
; 
; //sbit CS1=PB^3;
; void Set_CS1(uchar i)
; {if(i==1) PORTB=PORTB|0x08;
	.dbline 132
	cpi R16,1
	brne L40
	.dbline 132
	sbi 0x18,3
	rjmp L41
L40:
	.dbline 133
	in R24,0x18
	andi R24,247
	out 0x18,R24
L41:
	.dbline -2
	.dbline 133
;  else     PORTB=PORTB&0xf7;}
L39:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e Set_CS2 _Set_CS2 fV
;              i -> R16
	.even
_Set_CS2::
	.dbline -1
	.dbline 137
; 
; //sbit CS2=PB^4;
; void Set_CS2(uchar i)
; {if(i==1) PORTB=PORTB|0x10;
	.dbline 137
	cpi R16,1
	brne L43
	.dbline 137
	sbi 0x18,4
	rjmp L44
L43:
	.dbline 138
	in R24,0x18
	andi R24,191
	out 0x18,R24
L44:
	.dbline -2
	.dbline 138
;  else     PORTB=PORTB&0xbf;}
L42:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e Set_RST _Set_RST fV
;              i -> R16
	.even
_Set_RST::
	.dbline -1
	.dbline 142
; 
; //sbit RST=PB^5;
; void Set_RST(uchar i)
; {if(i==1) PORTB=PORTB|0x40;
	.dbline 142
	cpi R16,1
	brne L46
	.dbline 142
	sbi 0x18,6
	rjmp L47
L46:
	.dbline 143
	in R24,0x18
	andi R24,127
	out 0x18,R24
L47:
	.dbline -2
	.dbline 143
;  else     PORTB=PORTB&0x7f;}
L45:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 c
	.dbend
	.dbfunc e DisplayOnOff _DisplayOnOff fV
;              j -> <dead>
;              i -> R20
	.even
_DisplayOnOff::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 148
; 
; //***************************LCD显示开关控制命令***********//
; //参数说明:i=0开显示,i=1关显示
; void DisplayOnOff(uchar i)
; {uchar j;
	.dbline 149
;  Set_RW(0);                  // RW=0;
	clr R16
	rcall _Set_RW
	.dbline 150
;  Set_DI(0);                  //DI=0;
	clr R16
	rcall _Set_DI
	.dbline 151
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline 152
;  PORTC=62+i;                 //P0=0x3e+i;
	mov R24,R20
	subi R24,194    ; addi 62
	out 0x15,R24
	.dbline 153
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 154
;  Set_EN(1);                  //ENABLE=1;
	ldi R16,1
	rcall _Set_EN
	.dbline 155
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 156
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 157
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline -2
	.dbline 158
; }
L48:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym l j 1 c
	.dbsym r i 20 c
	.dbend
	.dbfunc e SetStartLine _SetStartLine fV
;              i -> R20
	.even
_SetStartLine::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 163
; 
; //***************************设置LCD显示起始行*************//
; //参数说明:i=0~63
; void SetStartLine(uchar i)
; {Set_RW(0);                  //RW=0;
	.dbline 163
	clr R16
	rcall _Set_RW
	.dbline 164
;  Set_DI(0);                  //DI=0;
	clr R16
	rcall _Set_DI
	.dbline 165
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline 166
;  PORTC=0xc0+i;               //PORTC=0xc0+i;
	mov R24,R20
	subi R24,64    ; addi 192
	out 0x15,R24
	.dbline 167
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 168
;  Set_EN(1);                  //ENABLE=1;
	ldi R16,1
	rcall _Set_EN
	.dbline 169
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 170
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 171
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline -2
	.dbline 172
; }
L49:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e SetX _SetX fV
;              i -> R20
	.even
_SetX::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 177
; 
; //***************************设置页(行)地址**************//
; //参数说明:i=0~7
; void SetX(uchar i)
; {Set_RW(0);                  //RW=0;
	.dbline 177
	clr R16
	rcall _Set_RW
	.dbline 178
;  Set_DI(0);                  //DI=0;
	clr R16
	rcall _Set_DI
	.dbline 179
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline 180
;  PORTC=0xb8+i;               //P0=0xb8+i;
	mov R24,R20
	subi R24,72    ; addi 184
	out 0x15,R24
	.dbline 181
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 182
;  Set_EN(1);                  //ENABLE=1;
	ldi R16,1
	rcall _Set_EN
	.dbline 183
;  DelayUs(100);               // _DelayUs_();
	ldi R16,100
	rcall _DelayUs
	.dbline 184
;  DelayUs(100);               //_DelayUs_();
	ldi R16,100
	rcall _DelayUs
	.dbline 185
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline -2
	.dbline 186
; }
L50:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e SetY _SetY fV
;              i -> R20
	.even
_SetY::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 191
; 
; //***************************设置Y(列)地址***************//
; //参数说明:i=0~63
; void SetY(uchar i)
; {Set_RW(0);                  //RW=0;
	.dbline 191
	clr R16
	rcall _Set_RW
	.dbline 192
;  Set_DI(0);                  //DI=0;
	clr R16
	rcall _Set_DI
	.dbline 193
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline 194
;  PORTC=0x40+i;               // P0=0x40+i;
	mov R24,R20
	subi R24,192    ; addi 64
	out 0x15,R24
	.dbline 195
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 196
;  Set_EN(1);                  //ENABLE=1;
	ldi R16,1
	rcall _Set_EN
	.dbline 197
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 198
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 199
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline -2
	.dbline 200
; }
L51:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e WriteByte _WriteByte fV
;              i -> R20
	.even
_WriteByte::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 205
; 
; //***************************写显示数据********************//
; //参数说明:i为送DDRAM的数据
; void WriteByte(uchar i)
; {Set_RW(0);                  //RW=0;
	.dbline 205
	clr R16
	rcall _Set_RW
	.dbline 206
;  Set_DI(1);                  //DI=1;
	ldi R16,1
	rcall _Set_DI
	.dbline 207
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline 208
;  PORTC=i;                    //P0=i;
	out 0x15,R20
	.dbline 209
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 210
;  Set_EN(1);                  //ENABLE=1;
	ldi R16,1
	rcall _Set_EN
	.dbline 211
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 212
;  DelayUs(10);                //_DelayUs_();
	ldi R16,10
	rcall _DelayUs
	.dbline 213
;  Set_EN(0);                  //ENABLE=0;
	clr R16
	rcall _Set_EN
	.dbline -2
	.dbline 214
; }
L52:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e Reset _Reset fV
	.even
_Reset::
	.dbline -1
	.dbline 218
; 
; //***************************LCD复位***********************//
; void Reset(void)
; {Set_RST(0);                 //RST=0;
	.dbline 218
	clr R16
	rcall _Set_RST
	.dbline 219
;  DelayMs(1);
	ldi R16,1
	ldi R17,0
	rcall _DelayMs
	.dbline 220
;  Set_RST(1);                 //RST=1;
	ldi R16,1
	.dbline -2
	.dbline 221
; }
L53:
	.dbline 0 ; func end
	rjmp _Set_RST
	.dbend
	.dbfunc e ClearScreen _ClearScreen fV
;              i -> R20
;              j -> R22
;              k -> R22
	.even
_ClearScreen::
	rcall push_gset2
	mov R22,R16
	.dbline -1
	.dbline 226
; 
; //***************************LCD清屏幕*********************//
; //参数说明:LCD从k(0~7)行开始清屏幕
; void ClearScreen(uchar k)
; {uchar i,j;
	.dbline 227
;  Set_CS1(1);                //CS1=1;选中右屏幕
	ldi R16,1
	rcall _Set_CS1
	.dbline 228
;  Set_CS2(1);                //CS2=1;选中左屏幕
	ldi R16,1
	rcall _Set_CS2
	.dbline 229
;  for(i=k;i<8;i+=1)
	mov R20,R22
	rjmp L58
L55:
	.dbline 230
;  	{SetX(i);               //设置起始行
	.dbline 230
	mov R16,R20
	rcall _SetX
	.dbline 231
; 	 for(j=0;j<64;j++)  
	clr R22
	rjmp L62
L59:
	.dbline 232
	clr R16
	rcall _WriteByte
L60:
	.dbline 231
	inc R22
L62:
	.dbline 231
	cpi R22,64
	brlo L59
	.dbline 233
L56:
	.dbline 229
	inc R20
L58:
	.dbline 229
	cpi R20,8
	brlo L55
	.dbline -2
	.dbline 234
; 		WriteByte(0x00);    //向DDRAM写0清屏幕
; 	 }
; }
L54:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r j 22 c
	.dbsym r k 22 c
	.dbend
	.dbfunc e Init_LCD _Init_LCD fV
	.even
_Init_LCD::
	.dbline -1
	.dbline 238
;  
; //***************************LCD初始化*********************//
; void Init_LCD(void)
; {Reset();                    //LCD复位
	.dbline 238
	rcall _Reset
	.dbline 239
;  DelayMs(1);
	ldi R16,1
	ldi R17,0
	rcall _DelayMs
	.dbline 240
;  ClearScreen(0);             //LCD清屏
	clr R16
	rcall _ClearScreen
	.dbline 241
;  DisplayOnOff(1);            //开启显示
	ldi R16,1
	rcall _DisplayOnOff
	.dbline 242
;  SetStartLine(0);            //设置起始行
	clr R16
	.dbline -2
	.dbline 243
; }
L63:
	.dbline 0 ; func end
	rjmp _SetStartLine
	.dbend
	.dbfunc e WritePIC _WritePIC fV
;             jj -> R22
;             ii -> R20
;             kk -> R22
;              j -> R10
;              i -> R14
;           disp -> R12,R13
	.even
_WritePIC::
	rcall push_gset5
	mov R14,R18
	mov R12,R16
	mov R13,R17
	ldd R10,y+10
	.dbline -1
	.dbline 249
; 
; //***************************LCD图象显示函数***************//
; //参数说明:disp[]:图象数组名;i:LCD的起始行;j:LCD的结束行
; //函数功能:从LCD的i行到j行显示数组disp[]所存的图象
; void WritePIC(const uchar *disp,uchar i,uchar j)
; {uchar ii=0;
	.dbline 249
	clr R20
	.dbline 250
;  uchar jj=0;
	clr R22
	.dbline 251
;  uchar kk=0;
	.dbline 252
;  SetX(0);
	clr R16
	rcall _SetX
	.dbline 253
;  SetY(0);
	clr R16
	rcall _SetY
	.dbline 254
;  for(ii=i;ii<j;ii++)
	mov R20,R14
	rjmp L68
L65:
	.dbline 255
;  {for(kk=0;kk<64;kk++)
	.dbline 255
	clr R22
	rjmp L72
L69:
	.dbline 256
	.dbline 256
	clr R16
	rcall _Set_CS1
	.dbline 257
	ldi R16,1
	rcall _Set_CS2
	.dbline 258
	mov R16,R20
	rcall _SetX
	.dbline 259
	mov R16,R22
	rcall _SetY
	.dbline 260
	mov R30,R12
	mov R31,R13
	lpm
	mov R16,R0
	rcall _WriteByte
	.dbline 261
	mov R24,R12
	mov R25,R13
	adiw R24,1
	mov R12,R24
	mov R13,R25
	.dbline 261
L70:
	.dbline 255
	inc R22
L72:
	.dbline 255
	cpi R22,64
	brlo L69
	.dbline 262
; 	{Set_CS1(0);             //选择左屏幕
; 	 Set_CS2(1);
; 	 SetX(ii);               //设置页地址
; 	 SetY(kk);               //设置列地址
; 	 WriteByte(*disp);       //写数据
; 	 disp++;}
;   for(kk=0;kk<64;kk++)      
	clr R22
	rjmp L76
L73:
	.dbline 263
	.dbline 263
	ldi R16,1
	rcall _Set_CS1
	.dbline 264
	clr R16
	rcall _Set_CS2
	.dbline 265
	mov R16,R20
	rcall _SetX
	.dbline 266
	mov R16,R22
	rcall _SetY
	.dbline 267
	mov R30,R12
	mov R31,R13
	lpm
	mov R16,R0
	rcall _WriteByte
	.dbline 268
	mov R24,R12
	mov R25,R13
	adiw R24,1
	mov R12,R24
	mov R13,R25
	.dbline 268
L74:
	.dbline 262
	inc R22
L76:
	.dbline 262
	cpi R22,64
	brlo L73
	.dbline 268
L66:
	.dbline 254
	inc R20
L68:
	.dbline 254
	cp R20,R10
	brsh X2
	rjmp L65
X2:
	.dbline -2
	.dbline 269
; 	{Set_CS1(1);             //选择右屏幕
; 	 Set_CS2(0);           
; 	 SetX(ii);               //设置页地址
; 	 SetY(kk);               //设置列地址
; 	 WriteByte(*disp);       //写数据
;   	 disp++;}}
; } 
L64:
	rcall pop_gset5
	.dbline 0 ; func end
	ret
	.dbsym r jj 22 c
	.dbsym r ii 20 c
	.dbsym r kk 22 c
	.dbsym r j 10 c
	.dbsym r i 14 c
	.dbsym r disp 12 pkc
	.dbend
	.dbfunc e WriteWord _WriteWord fV
;              i -> R20
;             cs -> y+10
;              y -> R10
;              x -> R12
;           disp -> R22,R23
	.even
_WriteWord::
	rcall push_gset4
	mov R12,R18
	mov R22,R16
	mov R23,R17
	ldd R10,y+8
	.dbline -1
	.dbline 276
;  
; //***************************LCD中文汉字显示函数***********//
; //参数说明:disp[]:汉字字模数组名;
; //参数说明:x:LCD的页地址;y:LCD的列地址

⌨️ 快捷键说明

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