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

📄 temperature.s

📁 单片机实行温度 的测量原理的的程序,简单,明了
💻 S
字号:
	.module temperature.c
	.area vector(rom, abs)
	.org 28
	rjmp _ad_handler
	.area lit(rom, con, rel)
_tabel::
	.byte 192,249
	.byte 164,176
	.byte 153,146
	.byte 130,248
	.byte 128,144
	.byte 136,131
	.byte 198,161
	.byte 134,142
	.byte 137,163
	.byte 140,200
	.dbfile D:\AVR调试\temperature\temperature.c
	.dbsym e tabel _tabel A[20:20]kc
	.area text(rom, con, rel)
	.dbfile D:\AVR调试\temperature\temperature.c
	.dbfunc e delay _delay fV
;              j -> R20
;              i -> R22
;           temp -> R16,R17
	.even
_delay::
	rcall push_gset2
	.dbline -1
	.dbline 14
; #include <io8535v.h>
; #include<macros.h>
; #define uchar unsigned char
; #define uint unsigned int
; #pragma interrupt_handler ad_handler:15
; 
; #define Vref 5.0
; 
; const unsigned char tabel[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0x89,0xA3,0x8C,0xC8};
; uchar addata;
; 
; 
; void delay(uint temp)//10ms,16M晶振
; {
	rjmp L3
L2:
	.dbline 17
; 	uchar i,j;	
; 	while(temp--)
; 	{
	.dbline 18
; 		for(j=213;j>0;j--)//1ms,58
	ldi R20,213
	rjmp L8
L5:
	.dbline 19
	ldi R22,148
	rjmp L12
L9:
	.dbline 19
L10:
	.dbline 19
	dec R22
L12:
	.dbline 19
	clr R2
	cp R2,R22
	brlo L9
L6:
	.dbline 18
	dec R20
L8:
	.dbline 18
	clr R2
	cp R2,R20
	brlo L5
	.dbline 20
L3:
	.dbline 16
	movw R2,R16
	subi R16,1
	sbci R17,0
	tst R2
	brne L2
	tst R3
	brne L2
X0:
	.dbline -2
L1:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r j 20 c
	.dbsym r i 22 c
	.dbsym r temp 16 i
	.dbend
	.area lit(rom, con, rel)
L14:
	.byte 0
	.byte 0,0
	.area text(rom, con, rel)
	.dbfile D:\AVR调试\temperature\temperature.c
	.dbfunc e LEDSCAN _LEDSCAN fV
;        disdata -> y+0
;           temp -> R20,R21
	.even
_LEDSCAN::
	rcall push_gset1
	movw R20,R16
	sbiw R28,3
	.dbline -1
	.dbline 24
; 			for(i=148;i>0;i--);//1ms,53	
; 	}	
; }
; 
; void LEDSCAN(temp)//显示程序
; {
	.dbline 25
;  uchar disdata[3] ={0};
	ldi R24,<L14
	ldi R25,>L14
	movw R30,R28
	ldi R16,3
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	rcall asgncblk
	.dbline 27
;  
;  disdata[0]=temp/1000;//取最高位
	ldi R18,1000
	ldi R19,3
	movw R16,R20
	rcall div16s
	std y+0,R16
	.dbline 28
;  disdata[1]=temp%1000/100;//取最二位
	ldi R18,1000
	ldi R19,3
	movw R16,R20
	rcall mod16s
	ldi R18,100
	ldi R19,0
	rcall div16s
	std y+1,R16
	.dbline 29
;  disdata[2]=temp%100/10;//取最三位
	ldi R18,100
	ldi R19,0
	movw R16,R20
	rcall mod16s
	ldi R18,10
	ldi R19,0
	rcall div16s
	std y+2,R16
	.dbline 31
; 	
;  PORTC|=0x01;//显示第一位
	sbi 0x15,0
	.dbline 32
;  PORTB=tabel[disdata[0]]&0x7f;
	ldi R24,<_tabel
	ldi R25,>_tabel
	ldd R30,y+0
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	andi R30,127
	out 0x18,R30
	.dbline 33
;  delay(1);
	ldi R16,1
	ldi R17,0
	rcall _delay
	.dbline 34
;  PORTC&=0X00;
	clr R2
	out 0x15,R2
	.dbline 36
;  
;  PORTC|=0x02;//显示第二位
	sbi 0x15,1
	.dbline 37
;  PORTB=tabel[disdata[1]];
	ldi R24,<_tabel
	ldi R25,>_tabel
	ldd R30,y+1
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x18,R30
	.dbline 38
;  delay(1);
	ldi R16,1
	ldi R17,0
	rcall _delay
	.dbline 39
;  PORTC&=0X00;
	clr R2
	out 0x15,R2
	.dbline 41
;  
;  PORTC|=0x04;//显示第三位
	sbi 0x15,2
	.dbline 42
;  PORTB=tabel[disdata[2]];
	ldi R24,<_tabel
	ldi R25,>_tabel
	ldd R30,y+2
	clr R31
	add R30,R24
	adc R31,R25
	lpm R30,Z
	out 0x18,R30
	.dbline 43
;  delay(1);
	ldi R16,1
	ldi R17,0
	rcall _delay
	.dbline 44
;  PORTC&=0X00;
	clr R2
	out 0x15,R2
	.dbline -2
L13:
	adiw R28,3
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym l disdata 0 A[3:3]c
	.dbsym r temp 20 I
	.dbend
	.dbfunc e ad_handler _ad_handler fV
;            Vin -> R20,R21
	.even
_ad_handler::
	rcall push_lset
	rcall push_gset2
	sbiw R28,4
	.dbline -1
	.dbline 48
; }
; 
; void ad_handler(void)//中断进入
; {
	.dbline 51
;      uint Vin;
; //	 uint Vref;
;  	 addata=ADC;
	in R2,0x4
	in R3,0x5
	sts _addata,R2
	.dbline 52
; 	 Vin=((float)ADC*Vref/1024)*1000;
	in R2,0x4
	in R3,0x5
	ldi R16,<L22
	ldi R17,>L22
	rcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	ldi R16,<L23
	ldi R17,>L23
	rcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	ldi R16,<L24
	ldi R17,>L24
	rcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R16,R2
	lsr R17
	ror R16
	rcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	rcall empy32fs
	movw R16,R2
	andi R16,1
	andi R17,0
	rcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	rcall add32fs
	rcall empy32fs
	ldi R16,<L25
	ldi R17,>L25
	rcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	rcall div32fs
	rcall empy32f
	movw R30,R28
	std z+0,R16
	std z+1,R17
	std z+2,R18
	std z+3,R19
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L26
	ldi R17,>L26
	rcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	rcall cmp32f
	brlt L20
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L26
	ldi R17,>L26
	rcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	rcall sub32f
	rcall fp2int
	movw R22,R16
	subi R22,0  ; offset = 32768
	sbci R23,128
	rjmp L21
L20:
	movw R30,R28
	ldd R16,z+0
	ldd R17,z+1
	ldd R18,z+2
	ldd R19,z+3
	rcall fp2int
	movw R22,R16
L21:
	movw R20,R22
	.dbline 53
; 	 LEDSCAN(Vin);
	movw R16,R20
	rcall _LEDSCAN
	.dbline 54
; 	 ADCSR|=BIT(ADSC);
	sbi 0x6,6
	.dbline -2
L19:
	adiw R28,4
	rcall pop_gset2
	rcall pop_lset
	.dbline 0 ; func end
	reti
	.dbsym r Vin 20 i
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 57
; }
; void main()//主程序
; {
	.dbline 58
;  	 PORTA=0;
	clr R2
	out 0x1b,R2
	.dbline 59
; 	 DDRA=0;
	out 0x1a,R2
	.dbline 60
; 	 PORTC=0x00;
	out 0x15,R2
	.dbline 61
; 	 DDRC=0xFF;
	ldi R24,255
	out 0x14,R24
	.dbline 62
; 	 DDRB=0xFF;
	out 0x17,R24
	.dbline 63
; 	 PORTB=0xFF;
	out 0x18,R24
	.dbline 64
; 	 ADMUX=0x00;
	out 0x7,R2
	.dbline 65
; 	 ADCSR=0x80;
	ldi R24,128
	out 0x6,R24
	.dbline 66
; 	 ADCSR|=BIT(ADIE);
	sbi 0x6,3
	.dbline 68
; 	 //SREG=0x80;
; 	 SEI();
	sei
	.dbline 69
; 	 ADCSR|=BIT(ADSC);
	sbi 0x6,6
L28:
	.dbline 70
L29:
	.dbline 70
	rjmp L28
X1:
	.dbline -2
L27:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\AVR调试\temperature\temperature.c
_addata::
	.blkb 1
	.dbsym e addata _addata c
	.area lit(rom, con, rel)
L26:
	.word 0x0,0x4700
L25:
	.word 0x0,0x4480
L24:
	.word 0x0,0x4000
L23:
	.word 0x0,0x40a0
L22:
	.word 0x0,0x447a

⌨️ 快捷键说明

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