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

📄 main.s

📁 ds18b20在数码管上显示温度,在avr128已编译通过
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module MAIN.C
	.area text(rom, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
_led_table::
	.blkb 2
	.area idata
	.byte 192,249
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 164,176
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 153,146
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 130,248
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 128,144
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 136,131
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 167,161
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 134,142
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 139,137
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 163,140
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 199,175
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 145,191
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.blkb 2
	.area idata
	.byte 247,255
	.area data(ram, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\MAIN.C
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\define.h
	.dbsym e led_table _led_table A[26:26]c
	.area text(rom, con, rel)
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\define.h
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\delay.h
	.dbfunc e Delay_1us _Delay_1us fV
;              t -> R16
	.even
_Delay_1us::
	.dbline -1
	.dbline 53
; #ifndef	_DELAY_H
; #define	_DELAY_H
; 
; // mcu:avr   crystal=8MHz
; 
; /**************************************************************
; **函数功能:延时1us
; **输入参数:无
; **返回值:无
; **在本函数外定义变量:无
; **调用的函数:NOP()
; **************************************************************/
; void Delay_1us(void);
; 
; /**************************************************************
; **函数功能:us级延时
; **输入参数:xus:延时us数
; **返回值:无
; **在本函数外定义变量:无
; **调用的函数:Delay_1us()
; **************************************************************/
; void Delay_Us(unsigned int xus);
; 
; /**************************************************************
; **函数功能:延时1ms
; **输入参数:无
; **返回值:无
; **在本函数外定义变量:无
; **调用的函数:NOP()
; **************************************************************/
; void Delay_1ms(void);
; 
; /**************************************************************
; **函数功能:ms级延时
; **输入参数:xms:延时ms数
; **返回值:无
; **在本函数外定义变量:无
; **调用的函数:Delay_1ms()
; **************************************************************/
; void Delay_Ms(unsigned int xms);
; 
; /**************************************************************
; **函数功能:10us级延时
; **输入参数:x10us:延时x10us数
; **返回值:无
; **在本函数外定义变量:无
; **调用的函数:无
; **************************************************************/
; void Delay10us(Word x10us);
; 
; 
; void Delay_1us()
; {
	.dbline 54
; 	unsigned char t=2;
	ldi R16,2
	.dbline 55
;    	t--;
	dec R16
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r t 16 c
	.dbend
	.dbfunc e Delay_Us _Delay_Us fV
;            xus -> R20,R21
	.even
_Delay_Us::
	st -y,R20
	st -y,R21
	movw R20,R16
	.dbline -1
	.dbline 59
; }
; 
; void Delay_Us(unsigned int xus)
; {
	xjmp L4
L3:
	.dbline 61
; 	 while (xus--)
;        	Delay_1us();
	xcall _Delay_1us
L4:
	.dbline 60
	movw R2,R20
	subi R20,1
	sbci R21,0
	tst R2
	brne L3
	tst R3
	brne L3
X0:
	.dbline -2
L2:
	.dbline 0 ; func end
	ld R21,y+
	ld R20,y+
	ret
	.dbsym r xus 20 i
	.dbend
	.dbfunc e Delay_1ms _Delay_1ms fV
;              i -> R16,R17
	.even
_Delay_1ms::
	.dbline -1
	.dbline 65
; }
; 
; void Delay_1ms(void)
; {
	.dbline 67
; 	unsigned int i;
; 	for(i=0;i<1142;i++)
	clr R16
	clr R17
	xjmp L10
L7:
	.dbline 68
; 		;
L8:
	.dbline 67
	subi R16,255  ; offset = 1
	sbci R17,255
L10:
	.dbline 67
	cpi R16,118
	ldi R30,4
	cpc R17,R30
	brlo L7
X1:
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e Delay_Ms _Delay_Ms fV
;              i -> R20,R21
;              j -> R22,R23
;            xms -> R16,R17
	.even
_Delay_Ms::
	xcall push_xgsetF000
	.dbline -1
	.dbline 72
; }
; 
; void Delay_Ms(Word xms) //crystal=8MHz
; {
	.dbline 74
; 	Word i,j; //variable:declare Word
; 	for(i=0; i<xms; i++)
	clr R20
	clr R21
	xjmp L15
L12:
	.dbline 75
; 		for(j=0; j<498;j++)
	clr R22
	clr R23
	xjmp L19
L16:
	.dbline 76
; 		{
	.dbline 77
; 			NOP();
	nop
	.dbline 78
; 			NOP();
	nop
	.dbline 79
; 			NOP();
	nop
	.dbline 80
; 			NOP();
	nop
	.dbline 81
; 			NOP();
	nop
	.dbline 82
; 			NOP();
	nop
	.dbline 83
; 			NOP();
	nop
	.dbline 84
; 			NOP();
	nop
	.dbline 85
; 			NOP();
	nop
	.dbline 86
; 		}
L17:
	.dbline 75
	subi R22,255  ; offset = 1
	sbci R23,255
L19:
	.dbline 75
	cpi R22,242
	ldi R30,1
	cpc R23,R30
	brlo L16
X2:
L13:
	.dbline 74
	subi R20,255  ; offset = 1
	sbci R21,255
L15:
	.dbline 74
	cp R20,R16
	cpc R21,R17
	brlo L12
X3:
	.dbline -2
L11:
	.dbline 0 ; func end
	xjmp pop_xgsetF000
	.dbsym r i 20 i
	.dbsym r j 22 i
	.dbsym r xms 16 i
	.dbend
	.dbfunc e Delay10us _Delay10us fV
;              i -> R20,R21
;              j -> R22
;          x10us -> R16,R17
	.even
_Delay10us::
	xcall push_xgsetF000
	.dbline -1
	.dbline 90
; }
; 
; void Delay10us(Word x10us)//crystal=8MHz
; {
	.dbline 92
; 	Word i;Byte j; //variable:declare Word
; 	for(i=0; i<x10us; i++)
	clr R20
	clr R21
	xjmp L24
L21:
	.dbline 93
; 	{
	.dbline 94
; 			for(j=0;j<2;j++)
	clr R22
	xjmp L28
L25:
	.dbline 95
; 			{
	.dbline 96
; 			 	NOP();
	nop
	.dbline 97
; 				NOP();
	nop
	.dbline 98
; 				NOP();
	nop
	.dbline 99
; 			}
L26:
	.dbline 94
	inc R22
L28:
	.dbline 94
	cpi R22,2
	brlo L25
X4:
	.dbline 100
; 	}
L22:
	.dbline 92
	subi R20,255  ; offset = 1
	sbci R21,255
L24:
	.dbline 92
	cp R20,R16
	cpc R21,R17
	brlo L21
X5:
	.dbline -2
L20:
	.dbline 0 ; func end
	xjmp pop_xgsetF000
	.dbsym r i 20 i
	.dbsym r j 22 c
	.dbsym r x10us 16 i
	.dbend
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\initrialm128.h
	.dbfunc e Init_Devices _Init_Devices fV
	.even
_Init_Devices::
	.dbline -1
	.dbline 16
; //ICC-AVR application builder : 2007-6-27 10:26:06
; // Target : M8
; // Crystal: 8.0000Mhz
; 
; /**************初始化m8函数***************/
; #ifndef Initrial_M128_H
; #define Initrial_M128_H
; 
; void Init_Devices(void);
; void Port_Init(void);  
; 
;  
; 
; //call this routine to initialize all peripherals
; void Init_Devices(void)
; {
	.dbline 18
; 	//stop errant interrupts until set up
; 	CLI(); //disable all interrupts
	cli
	.dbline 19
; 	Port_Init(); 
	xcall _Port_Init
	.dbline 20
; 	SEI(); //re-enable interrupts
	sei
	.dbline -2
L29:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Port_Init _Port_Init fV
	.even
_Port_Init::
	.dbline -1
	.dbline 25
; 	//all peripherals are now initialized
; }
; 
; void Port_Init(void)
; {
	.dbline 26
; 	PORTA = 0xff;
	ldi R24,255
	out 0x1b,R24
	.dbline 27
; 	DDRA  = 0xff;
	out 0x1a,R24
	.dbline 28
; 	PORTB = 0xff;
	out 0x18,R24
	.dbline 29
; 	DDRB  = 0xff;
	out 0x17,R24
	.dbline 30
; 	PORTC = 0xff; //m103 output only
	out 0x15,R24
	.dbline 31
; 	DDRC  = 0xff;
	out 0x14,R24
	.dbline 32
; 	PORTD = 0xff;
	out 0x12,R24
	.dbline 33
; 	DDRD  = 0xff;
	out 0x11,R24
	.dbline 34
; 	PORTE = 0xFF;
	out 0x3,R24
	.dbline 35
; 	DDRE  = 0xff;
	out 0x2,R24
	.dbline 36
; 	PORTF = 0xff;
	sts 98,R24
	.dbline 37
; 	DDRF  = 0xff;
	sts 97,R24
	.dbline 38
; 	PORTG = 0xff;
	sts 101,R24
	.dbline 39
; 	DDRG  = 0xff;
	sts 100,R24
	.dbline -2
L30:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfile H:\mega128开发板rev1.1\开发板程序\ds18b20温度+数码管显示程序\ds18b20.h
	.dbfunc e resetDS18B20 _resetDS18B20 fc
;        errTime -> R10
	.even
_resetDS18B20::
	st -y,R10
	.dbline -1
	.dbline 20
; /*--------------------------------------------------*/
; /*             AVR-ARM开发网论坛                    */
; /*           http://www.avrarm.com                  */
; /*            AVR生成代码测试程序                   */
; /*--------------------------------------------------*/
; /*     程序由AVR辅助开发工具V2.1.1自动生成          */
; /*     AVR系统的处理器为:   ATMega128               */
; /*     AVR系统的晶振频率:   8.0000 Mhz             */
; /*--------------------------------------------------*/
; 
; #include "define.h"
; #include "delay.h"
; 
; 
; /**********************************************************************
; functionName: unsigned char resetDS18B20(void)
; description :DS18B20初始化
; **********************************************************************/
; unsigned char resetDS18B20(void)
; {
	.dbline 21
; 	unsigned char errTime=0;
	clr R10
	.dbline 22
; 	RLS_DS18B20;		//释放总线
	cbi 0x2,2
	.dbline 23
; 	_NOP();
	nop
	.dbline 24
; 	HLD_DS18B20;		//Maga16控制总线
	sbi 0x2,2
	.dbline 25
; 	CLR_DS18B20;		//强制拉低
	cbi 0x3,2
	.dbline 26
; 	Delay_Us(480); 	//209.42us
	ldi R16,480
	ldi R17,1
	xcall _Delay_Us
	.dbline 28
; 	//以上延时大于480us
; 	RLS_DS18B20;		//释放总线,总线自动上拉
	cbi 0x2,2
	.dbline 29
; 	_NOP();
	nop
	xjmp L33
L32:
	.dbline 31
; 	while(STU_DS18B20)
; 	{
	.dbline 32
; 	   Delay_Us(6);	//5.15us
	ldi R16,6
	ldi R17,0
	xcall _Delay_Us
	.dbline 33
; 	   errTime++;
	inc R10
	.dbline 34
; 	   if(errTime>20)
	ldi R24,20
	cp R24,R10
	brsh L35
X6:
	.dbline 35
; 		  return(0x00); 	//如果等带大于约 5.15us*20就返回0x00,报告复位失败(实际上只要等待15-60us)
	clr R16
	xjmp L31
L35:
	.dbline 36
; 	}
L33:
	.dbline 30
	sbic 0x1,2
	rjmp L32
X7:
	.dbline 37
; 	errTime=0;
	clr R10
	xjmp L38
L37:
	.dbline 39
; 	while(!(STU_DS18B20))
; 	{
	.dbline 40
; 	   Delay_Us(6);	//5.15us
	ldi R16,6
	ldi R17,0
	xcall _Delay_Us
	.dbline 41
; 	   errTime++;
	inc R10
	.dbline 42
; 	   if(errTime>50)
	ldi R24,50
	cp R24,R10
	brsh L40
X8:
	.dbline 43
; 		  return(0x00); 	//如果等带大于约 5.15us*50就返回0x00,报告复位失败(实际上只要等待60-240us)
	clr R16
	xjmp L31
L40:
	.dbline 44
; 	}
L38:
	.dbline 38
	sbis 0x1,2
	rjmp L37
X9:
	.dbline 45
; 	return(0xff);
	ldi R16,255
	.dbline -2
L31:
	.dbline 0 ; func end
	ld R10,y+
	ret
	.dbsym r errTime 10 c
	.dbend
	.dbfunc e readByteDS18B20 _readByteDS18B20 fc
;         retVal -> R20
;              i -> R22
	.even
_readByteDS18B20::
	st -y,R20
	st -y,R22
	.dbline -1
	.dbline 54
; 
; }
; 
; /**********************************************************************
; functionName: unsigned char readByteDS18B20(void)
; description :读DS18B20一个字节
; **********************************************************************/
; unsigned char readByteDS18B20(void)
; {
	.dbline 56
; 	unsigned char i;
; 	unsigned char retVal=0;
	clr R20
	.dbline 57
; 	RLS_DS18B20;		//释放总线
	cbi 0x2,2
	.dbline 58
; 	for(i=8;i>0;i--)
	ldi R22,8
	xjmp L46
L43:
	.dbline 59
; 	{
	.dbline 60
; 	   retVal>>=1;
	lsr R20
	.dbline 61
; 	   HLD_DS18B20; 	//Maga16控制总线
	sbi 0x2,2
	.dbline 62
; 	   CLR_DS18B20; 	//强制拉低
	cbi 0x3,2
	.dbline 63
; 	   Delay_Us(8);	//延时大于1us
	ldi R16,8
	ldi R17,0
	xcall _Delay_Us
	.dbline 64
; 	   SET_DS18B20; 	//释放总线,DS18B20会将总线强制拉低
	sbi 0x3,2
	.dbline 66
; 	   //delay_nus(8);
; 	   RLS_DS18B20; 	 //释放总线
	cbi 0x2,2
	.dbline 67
; 	   if(STU_DS18B20)
	sbis 0x1,2
	rjmp L47
X10:
	.dbline 68
; 		  retVal|=0x80;
	ori R20,128
L47:
	.dbline 69
; 	   Delay_Us(32);		 //31us
	ldi R16,32
	ldi R17,0
	xcall _Delay_Us
	.dbline 70
; 	   HLD_DS18B20; 	 //释放总线
	sbi 0x2,2
	.dbline 71
; 	   SET_DS18B20; 	//释放总线,DS18B20会将总线强制拉低
	sbi 0x3,2
	.dbline 73
; 	   //delay_nus(30); 	 //30.38us
; 	}
L44:
	.dbline 58
	dec R22
L46:
	.dbline 58
	ldi R24,0
	cp R24,R22
	brlo L43
X11:
	.dbline 74
; 	Delay_Us(5);		 //2.71us(大于1us就行了)
	ldi R16,5
	ldi R17,0
	xcall _Delay_Us
	.dbline 75
; 	return(retVal);
	mov R16,R20
	.dbline -2
L42:
	.dbline 0 ; func end
	ld R22,y+
	ld R20,y+
	ret
	.dbsym r retVal 20 c
	.dbsym r i 22 c
	.dbend
	.dbfunc e writeByteDS18B20 _writeByteDS18B20 fV
;           temp -> R22
;              i -> R20
;             wb -> R10
	.even
_writeByteDS18B20::
	xcall push_xgsetF00C
	mov R10,R16
	.dbline -1
	.dbline 84
; 
; }
; 
; /**********************************************************************
; functionName: unsigned char readByteDS18B20(void)
; description :写DS18B20一个字节
; **********************************************************************/
; void writeByteDS18B20(unsigned char wb)
; {
	.dbline 87
; 	unsigned char i;
; 	unsigned char temp;
; 	RLS_DS18B20;			 //释放总线
	cbi 0x2,2
	.dbline 88
; 	for(i=0;i<8;i++)
	clr R20
	xjmp L53
L50:
	.dbline 89
; 	{
	.dbline 90
; 	   HLD_DS18B20; 	 //Maga16控制总线
	sbi 0x2,2
	.dbline 91
; 	   CLR_DS18B20; 	 //强制拉低
	cbi 0x3,2
	.dbline 92
; 	   Delay_Us(4);	 //14.92us
	ldi R16,4
	ldi R17,0
	xcall _Delay_Us
	.dbline 95
; 	   //SET_DS18B20;		 //释放总线

⌨️ 快捷键说明

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