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

📄 lcd1602pbpd.lis

📁 一些LCD库 分享给大家了 哈哈~
💻 LIS
📖 第 1 页 / 共 5 页
字号:
 0370                   .dbline 0 ; func end
 0370 5991              ld R21,y+
 0372 4991              ld R20,y+
 0374 0895              ret
                        .area data(ram, con, rel)
 0000           _LCD1602Err::
 0000                   .blkb 1
                        .area idata
 0000 00                .byte 0
                        .area data(ram, con, rel)
                        .area text(rom, con, rel)
                ;        busySta -> R18
                ;    busyCounter -> R16,R17
                        .even
 0376           _busy::
 0376           ; /*********************************************************************
 0376           ; 	微 雪 电 子   WaveShare   http://www.waveShare.net            	
 0376           ; 	                                                        
 0376           ; 目    的:   建立LCD1602的4位数据模式操作库
 0376           ; 
 0376           ; 目标系统:   基于AVR单片机
 0376           ; 	                                                                
 0376           ; 应用软件:   ICCAVR                                               
 0376           ; 	                                                                
 0376           ; 版    本:   Version 1.0
 0376           ; 	                                                                
 0376           ; 圆版时间:   2004-08-25
 0376           ; 
 0376           ; 开发人员:   SEE
 0376           ; 
 0376           ; 说    明:   若用于商业用途,请保留此段文字或注明代码来源
 0376           ; 
 0376           ; 	深 圳 市 微 雪 电 子 有 限 公 司 保 留 所 有 的 版 权 
 0376           ; *********************************************************************/
 0376           ; 
 0376           ; /*01010101010101010101010101010101010101010101010101010101010101010101
 0376           ; ----------------------------------------------------------------------
 0376           ; 版本更新记录:
 0376           ; 	版    本:   Version 1.1
 0376           ; 	圆版时间:   2005-03-25
 0376           ; 
 0376           ; ----------------------------------------------------------------------
 0376           ; 入口参数说明:
 0376           ; 
 0376           ; 	// control port
 0376           ; 	//#define SET_RS  sbi(PORTB,5)
 0376           ; 	//#define CLR_RS  cbi(PORTB,5)
 0376           ; 	//#define OUT_RS  sbi(DDRB,5)
 0376           ;     
 0376           ; 	//#define SET_RW  sbi(PORTB,6)
 0376           ; 	//#define CLR_RW  cbi(PORTB,6)
 0376           ; 	//#define OUT_RW  sbi(DDRB,6)
 0376           ;     
 0376           ; 	//#define SET_E   sbi(PORTB,7)
 0376           ; 	//#define CLR_E   cbi(PORTB,7)
 0376           ; 	//#define OUT_E   sbi(DDRB,7)
 0376           ;     
 0376           ; 	// data port
 0376           ; 	//#define SET_D4  sbi(PORTD,4)
 0376           ; 	//#define CLR_D4  cbi(PORTD,4)
 0376           ; 	//#define OUT_D4  sbi(DDRD,4)
 0376           ;     
 0376           ; 	//#define SET_D5  sbi(PORTD,5)
 0376           ; 	//#define CLR_D5  cbi(PORTD,5)
 0376           ; 	//#define OUT_D5  sbi(DDRD,5)
 0376           ;     
 0376           ; 	//#define SET_D6  sbi(PORTD,6)
 0376           ; 	//#define CLR_D6  cbi(PORTD,6)
 0376           ; 	//#define OUT_D6  sbi(DDRD,6)
 0376           ;     
 0376           ; 	//#define SET_D7  sbi(PORTD,7)
 0376           ; 	//#define CLR_D7  cbi(PORTD,7)
 0376           ; 	//#define OUT_D7  sbi(DDRD,7)
 0376           ;     
 0376           ; 	// busy port
 0376           ; 	//#define GET_BF  gbi(PIND,7)
 0376           ; 	//#define OUT_BF  sbi(DDRD,7)
 0376           ; 	//#define IN_BF	  cbi(DDRD,7)
 0376           ; 	
 0376           ; ----------------------------------------------------------------------
 0376           ; 接口定义:
 0376           ; LCD1602				ATmega16
 0376           ; 1.GND		--------	GND
 0376           ; 2.VCC		--------	VCC
 0376           ; 3.V0		--------	V0
 0376           ; 4.RS		--------	由外部程序定义
 0376           ; 5.R/W		--------	由外部程序定义
 0376           ; 6.E		--------	由外部程序定义
 0376           ; 7.D0		--------	NC
 0376           ; 8.D1		--------	NC
 0376           ; 9.D2		--------	NC
 0376           ; 10.D3		--------	NC
 0376           ; 11.D4		--------	由外部程序定义
 0376           ; 12.D5		--------	由外部程序定义
 0376           ; 13.D6		--------	由外部程序定义
 0376           ; 14.D7		--------	由外部程序定义
 0376           ; 15.LED+		--------	VCC
 0376           ; 16.LED-		--------	GND
 0376           ; 
 0376           ; 说明:
 0376           ; (1)使用ATmega16的7根IO口操作LCD1602
 0376           ; (2)该程序的优点是:7根IO可任意定义,不需分布在固定的一组PORT口上
 0376           ; (3)该程序的缺点是:IO定义的写法较为繁琐
 0376           ; ----------------------------------------------------------------------
 0376           ; 待定参数说明:
 0376           ; 	//#define DELAY()		{_nop_();_nop_();_nop_();}
 0376           ; 
 0376           ; ----------------------------------------------------------------------	
 0376           ; 对外变量说明:
 0376           ; 
 0376           ; ----------------------------------------------------------------------
 0376           ; 对外函数说明:
 0376           ; 
 0376           ; ----------------------------------------------------------------------
 0376           ; 10101010101010101010101010101010101010101010101010101010101010101010*/
 0376           ; 
 0376           ; #ifndef LCD1602_H
 0376           ; #define LCD1602_H
 0376           ; 
 0376           ; #include "D:\ICC_H\CmmICC.H"
 0376           ; 
 0376           ; /* 待定参数 */
 0376           ; #define DELAY()		{NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();}
 0376           ; 
 0376           ; /* 不考虑移植性的写法 */
 0376           ; //uint8 bdata bdat;
 0376           ; //sbit bdat0=bdat^0;
 0376           ; //sbit bdat1=bdat^1;
 0376           ; //sbit bdat2=bdat^2;
 0376           ; //sbit bdat3=bdat^3;
 0376           ; //sbit bdat4=bdat^4;
 0376           ; //sbit bdat5=bdat^5;
 0376           ; //sbit bdat6=bdat^6;
 0376           ; //sbit bdat7=bdat^7;
 0376           ; /* 考虑移植性的写法 */
 0376           ; uint8 bdat;
 0376           ; #define bdat0 (bdat&0x01)
 0376           ; #define bdat1 (bdat&0x02)
 0376           ; #define bdat2 (bdat&0x04)
 0376           ; #define bdat3 (bdat&0x08)
 0376           ; #define bdat4 (bdat&0x10)
 0376           ; #define bdat5 (bdat&0x20)
 0376           ; #define bdat6 (bdat&0x40)
 0376           ; #define bdat7 (bdat&0x80)
 0376           ; 
 0376           ; #define CGRAM0 0x00
 0376           ; #define CGRAM1 0x01
 0376           ; #define CGRAM2 0x02
 0376           ; #define CGRAM3 0x03
 0376           ; #define CGRAM4 0x04
 0376           ; #define CGRAM5 0x05
 0376           ; #define CGRAM6 0x06
 0376           ; #define CGRAM7 0x07
 0376           ; 
 0376           ; #define TRUE	1
 0376           ; #define FALSE	0
 0376           ; bool LCD1602Err = FALSE;
 0376           ; 
 0376           ; /*--------------------------------------------------------------------
 0376           ; 函数名称:LCD1602读读读读读忙~
 0376           ; 函数功能:都说是读读读读读忙咯~
 0376           ; 注意事项:对于高速CPU,应加延时,好像是废话~
 0376           ; 提示说明:无
 0376           ; 输    入:
 0376           ; 返    回:无
 0376           ; --------------------------------------------------------------------*/
 0376           ; void busy(void)
 0376           ; {
 0376           ; 	uint16 busyCounter=0;
 0376 0027              clr R16
 0378 1127              clr R17
 037A           ;       bool busySta;           //用于探测 lcd busy status
 037A           ;       IN_BF;
 037A 8F98              cbi 0x11,7
 037C           ;       SET_D4;
 037C 949A              sbi 0x12,4
 037E           ;       SET_D5;
 037E 959A              sbi 0x12,5
 0380           ;       SET_D6;
 0380 969A              sbi 0x12,6
 0382           ;       SET_D7;
 0382 979A              sbi 0x12,7
 0384           ;       DELAY();
 0384 0000              nop
 0386 0000              nop
 0388 0000              nop
 038A 0000              nop
 038C 0000              nop
 038E 0000              nop
 0390 0000              nop
 0392 0000              nop
 0394           ;       CLR_RS;
 0394 C598              cbi 0x18,5
 0396           ;       DELAY();
 0396 0000              nop
 0398 0000              nop
 039A 0000              nop
 039C 0000              nop
 039E 0000              nop
 03A0 0000              nop
 03A2 0000              nop
 03A4 0000              nop
 03A6           ;       SET_RW;
 03A6 C69A              sbi 0x18,6
 03A8           ;       DELAY();
 03A8 0000              nop
 03AA 0000              nop
 03AC 0000              nop
 03AE 0000              nop
 03B0 0000              nop
 03B2 0000              nop
 03B4 0000              nop
 03B6 0000              nop
 03B8           L122:
 03B8           ; 
 03B8           ; 	do
 03B8           ; 	{
 03B8           ; 		SET_E;   
 03B8 C79A              sbi 0x18,7
 03BA           ;               DELAY();
 03BA 0000              nop
 03BC 0000              nop
 03BE 0000              nop
 03C0 0000              nop
 03C2 0000              nop
 03C4 0000              nop
 03C6 0000              nop
 03C8 0000              nop
 03CA           ; /* 这里读取AC4-AC6位及BF的值,程序不需记录AC4-AC6的值,所以不存储 */
 03CA           ;               busySta=(bool)GET_BF;  
 03CA 20B3              in R18,0x10
 03CC 3327              clr R19
 03CE 2078              andi R18,128
 03D0 3070              andi R19,0
 03D2           ;               CLR_E;
 03D2 C798              cbi 0x18,7
 03D4           ;               DELAY(); 
 03D4 0000              nop
 03D6 0000              nop
 03D8 0000              nop
 03DA 0000              nop
 03DC 0000              nop
 03DE 0000              nop
 03E0 0000              nop
 03E2 0000              nop
 03E4           ; /* 读取 "BUSY"时,"D4-D7"状态可能已经改变,必须再次设为输出"1" */
 03E4           ;               SET_D4;
 03E4 949A              sbi 0x12,4
 03E6           ;               SET_D5;
 03E6 959A              sbi 0x12,5
 03E8           ;               SET_D6;
 03E8 969A              sbi 0x12,6
 03EA           ;               SET_D7;
 03EA 979A              sbi 0x12,7
 03EC           ;               DELAY();
 03EC 0000              nop
 03EE 0000              nop
 03F0 0000              nop
 03F2 0000              nop
 03F4 0000              nop
 03F6 0000              nop
 03F8 0000              nop
 03FA 0000              nop
 03FC           ;               SET_E;   
 03FC C79A              sbi 0x18,7
 03FE           ;               DELAY();
 03FE 0000              nop
 0400 0000              nop
 0402 0000              nop
 0404 0000              nop
 0406 0000              nop
 0408 0000              nop
 040A 0000              nop
 040C 0000              nop
 040E           ; /* 这里读取AC0-AC3位的值,程序不需记录AC0-AC3的值,所以不存储 */
 040E           ;               CLR_E;   
 040E C798              cbi 0x18,7
 0410           ;               DELAY();
 0410 0000              nop
 0412 0000              nop
 0414 0000              nop
 0416 0000              nop
 0418 0000              nop
 041A 0000              nop
 041C 0000              nop
 041E 0000              nop
 0420           ;               if(busyCounter==1000)
 0420 083E              cpi R16,232
 0422 E3E0              ldi R30,3
 0424 1E07              cpc R17,R30
 0426 21F4              brne L125
 0428           X44:
 0428           ; 		{
 0428           ; 			LCD1602Err=TRUE;	//标识LCD1602错误,方便上缴系统报错
 0428 81E0              ldi R24,1
 042A 80930000          sts _LCD1602Err,R24
 042E           ;                       return ;                        //避免由于LCD1602错误而导致程序阻塞
 042E 0AC0              xjmp L121
 0430           L125:
 0430           ; 		}
 0430           ; 		busyCounter++;
 0430 0F5F              subi R16,255  ; offset = 1
 0432 1F4F              sbci R17,255
 0434           ;       }
 0434           L123:
 0434           ; 	while(busySta);
 0434 2223              tst R18
 0436 09F0              breq X46
 0438 BFCF              xjmp L122
 043A           X46:
 043A           X45:
 043A           ; 
 043A           ; 	LCD1602Err=FALSE;
 043A 2224              clr R2

⌨️ 快捷键说明

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