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

📄 main.s

📁 AVR单片机ATmega16(L)应用实例—红外线转速仪
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module main.c
	.area data(ram, con, rel)
_Start::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile d:\MYDOCU~1\ac19-1\main.c
	.dbsym e Start _Start c
_JS::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile d:\MYDOCU~1\ac19-1\main.c
	.dbsym e JS _JS c
_DisFlag::
	.blkb 1
	.area idata
	.byte 1
	.area data(ram, con, rel)
	.dbfile d:\MYDOCU~1\ac19-1\main.c
	.dbsym e DisFlag _DisFlag c
_BeginFlag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile d:\MYDOCU~1\ac19-1\main.c
	.dbsym e BeginFlag _BeginFlag c
	.area lit(rom, con, rel)
_cs0::
	.byte 'S,'h,'a,'n,'g,'H,'a,'i,0
	.dbsym e cs0 _cs0 A[9:9]kc
_cs1::
	.byte 45,'T,'e,'s,'t,'e,'r,45,0
	.dbsym e cs1 _cs1 A[9:9]kc
_cs2::
	.byte 'T,'e,'s,'t,'i,'n,'g,45,0
	.dbsym e cs2 _cs2 A[9:9]kc
_dsp::
	.byte 'R,'P,'M,58,32,32,32,32,0
	.dbsym e dsp _dsp A[9:9]kc
	.area text(rom, con, rel)
	.dbfile d:\MYDOCU~1\ac19-1\main.c
	.dbfunc e timer2_init _timer2_init fV
	.even
_timer2_init::
	.dbline -1
	.dbline 40
; //ICC-AVR application builder : 2007-9-20 10:30:53
; // Target : m16
; // Crystal: 8.0000Mhz
; 
; #include <iom16v.h>
; #include <macros.h>
; #include "head.h"
; #define uchar unsigned char
; #define uint unsigned int
; #define xtal 8
; 
; extern void WaitForEnable(void);
; extern void LcdWriteData(uchar W);
; extern void LcdWriteCommand(uchar CMD,uchar Attribc);
; extern void InitLcd(void);
; extern void Display(uchar dd);
; extern void DisplayOneChar(uchar x,uchar y,uchar Wdata);
; extern void ePutstr(uchar x,uchar y,uchar const *ptr);
; 
; 		
; uchar Start=0,WorkFlag;
; uint WorkTime,DisTime,Counter;
; uint DisVal;
; uint cnt;
; uchar Flag,IntFlag,JS=0;
; uint tx,cx;
; uint disx[4];
; uchar DisFlag=1,EndFlag,BeginFlag=0;
; 
; const uchar cs0[]={"ShangHai"};//欢迎界面
; const uchar cs1[]={"-Tester-"};//欢迎界面
; const uchar cs2[]={"Testing-"};//测试界面
; const uchar dsp[]={"RPM:    "};//测试界面
; 
; //TIMER2 initialize - prescale:64
; // WGM: Normal
; // desired value: 1mSec
; // actual value:  1.000mSec (0.0%)
; void timer2_init(void)
; {
	.dbline 41
;  TCCR2 = 0x00; //stop
	clr R2
	out 0x25,R2
	.dbline 42
;  ASSR  = 0x00; //set async mode
	out 0x22,R2
	.dbline 43
;  TCNT2 = 0x83; //setup
	ldi R24,131
	out 0x24,R24
	.dbline 44
;  OCR2  = 0x7D;
	ldi R24,125
	out 0x23,R24
	.dbline 45
;  TCCR2 = 0x04; //start
	ldi R24,4
	out 0x25,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 49
; }
; 
; void port_init(void)
; {
	.dbline 50
;  PORTA = 0x00;
	clr R2
	out 0x1b,R2
	.dbline 51
;  DDRA  = 0xFF;
	ldi R24,255
	out 0x1a,R24
	.dbline 52
;  PORTB = 0x00;
	out 0x18,R2
	.dbline 53
;  DDRB  = 0xFF;
	out 0x17,R24
	.dbline 54
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 55
;  DDRC  = 0x00;
	out 0x14,R2
	.dbline 56
;  PORTD = 0xFF;
	out 0x12,R24
	.dbline 57
;  DDRD = 0xFF;
	out 0x11,R24
	.dbline 58
;  DDRD  = 0x63;
	ldi R24,99
	out 0x11,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 63
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 65
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 66
;  port_init();
	xcall _port_init
	.dbline 67
;  timer2_init();
	xcall _timer2_init
	.dbline 69
; 
;  MCUCR = 0x01;
	ldi R24,1
	out 0x35,R24
	.dbline 70
;  GICR  = 0x40;
	ldi R24,64
	out 0x3b,R24
	.dbline 71
;  TIMSK = 0x40; //timer interrupt sources
	out 0x39,R24
	.dbline 72
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e display1 _display1 fV
	.even
_display1::
	sbiw R28,2
	.dbline -1
	.dbline 78
;  //all peripherals are now initialized
; }
; 
; /**********************欢迎界面********************/
; void display1(void)
; {
	.dbline 79
; LcdWriteCommand(0x01,1); //清屏,检测忙信号
	ldi R18,1
	ldi R16,1
	xcall _LcdWriteCommand
	.dbline 80
; ePutstr(0,0,cs0);
	ldi R24,<_cs0
	ldi R25,>_cs0
	std y+1,R25
	std y+0,R24
	clr R18
	clr R16
	xcall _ePutstr
	.dbline 81
; ePutstr(0,1,cs1);
	ldi R24,<_cs1
	ldi R25,>_cs1
	std y+1,R25
	std y+0,R24
	ldi R18,1
	clr R16
	xcall _ePutstr
	.dbline -2
L4:
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e display2 _display2 fV
	.even
_display2::
	sbiw R28,2
	.dbline -1
	.dbline 85
; }
; 
; void display2(void)
; {
	.dbline 86
; LcdWriteCommand(0x01,1); //清屏,检测忙信号
	ldi R18,1
	ldi R16,1
	xcall _LcdWriteCommand
	.dbline 87
; ePutstr(0,0,cs2);
	ldi R24,<_cs2
	ldi R25,>_cs2
	std y+1,R25
	std y+0,R24
	clr R18
	clr R16
	xcall _ePutstr
	.dbline 88
; ePutstr(0,1,dsp);
	ldi R24,<_dsp
	ldi R25,>_dsp
	std y+1,R25
	std y+0,R24
	ldi R18,1
	clr R16
	xcall _ePutstr
	.dbline -2
L5:
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e Delay_1ms _Delay_1ms fV
;              i -> R16,R17
	.even
_Delay_1ms::
	.dbline -1
	.dbline 93
; }
; 
; //****************************************
; void Delay_1ms(void)		//1mS延时子函数
; { uint i;
	.dbline 94
;  for(i=1;i<(uint)(xtal*124);i++)
	ldi R16,1
	ldi R17,0
	xjmp L10
L7:
	.dbline 95
L8:
	.dbline 94
	subi R16,255  ; offset = 1
	sbci R17,255
L10:
	.dbline 94
	cpi R16,224
	ldi R30,3
	cpc R17,R30
	brlo L7
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e Delay_nms _Delay_nms fV
;              i -> R20,R21
;              n -> R22,R23
	.even
_Delay_nms::
	xcall push_gset2
	movw R22,R16
	.dbline -1
	.dbline 99
;     ;
; }
; //=============================================
; void Delay_nms(uint n)		//n*1mS延时子函数
; {
	.dbline 100
;  uint i=0;
	clr R20
	clr R21
	xjmp L13
L12:
	.dbline 102
	.dbline 102
	xcall _Delay_1ms
	.dbline 102
	wdr
	.dbline 103
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 104
L13:
	.dbline 101
;    while(i<n)
	cp R20,R22
	cpc R21,R23
	brlo L12
	.dbline -2
L11:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r n 22 i
	.dbend
	.dbfunc e main _main fV
;           time -> y+9
;          count -> y+5
;              x -> y+1
;           temp -> R10
	.even
_main::
	sbiw R28,13
	.dbline -1
	.dbline 109
;    {Delay_1ms();WDR();
;     i++;
;    }
; }
; 
; /**********************主函数*****************************/
; void main(void)
; {	uchar temp;
	.dbline 111
;     float count,time,x;
; 	Delay_nms(400);
	ldi R16,400
	ldi R17,1
	xcall _Delay_nms
	.dbline 112
; 	init_devices();
	xcall _init_devices
	.dbline 113
; 	InitLcd();
	xcall _InitLcd
	.dbline 114
; 	display1();	   //显示Test界面
	xcall _display1
	.dbline 115
; 	Delay_nms(2000);
	ldi R16,2000
	ldi R17,7
	xcall _Delay_nms
	.dbline 116
; 	display2();		   //显示Work状态
	xcall _display2
	.dbline 117
; 	DisFlag=1;
	ldi R24,1
	sts _DisFlag,R24
	xjmp L17
L16:
	.dbline 121
; 	      
; 	/********************************************/
; 		while(1)               //无限循环
; 		{  WDR();
	.dbline 121
	wdr
	.dbline 123
; 		     
; 		   	if(DisFlag==1)//如果显示标志为1
	lds R24,_DisFlag
	cpi R24,1
	breq X1
	xjmp L19
X1:
	.dbline 124
; 		   	{
	.dbline 125
; 				  time=(float)tx;count=(float)cx;
	ldi R16,<L21
	ldi R17,>L21
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_tx
	lds R17,_tx+1
	lsr R17
	ror R16
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	lds R16,_tx
	lds R17,_tx+1
	andi R16,1
	andi R17,0
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall add32f
	movw R30,R28
	std z+9,R16
	std z+10,R17
	std z+11,R18
	std z+12,R19
	.dbline 125
	ldi R16,<L21
	ldi R17,>L21
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	lds R16,_cx
	lds R17,_cx+1
	lsr R17
	ror R16
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32fs
	lds R16,_cx
	lds R17,_cx+1
	andi R16,1
	andi R17,0
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall add32f
	movw R30,R28
	std z+5,R16
	std z+6,R17
	std z+7,R18
	std z+8,R19
	.dbline 126
; 				  x=count/time;x=x*30000;DisVal=(uint)x;//数学计算
	movw R30,R28
	ldd R2,z+5
	ldd R3,z+6
	ldd R4,z+7
	ldd R5,z+8
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 4
	ldd R2,z+13
	ldd R3,z+14
	ldd R4,z+15
	ldd R5,z+16
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall div32f
	movw R30,R28
	std z+1,R16
	std z+2,R17
	std z+3,R18
	std z+4,R19
	.dbline 126
	ldi R16,<L22
	ldi R17,>L22
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R30,R28
 ; stack offset 4
	ldd R2,z+5
	ldd R3,z+6
	ldd R4,z+7

⌨️ 快捷键说明

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