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

📄 lcd1602pbpd.s

📁 一些LCD库 分享给大家了 哈哈~
💻 S
📖 第 1 页 / 共 5 页
字号:
	xcall push_xgset003C
	movw R10,R18
	mov R12,R16
; }
; /*--------------------------------------------------------------------
; 函数名称:输出一个字符串
; 函数功能:
; 注意事项:无
; 提示说明:调用LCD1602_puts(0x80,"waveShare"),则从第一行第一个位置开始输出"waveShare"
; 输    入:
; 返    回:无
; --------------------------------------------------------------------*/
; void LCD1602_puts(uint8 startAdr,uint8 *str)
; {
; 	/*
; 	while(*str)
; 	{
; 		LCD1602_putc(addr++,*str++);
; 	}
; 	*/
; 	//LCD1602_setCmd("AC++");
; 	write(0,startAdr);
	mov R18,R12
	clr R16
	xcall _write
	xjmp L253
L252:
; 	while(*str)
; 		write(1,*str++);
	movw R30,R10
	ld R18,Z+
	movw R10,R30
	ldi R16,1
	xcall _write
L253:
	movw R30,R10
	ldd R2,z+0
	tst R2
	brne L252
X95:
L251:
	.dbline 0 ; func end
	xjmp pop_xgset003C
;              i -> R20
;         length -> R20
;            dat -> y+3
;         endAdr -> R10
	.even
_LCD1602_putd0::
	st -y,r19
	st -y,r18
	st -y,R10
	st -y,R20
	mov R10,R16
	sbiw R28,1
	ldd R20,y+7
; }
; /*--------------------------------------------------------------------
; 函数名称:输出一个数值(带0)
; 函数功能:有时候你可能不是需要"123",而是需要"00123"吧
; 注意事项:无
; 提示说明:调用LCD1602_putd0(0x8F,123,5),则从0x8B开始到0X8F输出"00123"
; 输    入:
; 返    回:无
; --------------------------------------------------------------------*/
; //for example:dat=123,length=6,output 000123 
; void LCD1602_putd0(uint8 endAdr,uint32 dat,uint8 length)
; {
; 	sint8 i;
; 	speaData(dat,length);
	std y+0,R20
	ldd R16,y+3
	ldd R17,y+4
	ldd R18,y+5
	ldd R19,y+6
	xcall _speaData
; 	//LCD1602_setCmd("AC++");
; 	write(0,endAdr-length+1);
	mov R18,R10
	sub R18,R20
	subi R18,255    ; addi 1
	clr R16
	xcall _write
; 	for(i=length-1;i>=0;i--)
	subi R20,1
	xjmp L259
L256:
; 		write(1,dataElem[i]+0x30);
	ldi R24,<_dataElem
	ldi R25,>_dataElem
	mov R30,R20
	clr R31
	sbrc R30,7
	com R31
	add R30,R24
	adc R31,R25
	ldd R18,z+0
	subi R18,208    ; addi 48
	ldi R16,1
	xcall _write
L257:
	dec R20
L259:
	cpi R20,0
	brge L256
X96:
L255:
	.dbline 0 ; func end
	adiw R28,1
	ld R20,y+
	ld R10,y+
	adiw R28,2
	ret
;      effectLen -> R22
;              i -> R20
;         length -> R12
;            dat -> y+9
;         endAdr -> R10
	.even
_LCD1602_putd::
	st -y,r19
	st -y,r18
	xcall push_xgsetF03C
	mov R10,R16
	sbiw R28,1
	ldd R12,y+13
; }
; /*--------------------------------------------------------------------
; 函数名称:输出一个数值(不带0)
; 函数功能:
; 注意事项:无
; 提示说明:调用LCD1602_putd(0x8F,123,5),则从0x8B开始到0X8F输出"  123"
; 输    入:
; 返    回:无
; --------------------------------------------------------------------*/
; void LCD1602_putd(uint8 endAdr,uint32 dat,uint8 length)
; {
; 	sint8 i;
; 	sint8 effectLen;
; 	if(dat>999999)
	ldi R24,63
	ldi R25,66
	ldi R26,15
	ldi R27,0
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	cp R24,R2
	cpc R25,R3
	cpc R26,R4
	cpc R27,R5
	brsh L261
X97:
;  		effectLen=7;
	ldi R22,7
	xjmp L262
L261:
; 	else if(dat>99999)
	ldi R24,159
	ldi R25,134
	ldi R26,1
	ldi R27,0
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	cp R24,R2
	cpc R25,R3
	cpc R26,R4
	cpc R27,R5
	brsh L263
X98:
;  		effectLen=6;
	ldi R22,6
	xjmp L264
L263:
; 	else if(dat>9999)
	ldi R24,15
	ldi R25,39
	ldi R26,0
	ldi R27,0
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	cp R24,R2
	cpc R25,R3
	cpc R26,R4
	cpc R27,R5
	brsh L265
X99:
;  		effectLen=5;
	ldi R22,5
	xjmp L266
L265:
; 	else if(dat>999)
	ldi R24,231
	ldi R25,3
	ldi R26,0
	ldi R27,0
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	cp R24,R2
	cpc R25,R3
	cpc R26,R4
	cpc R27,R5
	brsh L267
X100:
;  		effectLen=4;
	ldi R22,4
	xjmp L268
L267:
; 	else if(dat>99)
	ldi R24,99
	ldi R25,0
	ldi R26,0
	ldi R27,0
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	cp R24,R2
	cpc R25,R3
	cpc R26,R4
	cpc R27,R5
	brsh L269
X101:
;  		effectLen=3;
	ldi R22,3
	xjmp L270
L269:
; 	else if(dat>9)
	ldi R24,9
	ldi R25,0
	ldi R26,0
	ldi R27,0
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	cp R24,R2
	cpc R25,R3
	cpc R26,R4
	cpc R27,R5
	brsh L271
X102:
;  		effectLen=2;
	ldi R22,2
	xjmp L272
L271:
; 	else
;  		effectLen=1;
	ldi R22,1
L272:
L270:
L268:
L266:
L264:
L262:
; 	speaData(dat,effectLen);
	std y+0,R22
	ldd R16,y+9
	ldd R17,y+10
	ldd R18,y+11
	ldd R19,y+12
	xcall _speaData
; 	//LCD1602_setCmd("AC++");
; 	if(length>effectLen)
	mov R2,R22
	clr R3
	sbrc R2,7
	com R3
	mov R4,R12
	clr R5
	cp R2,R4
	cpc R3,R5
	brge L273
X103:
; 	{
; 		write(0,endAdr-length+1);
	mov R18,R10
	sub R18,R4
	subi R18,255    ; addi 1
	clr R16
	xcall _write
; 		for(i=length-effectLen-1;i>=0;i--)
	mov R20,R12
	sub R20,R22
	subi R20,1
	xjmp L278
L275:
; 			write(1,' ');
	ldi R18,32
	ldi R16,1
	xcall _write
L276:
	dec R20
L278:
	cpi R20,0
	brge L275
X104:
; 	}
L273:
; 	for(i=effectLen-1;i>=0;i--)
	mov R20,R22
	subi R20,1
	xjmp L282
L279:
; 	{
; 		if(i==0||dataElem[i])
	tst R20
	breq L285
X105:
	ldi R24,<_dataElem
	ldi R25,>_dataElem
	mov R30,R20
	clr R31
	sbrc R30,7
	com R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	tst R2
	breq L283
X106:
L285:
; 		{
; 			write(0,endAdr-i);
	mov R18,R10
	sub R18,R20
	clr R16
	xcall _write
; 			for(;i>=0;i--)
	xjmp L289
L286:
; 				write(1,dataElem[i]+0x30);
	ldi R24,<_dataElem
	ldi R25,>_dataElem
	mov R30,R20
	clr R31
	sbrc R30,7
	com R31
	add R30,R24
	adc R31,R25
	ldd R18,z+0
	subi R18,208    ; addi 48
	ldi R16,1
	xcall _write
L287:
	dec R20
L289:
	cpi R20,0
	brge L286
X107:
; 		}
L283:
; 	}
L280:
	dec R20
L282:
	cpi R20,0
	brge L279
X108:
L260:
	.dbline 0 ; func end
	adiw R28,1
	xcall pop_xgsetF03C
	adiw R28,2
	ret
	.area lit(rom, con, rel)
_userCh0::
	.byte 16,31
	.byte 1,2
	.byte 4,8
	.byte 16,31
_userCh1::
	.byte 0,8
	.byte 15,1
	.byte 2,4
	.byte 8,15
_userCh2::
	.byte 0,0
	.byte 4,7
	.byte 1,2
	.byte 4,7
	.area text(rom, con, rel)
;              a -> R20,R21
;              b -> R22,R23
;          delay -> <dead>
	.even
_delays::
	st -y,r17
	st -y,r16
	xcall push_xgsetF000
; /*********************************************************************
; 	微 雪 电 子   WaveShare   http://www.waveShare.net	
; 
; 功能目的:   建立使用LCD1602的示例程序
; 
; 目标系统:   基于AVR单片机
; 
; 应用软件:   ICCAVR                                               
; 
; 版    本:   Version 1.0
; 
; 圆版时间:   2005-03-01
; 
; 开发人员:   SEE
; 
; 说    明:   若用于商业用途,请保留此段文字或注明代码来源 
; 
; 	深 圳 市 微 雪 电 子 有 限 公 司 保 留 所 有 的 版 权
; *********************************************************************/
; 
; /*01010101010101010101010101010101010101010101010101010101010101010101
; ----------------------------------------------------------------------
; 版本更新记录:
; 
; ----------------------------------------------------------------------
; 实验内容:
; 初始化、读写Lcd1602。
; ----------------------------------------------------------------------
; 硬件连接:
; 将Lcd1602插入主板的Lcd1602插槽,
; 使用连接线将LCD1602的引针接口连接到MCU:
; //LCD1602,4位接口,即使用D4-D7数据口,D0-D3不接入MCU
; //PIN1 --- GND
; //PIN2 --- VCC
; //PIN3 --- V0
; //PIN4 --- RS --- PB5
; //PIN5 --- R/W --- PB6
; //PIN6 --- E --- PB7
; //PIN7 --- D0
; //PIN8 --- D1
; //PIN9 --- D2
; //PIN10 --- D3
; //PIN11 --- D4 --- PD4
; //PIN12 --- D5 --- PD5
; //PIN13 --- D6 --- PD6
; //PIN14 --- D7 --- PD7
; //PIN15 --- VCC
; //PIN16 --- GND
; ----------------------------------------------------------------------
; 注意事项: 
; (1)若有加载库函数,请将光盘根目录下的“库函数”下的“ICC_H”文件夹拷到D盘
; (2)请详细阅读:光盘根目录下的“产品资料\开发板实验板\SMK系列\SMK1632\说明资料”
; ----------------------------------------------------------------------
; 10101010101010101010101010101010101010101010101010101010101010101010*/
; 
; #include <iom16v.h>
; #include "D:\ICC_H\CmmICC.H"
; 
; /* control port */
; #define SET_RS  sbi(PORTB,5)
; #define CLR_RS  cbi(PORTB,5)
; #define OUT_RS  sbi(DDRB,5)
; 
; #define SET_RW  sbi(PORTB,6)
; #define CLR_RW  cbi(PORTB,6)
; #define OUT_RW  sbi(DDRB,6)
; 
; #define SET_E   sbi(PORTB,7)
; #define CLR_E   cbi(PORTB,7)
; #define OUT_E   sbi(DDRB,7)
; 
; /* data port */
; #define SET_D4  sbi(PORTD,4)
; #define CLR_D4  cbi(PORTD,4)
; #define OUT_D4  sbi(DDRD,4)
; 
; #define SET_D5  sbi(PORTD,5)
; #define CLR_D5  cbi(PORTD,5)
; #define OUT_D5  sbi(DDRD,5)
; 
; #define SET_D6  sbi(PORTD,6)
; #define CLR_D6  cbi(PORTD,6)
; #define OUT_D6  sbi(DDRD,6)
; 
; #define SET_D7  sbi(PORTD,7)
; #define CLR_D7  cbi(PORTD,7)
; #define OUT_D7  sbi(DDRD,7)
; 
; /* busy port */
; #define GET_BF	gbi(PIND,7)
; #define OUT_BF	sbi(DDRD,7)
; #define IN_BF	cbi(DDRD,7)
; 
; #include "D:\ICC_H\LCD1602_.H"
; 
; const uint8  userCh0[8]={0x10,0x1f,0x01,0x02,0x04,0x08,0x10,0x1f};
; const uint8  userCh1[8]={0x00,0x08,0x0f,0x01,0x02,0x04,0x08,0x0f};
; const uint8  userCh2[8]={0x00,0x00,0x04,0x07,0x01,0x02,0x04,0x07};
; 
; /*--------------------------------------------------------------------
; 函数全称:
; 函数功能:
; 注意事项:
; 提示说明:
; 输    入:	
; 返    回:
; --------------------------------------------------------------------*/
; void delays(unsigned int delay)
; {unsigned int a,b;
; for(a=0;a<0;a++)
	clr R20
	clr R21
	xjmp L294
L291:
;  for(b=0;b<10000;b++);
	clr R22
	clr R23
	xjmp L298
L295:
L296:
	subi R22,255  ; offset = 1
	sbci R23,255
L298:
	cpi R22,16
	ldi R30,39
	cpc R23,R30
	brlo L295
X109:
L292:
	subi R20,255  ; offset = 1
	sbci R21,255
L294:
	clr R2
	brne L291
X110:
L290:
	.dbline 0 ; func end
	xcall pop_xgsetF000
	adiw R28,2
	ret
	.even
_main::
; }
; void main()
; {
; 
; 	LCD1602_init();
	xcall _LCD1602_init
	xjmp L301
L300:
; 
; 	while(1)
; 	{
; 		LCD1602_puts(0xC6,"Sleeping");
	ldi R18,<L303
	ldi R19,>L303
	ldi R16,198
	xcall _LCD1602_puts
; 		delays(10);
	ldi R16,10
	ldi R17,0
	xcall _delays
; 		LCD1602_setCmd("CLR_SCR");
	ldi R16,<L159
	ldi R17,>L159
	xcall _LCD1602_setCmd
; 		delays(10);
	ldi R16,10
	ldi R17,0
	xcall _delays
; 		LCD1602_puts(0xC6,"Sleeping");
	ldi R18,<L303
	ldi R19,>L303
	ldi R16,198
	xcall _LCD1602_puts
; 		delays(10);
	ldi R16,10
	ldi R17,0
	xcall _delays
; 		LCD1602_setCmd("CLR_SCR");
	ldi R16,<L159
	ldi R17,>L159
	xcall _LCD1602_setCmd
; 		delays(10);
	ldi R16,10
	ldi R17,0
	xcall _delays
; 		LCD1602_puts(0xC6,"Sleeping");
	ldi R18,<L303
	ldi R19,>L303
	ldi R16,198
	xcall _LCD1602_puts
; 		delays(10);
	ldi R16,10
	ldi R17,0
	xcall _delays
; 
; 		LCD1602_setCGRAM(CGRAM0,userCh0);	//Set CGRAM0' data
	ldi R18,<_userCh0
	ldi R19,>_userCh0
	clr R16
	xcall _LCD1602_setCGRAM
; 		LCD1602_setCGRAM(CGRAM1,userCh1);	//Set CGRAM1' data
	ldi R18,<_userCh1
	ldi R19,>_userCh1
	ldi R16,1
	xcall _LCD1602_setCGRAM
; 		LCD1602_setCGRAM(CGRAM2,userCh2);	//Set CGRAM2' data
	ldi R18,<_userCh2
	ldi R19,>_userCh2
	ldi R16,2
	xcall _LCD1602_setCGRAM
; 		
; 		LCD1602_putc(0x84,CGRAM2);		//putc to 0x84 by CGRAM2' data
	ldi R18,2
	ldi R16,132
	xcall _LCD1602_putc
; 		delay50ms(10);
	ldi R16,10
	ldi R17,0
	xcall _delay50ms
; 		LCD1602_putc(0x83,CGRAM1);		//putc to 0x83 by CGRAM1' data
	ldi R18,1
	ldi R16,131
	xcall _LCD1602_putc
; 		delay50ms(12);
	ldi R16,12
	ldi R17,0
	xcall _delay50ms
; 		LCD1602_putc(0x82,CGRAM0);		//putc to 0x84 by CGRAM0' data
	clr R18
	ldi R16,130
	xcall _LCD1602_putc
; 		delay50ms(14);
	ldi R16,14
	ldi R17,0
	xcall _delay50ms
; 
; 		LCD1602_setCmd("CLR_SCR");
	ldi R16,<L159
	ldi R17,>L159
	xcall _LCD1602_setCmd
; 	}
L301:
	xjmp L300
X111:
L299:
	.dbline 0 ; func end
	ret
	.area bss(ram, con, rel)
_bdat::
	.blkb 1
_dataElem::
	.blkb 6
	.area data(ram, con, rel)
L303:
	.blkb 9
	.area idata
	.byte 'S,'l,'e,'e,'p,'i,'n,'g,0
	.area data(ram, con, rel)
L248:
	.blkb 10
	.area idata
	.byte 'L,'E,'F,'T,95,'C,'U,'R,'S,0
	.area data(ram, con, rel)
L245:
	.blkb 11
	.area idata
	.byte 'R,'I,'G,'H,'T,95,'C,'U,'R,'S,0
	.area data(ram, con, rel)
L242:
	.blkb 9
	.area idata
	.byte 'L,'E,'F,'T,95,'S,'C,'R,0
	.area data(ram, con, rel)
L239:
	.blkb 10
	.area idata
	.byte 'R,'I,'G,'H,'T,95,'S,'C,'R,0
	.area data(ram, con, rel)
L230:
	.blkb 10
	.area idata
	.byte 'D,'I,'S,95,'B,'L,'I,'N,'K,0
	.a

⌨️ 快捷键说明

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