cycle.lst

来自「ATmega16应用例子」· LST 代码 · 共 2,013 行 · 第 1/5 页

LST
2,013
字号
(0330) 		return I2C_ERR;
    01CD 2700      CLR	R16
    01CE C015      RJMP	0x01E4
(0331) 
(0332) 	if( I2C_Restart()==I2C_ERR )
    01CF DF3E      RCALL	_I2C_Restart
    01D0 2300      TST	R16
    01D1 F411      BNE	0x01D4
(0333) 		return I2C_ERR;
    01D2 2700      CLR	R16
    01D3 C010      RJMP	0x01E4
(0334) 
(0335) 	if( I2C_SendRdDAdr(rdDAdr)==I2C_ERR )
    01D4 810C      LDD	R16,Y+4
    01D5 DF6D      RCALL	_I2C_SendRdDAdr
    01D6 2300      TST	R16
    01D7 F411      BNE	0x01DA
(0336) 		return I2C_ERR;
    01D8 2700      CLR	R16
    01D9 C00A      RJMP	0x01E4
(0337) 
(0338) 	if( I2C_RcvNAckDat(pRdDat)==I2C_ERR )
    01DA 810E      LDD	R16,Y+6
    01DB 811F      LDD	R17,Y+7
    01DC DF9C      RCALL	_I2C_RcvNAckDat
    01DD 2300      TST	R16
    01DE F411      BNE	0x01E1
(0339) 		return I2C_ERR;
    01DF 2700      CLR	R16
    01E0 C003      RJMP	0x01E4
(0340) 
(0341) 	I2C_Stop();
    01E1 E984      LDI	R24,0x94
    01E2 BF86      OUT	0x36,R24
(0342) 
(0343) 	return I2C_CRR;
    01E3 E001      LDI	R16,1
    01E4 940E07C8  CALL	pop_gset2
    01E6 9508      RET
_I2C_Read_:
  i                    --> R20
  num                  --> R22
  pRdDat               --> R10
  rdDAdr               --> Y+8
  wordAdr              --> R20
  wrDAdr               --> R12
    01E7 940E07D3  CALL	push_gset4
    01E9 2F42      MOV	R20,R18
    01EA 0168      MOVW	R12,R16
    01EB 84AA      LDD	R10,Y+10
    01EC 84BB      LDD	R11,Y+11
    01ED 856C      LDD	R22,Y+12
(0344) }
(0345) /*--------------------------------------------------------------------
(0346) 函数名称:I2C读器件,读N个数据
(0347) 函数功能:
(0348) 注意事项:
(0349) 提示说明:
(0350) 输    入:wrDAdr: write device-address 写器件地址
(0351) 		 wordAdr: word address 字地址
(0352) 		 rdDAdr: read device-address 读器件地址
(0353) 		 *pRdDat: p->read data 读取数据指针
(0354) 		 num: number 读取数据个数
(0355) 返    回:
(0356) --------------------------------------------------------------------*/
(0357) bool I2C_Read_(uint16 wrDAdr,uint8 wordAdr,
(0358) 			   uint8 rdDAdr,uint8 *pRdDat,uint8 num)
(0359) {
(0360)  	uint8 i;
(0361) 	
(0362) 	if( I2C_Start()==I2C_ERR )
    01EE DF12      RCALL	_I2C_Start
    01EF 2300      TST	R16
    01F0 F411      BNE	0x01F3
(0363) 		return I2C_ERR;
    01F1 2700      CLR	R16
    01F2 C033      RJMP	0x0226
(0364) 
(0365) 	if( I2C_SendWrDAdr_(wrDAdr)==I2C_ERR )
    01F3 0186      MOVW	R16,R12
    01F4 DF34      RCALL	_I2C_SendWrDAdr_
    01F5 2300      TST	R16
    01F6 F411      BNE	0x01F9
(0366) 		return I2C_ERR;
    01F7 2700      CLR	R16
    01F8 C02D      RJMP	0x0226
(0367) 
(0368) 	if( I2C_SendDat(wordAdr)==I2C_ERR )
    01F9 2F04      MOV	R16,R20
    01FA DF70      RCALL	_I2C_SendDat
    01FB 2300      TST	R16
    01FC F411      BNE	0x01FF
(0369) 		return I2C_ERR;
    01FD 2700      CLR	R16
    01FE C027      RJMP	0x0226
(0370) 
(0371) 	if( I2C_Restart()==I2C_ERR )
    01FF DF0E      RCALL	_I2C_Restart
    0200 2300      TST	R16
    0201 F411      BNE	0x0204
(0372) 		return I2C_ERR;
    0202 2700      CLR	R16
    0203 C022      RJMP	0x0226
(0373) 
(0374) 	if( I2C_SendRdDAdr(rdDAdr)==I2C_ERR )
    0204 8508      LDD	R16,Y+8
    0205 DF3D      RCALL	_I2C_SendRdDAdr
    0206 2300      TST	R16
    0207 F411      BNE	0x020A
(0375) 		return I2C_ERR;
    0208 2700      CLR	R16
    0209 C01C      RJMP	0x0226
(0376) 
(0377) 	for(i=0;i<num-1;i++)
    020A 2744      CLR	R20
    020B C00A      RJMP	0x0216
(0378) 		if( I2C_RcvAckDat(pRdDat+i)==I2C_ERR )
    020C 2F04      MOV	R16,R20
    020D 2711      CLR	R17
    020E 0D0A      ADD	R16,R10
    020F 1D1B      ADC	R17,R11
    0210 DF78      RCALL	_I2C_RcvAckDat
    0211 2300      TST	R16
    0212 F411      BNE	0x0215
(0379) 			return I2C_ERR;
    0213 2700      CLR	R16
    0214 C011      RJMP	0x0226
    0215 9543      INC	R20
    0216 2F86      MOV	R24,R22
    0217 5081      SUBI	R24,1
    0218 1748      CP	R20,R24
    0219 F390      BCS	0x020C
(0380) 	
(0381) 	if( I2C_RcvNAckDat(pRdDat+i)==I2C_ERR )
    021A 2F04      MOV	R16,R20
    021B 2711      CLR	R17
    021C 0D0A      ADD	R16,R10
    021D 1D1B      ADC	R17,R11
    021E DF5A      RCALL	_I2C_RcvNAckDat
    021F 2300      TST	R16
    0220 F411      BNE	0x0223
(0382) 			return I2C_ERR;
    0221 2700      CLR	R16
    0222 C003      RJMP	0x0226
(0383) 
(0384) 	I2C_Stop();
    0223 E984      LDI	R24,0x94
    0224 BF86      OUT	0x36,R24
(0385) 	
(0386) 	return I2C_CRR;
    0225 E001      LDI	R16,1
    0226 940E07CB  CALL	pop_gset4
    0228 9508      RET
_delay50us:
  j                    --> R20
  t                    --> R16
    0229 940E07D9  CALL	push_gset1
FILE: D:\ICC_H\Hardware.H
(0001) /*********************************************************************
(0002) 	微 雪 电 子   WaveShare   http://www.waveShare.net            	
(0003) 		                                                        
(0004) 目    的:   建立AVR的硬件提取库,增加各类补丁,方便移植
(0005) 					
(0006) 目标系统:   基于AVR单片机
(0007) 		                                                                
(0008) 应用软件:   ICCAVR
(0009) 		                                                                
(0010) 版    本:   Version 1.0                                                          
(0011) 		                                                                
(0012) 圆版时间:   2005-06-25
(0013) 	
(0014) 开发人员:   SEE(中文名不告诉你~怕你骂我)
(0015) 
(0016) 说    明:   若用于商业用途,请保留此段文字或注明代码来源
(0017) 	
(0018) 	深 圳 微 雪 电 子 保 留 所 有 的 版 权     
(0019) *********************************************************************/
(0020) 
(0021) /*01010101010101010101010101010101010101010101010101010101010101010101
(0022) ----------------------------------------------------------------------
(0023) 版本更新记录:
(0024) 
(0025) ----------------------------------------------------------------------
(0026) 入口参数说明:
(0027) 
(0028) ----------------------------------------------------------------------
(0029) 待定参数说明:
(0030) 
(0031) ----------------------------------------------------------------------	
(0032) 对外变量说明:
(0033)     
(0034) ----------------------------------------------------------------------
(0035) 对外函数说明:
(0036)    
(0037) ----------------------------------------------------------------------
(0038) 10101010101010101010101010101010101010101010101010101010101010101010*/
(0039) 
(0040) #ifndef Hardware_H
(0041) #define Hardware_H
(0042) 
(0043) #include <math.h>
(0044) #include <string.h>
(0045) #include <stdio.h>
(0046) #include <macros.h>
(0047) #include <eeprom.h>
(0048) //#include <wdt.h>
(0049) #include "D:\ICC_H\I2C.H"	//i2c即AVR的"twi"
(0050) 
(0051) /* hard configs */
(0052) #ifndef flash
(0053) 	#define flash	const
(0054) #endif
(0055) 
(0056) #ifndef code
(0057) 	#define code	const
(0058) #endif
(0059) 
(0060) #ifndef NOP
(0061) 	#define NOP()	asm("nop")
(0062) #endif
(0063) 
(0064) /* io configs */
(0065) #define sbi(io,bit)		(  io |=  (1<<bit) )	//example: sbi(PORTA,0);sbi(DDRA,0);
(0066) #define cbi(io,bit)		(  io &= ~(1<<bit) )	//example: cbi(PORTA,0);cbi(DDRA,0);
(0067) #define gbi(pin ,bit)	( pin &   (1<<bit) )	//example: gbi(PINA,0);
(0068) 
(0069) /* interrupt configs */
(0070) #define DIS_INT  asm("sei")
(0071) #define EN_INT   asm("cli")
(0072) 
(0073) /* wdt configs */
(0074) #define WDT()    asm("wdr")
(0075) 
(0076) /* bit operation */
(0077) //#ifndef BIT
(0078) //#define BIT(x)	( 1<<(x) )
(0079) //#endif
(0080) 
(0081) /* USART configs for 4 Mhz crystal */
(0082) //#define BAUD9600			25
(0083) //#define BAUD19000			12
(0084) //#define UART_TRAN_ON()	UCR |=  0x08
(0085) //#define UART_TRAN_OFF()	UCR &= ~0x08
(0086) //#define UART_RCV_ON()		UCR |=  0x10
(0087) //#define UART_RCV_OFF()	UCR &= ~0x10
(0088) 
(0089) /*--------------------------------------------------------------------
(0090) 函数全称:50us 延时
(0091) 函数功能:当然是 50us延时 啦
(0092) 注意事项:基于7.3728M晶振,稍微有点误差
(0093) 提示说明:调用Delay50us(20),得到1ms延时
(0094) 输    入:	
(0095) 返    回:无 
(0096) --------------------------------------------------------------------*/
(0097) void delay50us(sint16 t)
(0098) {
(0099)     uint8 j;		
(0100)     for(;t>0;t--)			
    022B C007      RJMP	0x0233
(0101)         for(j=0;j<70;j++)	
    022C 2744      CLR	R20
    022D C001      RJMP	0x022F
    022E 9543      INC	R20
    022F 3446      CPI	R20,0x46
    0230 F3E8      BCS	0x022E
    0231 5001      SUBI	R16,1
    0232 4010      SBCI	R17,0
    0233 2422      CLR	R2
    0234 2433      CLR	R3
    0235 1620      CP	R2,R16
    0236 0631      CPC	R3,R17
    0237 F3A4      BLT	0x022C
    0238 940E07DC  CALL	pop_gset1
    023A 9508      RET
_delay50ms:
  i                    --> R20
  t                    --> R16
    023B 940E07D9  CALL	push_gset1
(0102)             ;
(0103) }
(0104) /*--------------------------------------------------------------------
(0105) 函数全称:50ms 延时
(0106) 函数功能:当然是 50ms延时 啦
(0107) 注意事项:基于7.3728M晶振,稍微有点误差
(0108) 提示说明:调用delay50ms(20),得到1s延时 
(0109) 输    入:
(0110) 返    回:无
(0111) --------------------------------------------------------------------*/
(0112) void delay50ms(sint16 t)
(0113) {
(0114) 	uint16 i; 
(0115) 	for(;t>0;t--)
    023D C00B      RJMP	0x0249
(0116) 		for(i=0;i<52642;i++)
    023E 2744      CLR	R20
    023F 2755      CLR	R21
    0240 C002      RJMP	0x0243
    0241 5F4F      SUBI	R20,0xFF
    0242 4F5F      SBCI	R21,0xFF
    0243 3A42      CPI	R20,0xA2
    0244 ECED      LDI	R30,0xCD
    0245 075E      CPC	R21,R30
    0246 F3D0      BCS	0x0241
    0247 5001      SUBI	R16,1
    0248 4010      SBCI	R17,0
    0249 2422      CLR	R2
    024A 2433      CLR	R3
    024B 1620      CP	R2,R16
    024C 0631      CPC	R3,R17
    024D F384      BLT	0x023E
    024E 940E07DC  CALL	pop_gset1
    0250 9508      RET
FILE: D:\ICC_H\LCD1602_.H
(0001) /*********************************************************************
(0002) 	微 雪 电 子   WaveShare   http://www.waveShare.net            	
(0003) 	                                                        
(0004) 目    的:   建立LCD1602操作库
(0005) 
(0006) 目标系统:   基于AVR单片机
(0007) 	                                                                
(0008) 应用软件:   ICCAVR                                               
(0009) 	                                                                
(0010) 版    本:   Version 1.0
(0011) 	                                                                
(0012) 圆版时间:   2004-08-25
(0013) 
(0014) 开发人员:   SEE(中文名不告诉你~怕你骂我)
(0015) 
(0016) 说    明:   若用于商业用途,请保留此段文字或注明代码来源
(0017) 
(0018) 	深 圳 微 雪 电 子 保 留 所 有 的 版 权 
(0019) *********************************************************************/
(0020) 
(0021) /*01010101010101010101010101010101010101010101010101010101010101010101
(0022) ----------------------------------------------------------------------
(0023) 版本更新记录:
(0024) 	版    本:   Version 1.1
(0025) 	圆版时间:   2005-03-25
(0026) 
(0027) ----------------------------------------------------------------------
(0028) 入口参数说明:
(0029) 
(0030) 	// lcd control and data port direction //
(0031) 	#define LCD_DDR_OUT {DDRA|= 0xF0;DDRD |= 0xE0;}
(0032) 
(0033) 	// control port //
(0034) 	#define SET_RS  sbi(PORTD,5)
(0035) 	#define CLR_RS  cbi(PORTD,5)
(0036) 	#define SET_RW  sbi(PORTD,6)
(0037) 	#define CLR_RW  cbi(PORTD,6)
(0038) 	#define SET_E   sbi(PORTD,7)
(0039) 	#define CLR_E   cbi(PORTD,7)
(0040) 
(0041) 	// data port //
(0042) 	#define SET_D4  sbi(PORTA,4)
(0043) 	#define CLR_D4  cbi(PORTA,4)
(0044) 	#define SET_D5  sbi(PORTA,5)
(0045) 	#define CLR_D5  cbi(PORTA,5)
(0046) 	#define SET_D6  sbi(PORTA,6)
(0047) 	#define CLR_D6  cbi(PORTA,6)
(0048) 	#define SET_D7  sbi(PORTA,7)
(0049) 	#define CLR_D7  cbi(PORTA,7)
(0050) 
(0051) 	// busy port //
(0052) 	#define GET_BF	gbi(PINA,7)
(0053) 	#define OUT_BF	sbi(DDRA,7)
(0054) 	#define IN_BF	cbi(DDRA,7)
(0055) 
(0056) ----------------------------------------------------------------------
(0057) 待定参数说明:
(0058) 	#define DELAY()		{_nop_();_nop_();_nop_();}
(0059) 
(0060) ----------------------------------------------------------------------	
(0061) 对外变量说明:
(0062) 
(0063) ----------------------------------------------------------------------
(0064) 对外函数说明:
(0065) 
(0066) ----------------------------------------------------------------------
(0067) 10101010101010101010101010101010101010101010101010101010101010101010*/
(0068) 
(0069) #ifndef LCD1602_H
(0070) #define LCD1602_H
(0071) 
(0072) #include "D:\ICC_H\CmmICC.H"
(0073) 
(0074) /* 待定参数 */
(0075) #define DELAY()		{NOP();NOP();NOP();NOP();NOP();NOP();NOP();NOP();}
(0076) 
(0077) /* 不考虑移植性的写法 */
(0078) //uint8 bdata bdat;
(0079) //sbit bdat0=bdat^0;
(0080) //sbit bdat1=bdat^1;
(0081) //sbit bdat2=bdat^2;
(0082) //sbit bdat3=bdat^3;
(0083) //sbit bdat4=bdat^4;
(0084) //sbit bdat5=bdat^5;
(0085) //sbit bdat6=bdat^6;
(0086) //sbit bdat7=bdat^7;
(0087) /* 考虑移植性的写法 */
(0088) uint8 bdat;
(0089) #define bdat0 (bdat&0x01)
(0090) #define bdat1 (bdat&0x02)

⌨️ 快捷键说明

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