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

📄 lcd12864_3wires_draw.s

📁 IC为ST7920的12864LCD
💻 S
📖 第 1 页 / 共 4 页
字号:
	std y+2,R24
	ldi R24,6
	std y+0,R24
	ldi R18,3
	ldi R16,6
	xcall _Set_White
	.dbline 225
	ldi R24,1
	std y+2,R24
	ldi R24,4
	std y+0,R24
	ldi R18,4
	ldi R16,4
	xcall _Set_White
	.dbline 226
	ldi R16,2000
	ldi R17,7
	xcall _Delay
	.dbline 227
	ldi R16,2000
	ldi R17,7
	xcall _Delay
	.dbline 228
	ldi R24,1
	std y+2,R24
	std y+0,R24
	ldi R18,1
	ldi R16,1
	xcall _Set_White
	.dbline 229
	ldi R24,1
	std y+2,R24
	ldi R24,3
	std y+0,R24
	ldi R18,2
	ldi R16,3
	xcall _Set_White
	.dbline 230
	ldi R24,1
	std y+2,R24
	ldi R24,2
	std y+0,R24
	ldi R18,3
	ldi R16,2
	xcall _Set_White
	.dbline 231
	ldi R24,1
	std y+2,R24
	ldi R24,5
	std y+0,R24
	ldi R18,4
	ldi R16,5
	xcall _Set_White
	.dbline 232
	ldi R16,2000
	ldi R17,7
	xcall _Delay
	.dbline 233
	ldi R16,2000
	ldi R17,7
	xcall _Delay
	.dbline 234
	ldi R24,1
	std y+2,R24
	ldi R24,8
	std y+0,R24
	ldi R18,1
	ldi R16,1
	xcall _Set_White
	.dbline 235
	ldi R24,1
	std y+2,R24
	ldi R24,8
	std y+0,R24
	ldi R18,2
	ldi R16,1
	xcall _Set_White
	.dbline 236
	ldi R24,1
	std y+2,R24
	ldi R24,8
	std y+0,R24
	ldi R18,3
	ldi R16,1
	xcall _Set_White
	.dbline 237
	ldi R24,1
	std y+2,R24
	ldi R24,8
	std y+0,R24
	ldi R18,4
	ldi R16,1
	xcall _Set_White
	.dbline 239
	ldi R16,2000
	ldi R17,7
	xcall _Delay
	.dbline 240
	ldi R16,2000
	ldi R17,7
	xcall _Delay
	.dbline 241
	ldi R24,48
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 242
	ldi R24,1
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 243
	ldi R24,1
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 244
	ldi R24,1
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 245
	xcall _Set_Draw
	.dbline 246
	ldi R16,100
	ldi R17,0
	xcall _Delay
	.dbline 247
	ldi R24,<_PIC1
	ldi R25,>_PIC1
	std y+1,R25
	std y+0,R24
	clr R18
	clr R16
	xcall _Draw_Pic
	.dbline 248
	ldi R24,54
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 249
	ldi R16,5000
	ldi R17,19
	xcall _Delay
	.dbline 250
	ldi R24,52
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 252
	ldi R24,<_PIC2
	ldi R25,>_PIC2
	std y+1,R25
	std y+0,R24
	clr R18
	clr R16
	xcall _Draw_Pic
	.dbline 253
	ldi R24,54
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 254
	ldi R16,5000
	ldi R17,19
	xcall _Delay
	.dbline 256
	ldi R24,48
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 257
	ldi R24,1
	std y+0,R24
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 260
L3:
	.dbline 203
	xjmp L2
X0:
	.dbline -2
L1:
	adiw R28,3
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbend
	.dbfunc e LCD_Init _LCD_Init fV
;            cmd -> R20
	.even
_LCD_Init::
	xcall push_gset1
	sbiw R28,1
	.dbline -1
	.dbline 264
; 	while(1)
; 	{	
; 		nop();
; 		nop();
; 		Delay(500);
; 		Char_Set_XY(0,0,"ST7920_3_wires");
; 		Char_Set_XY(2,1,"反白练习");
; 		Char_Set_XY(0,2,"可以单字反白或不");
; 		Char_Set_XY(3,3,"反白");
; 		Delay(2000);
; 		Delay(2000);
; 		Set_Draw();
; 		Delay(100);
; 		Set_White(1,1,7,0);			//第1行,第1个汉字位置到第8汉字位置反白
; 		Set_White(3,2,6,0);			//第2行,第2个汉字位置到第7汉字位置反白
; 		Set_White(1,3,8,0);			//第3行,第3个汉字位置到第6汉字位置反白
; 		Set_White(4,4,5,0);			//第4行,第4个汉字位置到第5汉字位置反白
; 		Delay(2000);
; 		Delay(2000);
; 		Set_White(4,1,4,1);			//
; 		Set_White(5,2,5,1);			//
; 		Set_White(6,3,6,1);			//
; 		Set_White(4,4,4,1);			//
; 		Delay(2000);
; 		Delay(2000);
; 		Set_White(1,1,1,1);			//
; 		Set_White(3,2,3,1);			//
; 		Set_White(2,3,2,1);			//
; 		Set_White(5,4,5,1);			//
; 		Delay(2000);
; 		Delay(2000);
; 		Set_White(1,1,8,1);			//第1行,第1个汉字位置到第8汉字位置取消反白
; 		Set_White(1,2,8,1);			//第2行,第1个汉字位置到第8汉字位置取消反白
; 		Set_White(1,3,8,1);			//第3行,第1个汉字位置到第8汉字位置取消反白
; 		Set_White(1,4,8,1);			//第4行,第1个汉字位置到第8汉字位置取消反白
; 		
; 		Delay(2000);
; 		Delay(2000);
; 		W_1byte(0,0,0x30);		//基本指令集,,绘图显示OFF
; 		W_1byte(0,0,0x01);		//清除显示
; 		W_1byte(0,0,0x01);		//清除显示
; 		W_1byte(0,0,0x01);		//清除显示
; 		Set_Draw();
; 		Delay(100);
; 		Draw_Pic(0,0,*PIC1);	//先替换液晶内部RAM中的数据,再开显示
; 		W_1byte(0,0,0x36);		//8BIT控制界面,扩充指令集,,绘图显示ON
; 		Delay(5000);
; 		W_1byte(0,0,0x34);		//绘图显示OFF,主要解决画图时拖尾的现象,即先
; 								//替换好液晶内部RAM中的数据在开显示。									
; 		Draw_Pic(0,0,*PIC2);
; 		W_1byte(0,0,0x36);		//8BIT控制界面,扩充指令集,绘图显示ON
; 		Delay(5000);
; 								//画完图后要显示文字要重新设置成普通模式	
; 		W_1byte(0,0,0x30);		//基本指令集,,绘图显示OFF
; 		W_1byte(0,0,0x01);		//清除显示
; 		
; 		//for(;;);
; 	}
; }
; /******************************************************************/
; void LCD_Init(void)
; {
	.dbline 266
;  	uchar cmd;
;  	cmd=0x30;			//功能设置 8位数据,基本指令
	ldi R20,48
	.dbline 267
; 	W_1byte(0,0,cmd);
	std y+0,R20
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 268
; 	Delay(2);
	ldi R16,2
	ldi R17,0
	xcall _Delay
	.dbline 269
; 	cmd=0x0C;			//显示状态 ON,游标OFF,反白OFF
	ldi R20,12
	.dbline 270
; 	W_1byte(0,0,cmd);	//写指令
	std y+0,R20
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 271
; 	Delay(2);
	ldi R16,2
	ldi R17,0
	xcall _Delay
	.dbline 272
; 	cmd=0x01;			//清除显示
	ldi R20,1
	.dbline 273
; 	W_1byte(0,0,cmd);	//写指令
	std y+0,R20
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 274
; 	Delay(2);
	ldi R16,2
	ldi R17,0
	xcall _Delay
	.dbline 275
; 	cmd=0x02;			//地址归位
	ldi R20,2
	.dbline 276
; 	W_1byte(0,0,cmd);	//写指令
	std y+0,R20
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 277
; 	Delay(2);
	ldi R16,2
	ldi R17,0
	xcall _Delay
	.dbline 278
; 	cmd=0x80;			//设置DDRAM地址
	ldi R20,128
	.dbline 279
; 	W_1byte(0,0,cmd);	//写指令
	std y+0,R20
	clr R18
	clr R16
	xcall _W_1byte
	.dbline 280
; 	Delay(2);			//延时
	ldi R16,2
	ldi R17,0
	xcall _Delay
	.dbline -2
L9:
	adiw R28,1
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r cmd 20 c
	.dbend
	.dbfunc e W_1byte _W_1byte fV
;         H_data -> R22,R23
;           S_ID -> R10,R11
;         L_data -> R20,R21
;         W_data -> y+6
;             RS -> R20
;             RW -> R22
	.even
_W_1byte::
	xcall push_gset3
	mov R20,R18
	mov R22,R16
	.dbline -1
	.dbline 296
; }
; /*******************************************************************
; 函 数 名:W_1byte
; 入口参数:RW、RS、W_data
; 出口参数:无
; 建立日期:2007年3月3日
; 修改日期:
; 函数作用:写一个字节的数据到12864液晶,包括指令和数据
; 说    明:RW=1,从液晶读数据到MCU;RW=0,写一个数据到液晶;
; 		 (一般RW都设为0,即只向液晶写数据,不读数据)
;           RS=1,写入的是数据;RS=0,写入的是指令;
; 		  一般模式:RW=0,RS=1;写数据
; 		  			RW=0,RS=0;写指令
; ********************************************************************/
; void W_1byte(uchar RW, uchar RS, uchar W_data)
; {
	.dbline 297
; 	uint H_data,L_data,S_ID = 0xf8;	 //11111RWRS0
	ldi R24,248
	ldi R25,0
	movw R10,R24
	.dbline 298
; 	if(RW == 0)
	tst R22
	brne L11
	.dbline 299
; 	{
	.dbline 300
; 	 	S_ID &=~ 0x04;
	andi R24,251
	movw R10,R24
	.dbline 301
; 	}
	xjmp L12
L11:
	.dbline 303
; 	else					//if(RW==1)
; 	{
	.dbline 304
; 	 	S_ID |= 0X04;
	movw R24,R10
	ori R24,4
	movw R10,R24
	.dbline 305
; 	}
L12:
	.dbline 306
; 	if(RS == 0)
	tst R20
	brne L13
	.dbline 307
; 	{
	.dbline 308
; 	 	S_ID &=~ 0x02;
	movw R24,R10
	andi R24,253
	movw R10,R24
	.dbline 309
; 	}
	xjmp L14
L13:
	.dbline 311
; 	else					//if(RS==1)
; 	{
	.dbline 312
; 	 	S_ID |= 0X02;
	movw R24,R10
	ori R24,2
	movw R10,R24
	.dbline 313
; 	}
L14:
	.dbline 314
; 	H_data = W_data;
	ldd R22,y+6
	clr R23
	.dbline 315
; 	H_data &= 0xf0;			//屏蔽低4位的数据
	andi R22,240
	andi R23,0
	.dbline 316
; 	L_data = W_data;	   	//xxxx0000格式
	ldd R20,y+6
	clr R21
	.dbline 317
; 	L_data &= 0x0f;			//屏蔽高4位的数据
	andi R20,15
	andi R21,0
	.dbline 318
; 	L_data <<= 4;			//xxxx0000格式
	lsl R20
	rol R21
	lsl R20
	rol R21
	lsl R20
	rol R21
	lsl R20
	rol R21
	.dbline 319
; 	Set_CS();
	sbi 0x17,5
	.dbline 319
	sbi 0x18,5
	.dbline 320
; 	Write_8bits(S_ID); 		//发送S_ID
	movw R16,R10
	xcall _Write_8bits
	.dbline 321
; 	Write_8bits(H_data);	//发送H_data
	movw R16,R22
	xcall _Write_8bits
	.dbline 322
; 	Write_8bits(L_data);	//发送L_data
	movw R16,R20
	xcall _Write_8bits
	.dbline 323
; 	Clr_CS();	
	sbi 0x17,5
	.dbline 323
	cbi 0x18,5
	.dbline -2
L10:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r H_data 22 i
	.dbsym r S_ID 10 i
	.dbsym r L_data 20 i
	.dbsym l W_data 6 c
	.dbsym r RS 20 c
	.dbsym r RW 22 c
	.dbend
	.dbfunc e Write_8bits _Write_8bits fV
;      Temp_data -> R20,R21
;              i -> R22,R23
;         W_bits -> R10,R11
	.even
_Write_8bits::
	xcall push_gset3
	movw R10,R16
	.dbline -1
	.dbline 335
; }
; /********************************************************************
; 函 数 名:Write_8bits
; 入口参数:W_bits
; 出口参数:无
; 建立日期:2007年3月3日
; 修改日期:
; 函数作用:负责串行输出8个bit位
; 说    明:
; ********************************************************************/
; void Write_8bits(uint W_bits)
; {
	.dbline 337
; 	uint i,Temp_data;
; 	for(i=0; i<8; i++)
	clr R22
	clr R23
	xjmp L19
L16:
	.dbline 338
; 	{
	.dbline 339
; 		Temp_data = W_bits;
	movw R20,R10
	.dbline 340
; 		Temp_data <<= i;
	movw R18,R22
	movw R16,R20
	xcall lsl16
	movw R20,R16
	.dbline 341
; 		if((Temp_data&0x80)==0)
	sbrc R16,7
	rjmp L20
	.dbline 342
; 		{
	.dbline 343
; 		 	Clr_SID();
	sbi 0x17,6
	.dbline 343
	cbi 0x18,6
	.dbline 344
; 		}
	xjmp L21
L20:
	.dbline 346
; 		else
; 		{
	.dbline 347
; 		 	Set_SID();
	sbi 0x17,6
	.dbline 347
	sbi 0x18,6
	.dbline 348
; 		} 
L21:
	.dbline 349
	nop
	.dbline 350
	sbi 0x17,7
	.dbline 350
	sbi 0x18,7
	.dbline 351
	nop
	.dbline 352
	nop
	.dbline 353
	sbi 0x17,7
	.dbline 353
	cbi 0x18,7
	.dbline 354
	nop
	.dbline 355
	sbi 0x17,6
	.dbline 355
	cbi 0x18,6
	.dbline 356
L17:
	.dbline 337
	subi R22,255  ; offset = 1
	sbci R23,255
L19:
	.dbline 337
	cpi R22,8
	ldi R30,0
	cpc R23,R30
	brlo L16
	.dbline -2
L15:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r Temp_data 20 i
	.dbsym r i 22 i
	.dbsym r W_bits 10 i
	.dbend
	.dbfunc e Delay _Delay fV
;              i -> R20,R21
;             ms -> R16,R17
	.even
_Delay::
	xcall push_gset1
	.dbline -1
	.dbline 368
; 		nop();
; 		Set_SCLK();
; 		nop();
; 		nop();
; 		Clr_SCLK();
; 		nop();
; 		Clr_SID();
; 	}
; }
; /********************************************************************
; 函 数 名:Delay
; 入口参数:ms
; 出口参数:无
; 建立日期:2007年3月3日
; 修改日期:
; 函数作用:毫秒级的延时程序,当晶振为12Mhz时,xtal=12;
; 说    明:
; ********************************************************************/
; void Delay(uint ms) 
; { 
	xjmp L24
L23:
	.dbline 371
;     uint i; 
;     while(ms--)    
;    { 
	.dbline 372
;      for(i=1;i<(uint)(xtal*143-2);i++) 
	ldi R20,1
	ldi R21,0
	xjmp L29
L26:
	.dbline 373
L27:
	.dbline 372
	subi R20,255  ; offset = 1
	sbci R21,255
L29:
	.dbline 372
	cpi R20,118
	ldi R30,4
	cpc R21,R30
	brlo L26
	.dbline 374
L24:
	.dbline 370
	movw R2,R16
	subi R16,1
	sbci R17,0
	tst R2
	brne L23
	tst R3
	brne L23
X1:
	.dbline -2
L22:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r ms 16 i
	.dbend
	.dbfunc e Char_Set_XY _Char_Set_XY fV
;              p -> R20,R21
;              y -> R10
;              x -> R22
	.even
_Char_Set_XY::
	xcall push_gset3
	mov R10,R18
	mov R22,R16
	sbiw R28,1
	ldd R20,y+7
	ldd R21,y+8
	.dbline -1
	.dbline 387
;          ; 
;    }   
; }
; //===================================================================*/
; /********************************************************************
; 函 数 名:Char_Set_XY
; 入口参数:x,y,*p
; 出口参数:无
; 建立日期:2007年8月26日
; 修改日期:

⌨️ 快捷键说明

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