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

📄 test_t1.s

📁 ad7135的avr16的源程序
💻 S
字号:
	.module test_t1.c
	.area data(ram, con, rel)
_N::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile test_t1.c
	.dbsym e N _N c
_T1OVF_NUM::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile test_t1.c
	.dbsym e T1OVF_NUM _T1OVF_NUM i
	.area text(rom, con, rel)
	.dbfile test_t1.c
	.dbfunc e INT0_INIT _INT0_INIT fV
	.even
_INT0_INIT::
	.dbline -1
	.dbline 38
; //************************************************* 
; //测试功能:t1内部计数,如有溢出则计量溢出次数
; //测试方法:
; //测试结果:ok
; //时钟频率:外部8m
; //管脚分配:
; //注意事项: 
; //完成时间:2009.03.15 
; //**************************************************
; 
; //************************************************** 
; //头文件
; //************************************************** 
; #include <iom16v.h>
; #include <macros.h>
; //************************************************** 
; 
; 
; //***************************************************** 
; //全局变量定义
; //*****************************************************
; unsigned char N=0;//用来区别是第一次外部中断还是第二次中断
; unsigned int T1OVF_NUM=0;//用来计定时器T1的溢出次数
; unsigned long int T1_NUM;//T1计的总时钟的个数
; 
; //***************************************************** 
; //函数声明
; //*****************************************************
; void INT0_INIT(void);
; void T1_INIT(void);
; 
; //***************************************************** 
; //函数名称:void INT0_INIT(void)  
; //函数功能:int0初始化,上升沿产生中断,使能中断
; //注意事项:未开总中断
; //*****************************************************
; void INT0_INIT(void)
; {	 
	.dbline 39
; 	 MCUCR|=((1<<ISC01)|(1<<ISC00));
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 40
; 	 GICR|=(1<<INT0);
	in R24,0x3b
	ori R24,64
	out 0x3b,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 4
	jmp _INT0_INTERRUPT
	.area text(rom, con, rel)
	.dbfile test_t1.c
	.dbfunc e INT0_INTERRUPT _INT0_INTERRUPT fV
	.even
_INT0_INTERRUPT::
	st -y,R0
	st -y,R1
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R6
	st -y,R7
	st -y,R8
	st -y,R9
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R19
	st -y,R24
	st -y,R25
	st -y,R30
	in R0,0x3f
	st -y,R0
	xcall push_gset2
	.dbline -1
	.dbline 49
; }
; //***************************************************** 
; //函数名称:void INT0_INTERRUPT(void) 
; //函数功能:中断处理,N+1
; //注意事项: 
; //*****************************************************
; #pragma interrupt_handler INT0_INTERRUPT:2
; void INT0_INTERRUPT(void)
; {	 
	.dbline 50
; 	 if(!N)
	lds R2,_N
	tst R2
	brne L3
	.dbline 51
; 	 {    
	.dbline 52
; 	 	  TCCR1B=0X01;//开始内部计数
	ldi R24,1
	out 0x2e,R24
	.dbline 53
; 		  MCUCR=0X02;//设置外部中断0下降沿产生中断
	ldi R24,2
	out 0x35,R24
	.dbline 54
; 		  N++;
	mov R24,R2
	subi R24,255    ; addi 1
	sts _N,R24
	.dbline 55
; 	 }
	xjmp L4
L3:
	.dbline 57
	.dbline 58
	clr R2
	out 0x2e,R2
	.dbline 59
	cli
	.dbline 61
	lds R2,_T1OVF_NUM
	lds R3,_T1OVF_NUM+1
	clr R4
	clr R5
	sts _T1_NUM+1,R3
	sts _T1_NUM,R2
	sts _T1_NUM+2+1,R5
	sts _T1_NUM+2,R4
	.dbline 62
	lds R4,_T1_NUM+2
	lds R5,_T1_NUM+2+1
	lds R2,_T1_NUM
	lds R3,_T1_NUM+1
	ldi R20,0
	ldi R21,0
	ldi R22,1
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	movw R2,R16
	movw R4,R18
	in R6,0x2c
	in R7,0x2d
	clr R8
	clr R9
	add R2,R6
	adc R3,R7
	adc R4,R8
	adc R5,R9
	sts _T1_NUM+1,R3
	sts _T1_NUM,R2
	sts _T1_NUM+2+1,R5
	sts _T1_NUM+2,R4
	.dbline 64
	clr R2
	clr R3
	sts _T1OVF_NUM+1,R3
	sts _T1OVF_NUM,R2
	.dbline 65
	out 0x2d,R3
	out 0x2c,R2
	.dbline 66
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 67
	sts _N,R2
	.dbline 68
	sei
	.dbline 69
L4:
	.dbline -2
L2:
	xcall pop_gset2
	ld R0,y+
	out 0x3f,R0
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R19,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R9,y+
	ld R8,y+
	ld R7,y+
	ld R6,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e T1_INIT _T1_INIT fV
	.even
_T1_INIT::
	.dbline -1
	.dbline 77
; 	 else
; 	 {    
; 	 	  TCCR1B=0X00;//定时器t1停止工作
; 		  CLI();//关中断,进行数据处理
; 		  //数据处理
; 		  T1_NUM=T1OVF_NUM;
; 		  T1_NUM=T1_NUM*65536+TCNT1;
; 		  //数据处理结束
; 		  T1OVF_NUM=0;
; 		  TCNT1=0X0000;
; 		  MCUCR|=((1<<ISC01)|(1<<ISC00));//设置外部上升沿中断
; 		  N=0;//
; 		  SEI();
; 	 }
; }
; //************************************************** 
; //函数名称:void T1_INIT(void)  
; //函数功能:内部定时
; //注意事项,定时器未工作,定时器工作,需+TCCR1B=0X01;
; //************************************************** 
; void T1_INIT(void)
; {	 
	.dbline 78
; 	 TCCR1A=0X00;
	clr R2
	out 0x2f,R2
	.dbline 79
; 	 TCNT1=0X0000;
	clr R3
	out 0x2d,R3
	out 0x2c,R2
	.dbline 80
; 	 TIMSK|=(1<<TOIE1);
	in R24,0x39
	ori R24,4
	out 0x39,R24
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 32
	jmp _T1_OVF
	.area text(rom, con, rel)
	.dbfile test_t1.c
	.dbfunc e T1_OVF _T1_OVF fV
	.even
_T1_OVF::
	st -y,R24
	st -y,R25
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 89
; }
; //************************************************** 
; //函数名称:void T1_OVF(void)  
; //函数功能:ti溢出处理
; //注意事项:
; //**************************************************
; #pragma interrupt_handler T1_OVF:9
; void T1_OVF(void)
; {	 
	.dbline 90
; 	 T1OVF_NUM++;
	lds R24,_T1OVF_NUM
	lds R25,_T1OVF_NUM+1
	adiw R24,1
	sts _T1OVF_NUM+1,R25
	sts _T1OVF_NUM,R24
	.dbline -2
L6:
	ld R24,y+
	out 0x3f,R24
	ld R25,y+
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 96
; }
; //********************************************************** 
; //主函数
; //**********************************************************
; void main(void)
; {	 
	.dbline 97
; 	 CLI();
	cli
	.dbline 98
; 	 INT0_INIT();
	xcall _INT0_INIT
	.dbline 99
; 	 T1_INIT();
	xcall _T1_INIT
	.dbline 100
; 	 SEI();
	sei
L8:
	.dbline 102
L9:
	.dbline 101
	xjmp L8
X0:
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile test_t1.c
_T1_NUM::
	.blkb 4
	.dbsym e T1_NUM _T1_NUM l

⌨️ 快捷键说明

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