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

📄 7135_finish.s

📁 ad7135的avr16的源程序
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module _7135_finish.c
	.area data(ram, con, rel)
_N::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile 7135_finish.c
	.dbsym e N _N c
_T2OVF_NUM::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile 7135_finish.c
	.dbsym e T2OVF_NUM _T2OVF_NUM i
	.area text(rom, con, rel)
	.dbfile 7135_finish.c
	.dbfunc e DELAY_1MS _DELAY_1MS fV
;              i -> R16,R17
	.even
_DELAY_1MS::
	.dbline -1
	.dbline 47
; //************************************************* 
; //测试功能:7135的ad功能。将采集到的数据以四位由高到低发给上位机显示
; //测试方法:注意:采集到的电压单位为mv
; //测试结果:ok
; //时钟频率:外部8m
; //管脚分配:1脚(pb0)接7135的25,4脚(pb3)接7135的22
; //16脚(pd2)接7135的21
; //注意事项:基准电压为:1v.输入电压不大于2v
; //完成时间:2009.03.22
; //**************************************************
; 
; //************************************************** 
; //头文件
; //************************************************** 
; #include <iom16v.h>
; #include <macros.h>
; //************************************************** 
; 
; 
; //***************************************************** 
; //全局变量定义
; //*****************************************************
; unsigned char N=0;//用来区别是第一次外部中断还是第二次中断
; unsigned int T2OVF_NUM=0;//用来计定时器T2的溢出次数
; unsigned long int T2_NUM;//T2计的总时钟的个数
; unsigned int VIN;//测到的电压,单位为mv
; 
; //***************************************************** 
; //函数声明
; //*****************************************************
; void DELAY_1MS(void);
; void DELAY_NMS(unsigned int n);
; void PORT_INIT(void);
; void INT0_INIT(void);
; void T2_INIT(void);
; void T0_125K(void);
; void USART_INIT(void);
; void USART_TX(unsigned char data);
; void DATA_DISPLAY(unsigned int data);
; 
; //***************************************************** 
; //函数名称:void DELAY_1MS(void)
; //函数功能:延时1ms
; //注意事项:i=143*n-2
; //*****************************************************
; void DELAY_1MS(void)
; {    
	.dbline 49
; 	 unsigned int i;
; 	 for(i=1142;i>0;i--)    
	ldi R16,1142
	ldi R17,4
	xjmp L5
L2:
	.dbline 50
L3:
	.dbline 49
	subi R16,1
	sbci R17,0
L5:
	.dbline 49
	cpi R16,0
	cpc R16,R17
	brne L2
X0:
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e DELAY_NMS _DELAY_NMS fV
;              n -> R20,R21
	.even
_DELAY_NMS::
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 58
;      ;
; }
; //***************************************************** 
; //函数名称:void DELAY_NMS(void)
; //函数功能:延时Nms
; //注意事项:
; //*****************************************************
; void DELAY_NMS(unsigned int n)
; {	 
	.dbline 59
; 	 for(;n>0;n--)
	xjmp L10
L7:
	.dbline 60
	xcall _DELAY_1MS
L8:
	.dbline 59
	subi R20,1
	sbci R21,0
L10:
	.dbline 59
	cpi R20,0
	cpc R20,R21
	brne L7
X1:
	.dbline -2
L6:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r n 20 i
	.dbend
	.dbfunc e PORT_INIT _PORT_INIT fV
	.even
_PORT_INIT::
	.dbline -1
	.dbline 68
; 	      DELAY_1MS();
; }
; //***************************************************** 
; //函数名称:void INT0_INIT(void)  
; //函数功能:int0初始化,上升沿产生中断,使能中断
; //注意事项:未开总中断
; //*****************************************************
; void PORT_INIT(void)
; {	 
	.dbline 69
; 	 DDRB=0X09;
	ldi R24,9
	out 0x17,R24
	.dbline 70
; 	 PORTB=0X00;
	clr R2
	out 0x18,R2
	.dbline 71
; 	 DDRD=0X00;
	out 0x11,R2
	.dbline 72
; 	 PORTD=0XFF;
	ldi R24,255
	out 0x12,R24
	.dbline -2
L11:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e T0_125K _T0_125K fV
	.even
_T0_125K::
	.dbline -1
	.dbline 81
; }
; 	 
; //********************************************************** 
; //函数名称:void T0_250K(void)   
; //函数功能:t0工作于CTC模式,产生250k方波
; //注意事项:一分频,pb3(oc0)接7135 clk
; //********************************************************** 
; void T0_125K(void)
; {    
	.dbline 82
; 	TCCR0=0X00;
	clr R2
	out 0x33,R2
	.dbline 83
; 	TCNT0=0X00;
	out 0x32,R2
	.dbline 84
; 	OCR0=31;
	ldi R24,31
	out 0x3c,R24
	.dbline 85
; 	TIMSK&=~(1<<OCIE0);
	in R24,0x39
	andi R24,253
	out 0x39,R24
	.dbline 86
; 	TCCR0=0X19;
	ldi R24,25
	out 0x33,R24
	.dbline -2
L12:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e INT0_INIT _INT0_INIT fV
	.even
_INT0_INIT::
	.dbline -1
	.dbline 94
; }
; //***************************************************** 
; //函数名称:void INT0_INIT(void)  
; //函数功能:int0初始化,上升沿产生中断,使能中断
; //注意事项:未开总中断
; //*****************************************************
; void INT0_INIT(void)
; {	 
	.dbline 95
; 	 MCUCR|=((1<<ISC01)|(1<<ISC00));
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 96
; 	 GICR|=(1<<INT0);
	in R24,0x3b
	ori R24,64
	out 0x3b,R24
	.dbline -2
L13:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 4
	jmp _INT0_INTERRUPT
	.area text(rom, con, rel)
	.dbfile 7135_finish.c
	.dbfunc e INT0_INTERRUPT _INT0_INTERRUPT fV
	.even
_INT0_INTERRUPT::
	xcall push_lset
	xcall push_gset2
	.dbline -1
	.dbline 105
; }
; //***************************************************** 
; //函数名称:void INT0_INTERRUPT(void) 
; //函数功能:中断处理,N+1
; //注意事项: 
; //*****************************************************
; #pragma interrupt_handler INT0_INTERRUPT:2
; void INT0_INTERRUPT(void)
; {	 
	.dbline 106
; 	 if(!N)
	lds R2,_N
	tst R2
	brne L15
	.dbline 107
; 	 {    
	.dbline 108
; 	 	  TCCR2=0X01;//开始内部计数
	ldi R24,1
	out 0x25,R24
	.dbline 109
; 		  MCUCR=0X02;//设置外部中断0下降沿产生中断
	ldi R24,2
	out 0x35,R24
	.dbline 110
; 		  N++;
	mov R24,R2
	subi R24,255    ; addi 1
	sts _N,R24
	.dbline 111
; 	 }
	xjmp L16
L15:
	.dbline 113
	.dbline 114
	clr R2
	out 0x25,R2
	.dbline 115
	cli
	.dbline 117
	lds R2,_T2OVF_NUM
	lds R3,_T2OVF_NUM+1
	clr R4
	clr R5
	sts _T2_NUM+1,R3
	sts _T2_NUM,R2
	sts _T2_NUM+2+1,R5
	sts _T2_NUM+2,R4
	.dbline 118
	lds R4,_T2_NUM+2
	lds R5,_T2_NUM+2+1
	lds R2,_T2_NUM
	lds R3,_T2_NUM+1
	ldi R20,0
	ldi R21,1
	ldi R22,0
	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,0x24
	clr R7
	clr R8
	clr R9
	add R2,R6
	adc R3,R7
	adc R4,R8
	adc R5,R9
	sts _T2_NUM+1,R3
	sts _T2_NUM,R2
	sts _T2_NUM+2+1,R5
	sts _T2_NUM+2,R4
	.dbline 119
	ldi R24,6
	ldi R25,0
	st -y,R24
	movw R16,R2
	movw R18,R4
	xcall lsr32
	sts _T2_NUM+1,R17
	sts _T2_NUM,R16
	sts _T2_NUM+2+1,R19
	sts _T2_NUM+2,R18
	.dbline 120
	ldi R20,17
	ldi R21,39
	ldi R22,0
	ldi R23,0
	movw R2,R16
	movw R4,R18
	sub R2,R20
	sbc R3,R21
	sbc R4,R22
	sbc R5,R23
	sts _T2_NUM+1,R3
	sts _T2_NUM,R2
	sts _T2_NUM+2+1,R5
	sts _T2_NUM+2,R4
	.dbline 121
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	sts _VIN+1,R17
	sts _VIN,R16
	.dbline 122
	xcall _DATA_DISPLAY
	.dbline 124
	clr R2
	clr R3
	sts _T2OVF_NUM+1,R3
	sts _T2OVF_NUM,R2
	.dbline 125
	out 0x24,R2
	.dbline 126
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 127
	sts _N,R2
	.dbline 128
	cbi 0x18,0
	.dbline 130
L16:
	.dbline -2
L14:
	xcall pop_gset2
	xcall pop_lset
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e T2_INIT _T2_INIT fV

⌨️ 快捷键说明

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