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

📄 zong.s

📁 ad7135的avr16的源程序
💻 S
字号:
	.module zong.c
	.area data(ram, con, rel)
_N::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile zong.c
	.dbsym e N _N c
_T1OVF_NUM::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile zong.c
	.dbsym e T1OVF_NUM _T1OVF_NUM i
	.area text(rom, con, rel)
	.dbfile zong.c
	.dbfunc e delay_1ms _delay_1ms fV
;              i -> R16,R17
	.even
_delay_1ms::
	.dbline -1
	.dbline 37
; //ICC-AVR application builder : 2009-3-19 15:44:36
; // Target : M16
; // Crystal: 8.0000Mhz
; 
; #include <iom16v.h>
; #include <macros.h>
; 
; 
; //***************************************************** 
; //全局变量定义
; //*****************************************************
; 
; unsigned char N=0;//用来区别是第一次外部中断还是第二次中断
; unsigned int T1OVF_NUM=0;//用来计定时器T1的溢出次数
; unsigned long int T1_NUM;//T1计的总时钟的个数
; unsigned int VIN;//测到的电压,单位为mv
; 
; 
; //***************************************************** 
; //函数声明
; //*****************************************************
; //void port_init(void);
; void timer0_125Kinit(void);
; //void timer1_init(void)
; //void timer2_250init(void);
; void init_devices(void);
; void usart_tx(unsigned char data);
; void delay_1ms(void);
; void delay_nms(unsigned int n);
; void timer1_ovf_isr(void);
; void int0_isr(void);
; void data_display(unsigned int data);
; 
; 
; 
; void delay_1ms(void)
; {    
	.dbline 39
; 	 unsigned int i;
; 	 for(i=1142;i>0;i--)    
	ldi R16,1142
	ldi R17,4
	xjmp L5
L2:
	.dbline 40
L3:
	.dbline 39
	subi R16,1
	sbci R17,0
L5:
	.dbline 39
	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 48
;      ;
; }
; //***************************************************** 
; //函数名称:void DELAY_NMS(void)
; //函数功能:延时Nms
; //注意事项:
; //*****************************************************
; void delay_nms(unsigned int n)
; {	 
	.dbline 49
; 	 for(;n>0;n--)
	xjmp L10
L7:
	.dbline 50
	xcall _delay_1ms
L8:
	.dbline 49
	subi R20,1
	sbci R21,0
L10:
	.dbline 49
	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 55
; 	      delay_1ms();
; }
; 
; 
; void port_init(void)
; {
	.dbline 56
;  PORTA = 0x01;
	ldi R24,1
	out 0x1b,R24
	.dbline 57
;  DDRA  = 0x00;
	clr R2
	out 0x1a,R2
	.dbline 58
;  PORTB = 0x00;
	out 0x18,R2
	.dbline 59
;  DDRB  = 0xFF;
	ldi R24,255
	out 0x17,R24
	.dbline 60
;  PORTC = 0x00; //m103 output only
	out 0x15,R2
	.dbline 61
;  DDRC  = 0x00;
	out 0x14,R2
	.dbline 62
;  PORTD = 0x00;
	out 0x12,R2
	.dbline 63
;  DDRD  = 0xFF;
	out 0x11,R24
	.dbline -2
L11:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_125Kinit _timer0_125Kinit fV
	.even
_timer0_125Kinit::
	.dbline -1
	.dbline 71
; }
; 
; //TIMER0 initialize - prescale:Stop
; // WGM: CTC
; // desired value: 125KHz
; // actual value: Out of range
; void timer0_125Kinit(void)
; {
	.dbline 72
;  TCCR0 = 0x00; //stop
	clr R2
	out 0x33,R2
	.dbline 73
;  TCNT0 = 0x00 /*INVALID SETTING*/; //set count
	out 0x32,R2
	.dbline 74
;  OCR0  = 0x1F /*INVALID SETTING*/;  //set compare
	ldi R24,31
	out 0x3c,R24
	.dbline 75
;  TIMSK&=~(1<<OCIE0);
	in R24,0x39
	andi R24,253
	out 0x39,R24
	.dbline 76
;  TCCR0 = 0x19;
	ldi R24,25
	out 0x33,R24
	.dbline -2
L12:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer2_250init _timer2_250init fV
	.even
_timer2_250init::
	.dbline -1
	.dbline 85
;  //TCCR0 = 0x08; //start timer
; }
; 
; //TIMER2 initialize - prescale:Stop
; // WGM: CTC
; // desired value: 250Hz
; // actual value: Out of range
; void timer2_250init(void)
; {
	.dbline 86
;  TCCR2 = 0x00; //stop
	clr R2
	out 0x25,R2
	.dbline 88
;  //ASSR  = 0x00; //set async mode
;  TCNT2 = 0x00 /*INVALID SETTING*/; //setup
	out 0x24,R2
	.dbline 89
;  OCR2  = 0xF9 /*INVALID SETTING*/;
	ldi R24,249
	out 0x23,R24
	.dbline 90
;  TIMSK&=~(1<<OCIE2);
	in R24,0x39
	andi R24,127
	out 0x39,R24
	.dbline 91
;  TCCR2 = 0x1C; 
	ldi R24,28
	out 0x25,R24
	.dbline -2
L13:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 98
;  //TCCR2 = 0x08; //start
; }
; 
; 
; 
; void timer1_init(void)
; {
	.dbline 99
;  TCCR1A=0x00;
	clr R2
	out 0x2f,R2
	.dbline 100
;  TCCR1B=0x00;
	out 0x2e,R2
	.dbline 101
;  TCNT1=0X0000;
	clr R3
	out 0x2d,R3
	out 0x2c,R2
	.dbline 102
;  TIMSK|=(1<<TOIE1);
	in R24,0x39
	ori R24,4
	out 0x39,R24
	.dbline -2
L14:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e int0_init _int0_init fV
	.even
_int0_init::
	.dbline -1
	.dbline 107
; }
; 
; 
; void int0_init(void)
; {	 
	.dbline 108
; 	 MCUCR|=((1<<ISC01)|(1<<ISC00));
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 109
; 	 GICR|=(1<<INT0);
	in R24,0x3b
	ori R24,64
	out 0x3b,R24
	.dbline -2
L15:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 32
	jmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile zong.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R24
	st -y,R25
	in R24,0x3f
	st -y,R24
	.dbline -1
	.dbline 118
; }
; 
; 
; 
; 
; 
; #pragma interrupt_handler timer1_ovf_isr:9
; void timer1_ovf_isr(void)
; {
	.dbline 119
;  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
L16:
	ld R24,y+
	out 0x3f,R24
	ld R25,y+
	ld R24,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 132
;  
;  //TIMER1 has overflowed
;  //TCNT1H = 0x00 /*INVALID SETTING*/; //reload counter high value
;  //TCNT1L = 0x00 /*INVALID SETTING*/; //reload counter low value
; }
; 
; //UART0 initialize
; // desired baud rate: 9600
; // actual: baud rate:9615 (0.2%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
	.dbline 133
;  UCSRB = 0x98; //disable while setting baud rate
	ldi R24,152
	out 0xa,R24
	.dbline 134
;  UCSRA = 0x20;
	ldi R24,32
	out 0xb,R24
	.dbline 135
;  UCSRC = 0x86;
	ldi R24,134
	out 0x20,R24
	.dbline 136
;  UBRRL = 0x33; //set baud rate lo
	ldi R24,51
	out 0x9,R24
	.dbline 137
;  UBRRH = 0x00; //set baud rate hi
	clr R2
	out 0x20,R2
	.dbline -2
L17:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e usart_tx _usart_tx fV
;           data -> R20
	.even
_usart_tx::
	xcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 143
;  //UCSRB = 0x00;
; }
; 
; 
; void usart_tx(unsigned char data)
; {	 
	.dbline 144
; 	 UDR=data;
	out 0xc,R20
L19:
	.dbline 146
L20:
	.dbline 145
; 	 while(!(UCSRA&(1<<TXC)))
	sbis 0xb,6
	rjmp L19
	.dbline 147
; 	 ;
; 	 delay_nms(1);
	ldi R16,1
	ldi R17,0
	xcall _delay_nms
	.dbline -2
L18:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r data 20 c
	.dbend
	.area vector(rom, abs)
	.org 44
	jmp _usart_receive
	.area text(rom, con, rel)
	.dbfile zong.c
	.dbfunc e usart_receive _usart_receive fV
;              d -> R16
	.even
_usart_receive::
	st -y,R16
	in R16,0x3f
	st -y,R16
	.dbline -1
	.dbline 152
; }
; 
; #pragma interrupt_handler usart_receive:12
; void usart_receive(void)
; {	 
	.dbline 154
; 	 unsigned char d;
; 	 d=UDR;
	in R16,0xc
	.dbline 155
; 	 if(d==0x01)
	cpi R16,1
	brne L23
	.dbline 156
; 	 {    
	.dbline 157
; 	 	  PORTB|=(1<<0);
	sbi 0x18,0
	.dbline 158
; 		  SEI();
	sei
	.dbline 159
; 	 }
	xjmp L24
L23:
	.dbline 161
	.dbline 162
	cbi 0x18,0
	.dbline 163
	cli
	.dbline 164
L24:
	.dbline -2
L22:
	ld R16,y+
	out 0x3f,R16
	ld R16,y+
	.dbline 0 ; func end
	reti
	.dbsym r d 16 c
	.dbend
	.area vector(rom, abs)
	.org 4
	jmp _int0_isr
	.area text(rom, con, rel)
	.dbfile zong.c
	.dbfunc e int0_isr _int0_isr fV
	.even
_int0_isr::
	xcall push_lset
	xcall push_gset2
	.dbline -1
	.dbline 169
; 	 else
; 	 {    
; 	 	  PORTB&=~(1<<0);
; 		  CLI();
; 	 }
; }
; 
; #pragma interrupt_handler int0_isr:2
; void int0_isr(void)
; {
	.dbline 170
;    if(!N)
	lds R2,_N
	tst R2
	brne L26
	.dbline 171
; 	 {    
	.dbline 172
; 	 	  TCCR1B=0X01;//开始内部计数
	ldi R24,1
	out 0x2e,R24
	.dbline 173
; 		  MCUCR=0X02;//设置外部中断0下降沿产生中断
	ldi R24,2
	out 0x35,R24
	.dbline 174
; 		  N++;
	mov R24,R2
	subi R24,255    ; addi 1
	sts _N,R24
	.dbline 175
; 	 }
	xjmp L27
L26:
	.dbline 177
	.dbline 178
	clr R2
	out 0x2e,R2
	.dbline 179
	cli
	.dbline 181
	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 182
	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 183
	ldi R24,6
	ldi R25,0
	st -y,R24
	movw R16,R2
	movw R18,R4
	xcall lsr32
	sts _T1_NUM+1,R17
	sts _T1_NUM,R16
	sts _T1_NUM+2+1,R19
	sts _T1_NUM+2,R18
	.dbline 184
	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 _T1_NUM+1,R3
	sts _T1_NUM,R2
	sts _T1_NUM+2+1,R5
	sts _T1_NUM+2,R4
	.dbline 185
	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 186
	xcall _data_display
	.dbline 188
	clr R2
	clr R3
	sts _T1OVF_NUM+1,R3
	sts _T1OVF_NUM,R2
	.dbline 189
	out 0x2d,R3
	out 0x2c,R2
	.dbline 190
	in R24,0x35
	ori R24,3
	out 0x35,R24
	.dbline 191
	sts _N,R2
	.dbline 192
	cbi 0x18,0
	.dbline 194
L27:
	.dbline -2
L25:
	xcall pop_gset2
	xcall pop_lset
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e data_display _data_display fV
;           temp -> y+0
;              i -> R20
;           data -> R20,R21
	.even
_data_display::
	xcall push_gset1
	movw R20,R16
	sbiw R28,4
	.dbline -1
	.dbline 215
; 	 else
; 	 {    
; 	 	  TCCR1B=0X00;//定时器t1停止工作
; 		  CLI();//关中断,进行数据处理
; 		  //数据处理
; 		  T1_NUM=T1OVF_NUM;
; 		  T1_NUM=(T1_NUM*65536+TCNT1);
; 		  T1_NUM/=64;
; 		  T1_NUM-=10001;
; 		  VIN=T1_NUM/10;
; 		  data_display(VIN);
; 		  //数据处理结束
; 		  T1OVF_NUM=0;
; 		  TCNT1=0X0000;
; 		  MCUCR|=((1<<ISC01)|(1<<ISC00));//设置外部上升沿中断
; 		  N=0;//
; 		  PORTB&=~(1<<0);//上位机发0x01,测量一次,停止ad
; 		  //SEI();先进行1次采样
; 	 }
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
;  //external interupt on INT0
; }
; 
; void data_display(unsigned int data)
; {	 
	.dbline 217
; 	 unsigned char temp[4],i;
; 	 temp[0]=data/1000;
	ldi R18,1000
	ldi R19,3
	movw R16,R20
	xcall div16u
	std y+0,R16
	.dbline 218
; 	 temp[1]=(data/100)%10;
	ldi R18,100
	ldi R19,0
	movw R16,R20
	xcall div16u
	ldi R18,10
	ldi R19,0
	xcall mod16u
	std y+1,R16
	.dbline 219
; 	 temp[2]=(data/10)%10;
	ldi R18,10
	ldi R19,0
	movw R16,R20
	xcall div16u
	ldi R18,10
	ldi R19,0
	xcall mod16u
	std y+2,R16
	.dbline 220
; 	 temp[3]=data%10;
	ldi R18,10
	ldi R19,0
	movw R16,R20
	xcall mod16u
	std y+3,R16
	.dbline 221
; 	 for(i=0;i<4;i++)
	clr R20
	xjmp L35
L32:
	.dbline 222
	.dbline 223
	movw R24,R28
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	ldd R16,z+0
	xcall _usart_tx
	.dbline 224
	ldi R16,1
	ldi R17,0
	xcall _delay_nms
	.dbline 225
L33:
	.dbline 221
	inc R20
L35:
	.dbline 221
	cpi R20,4
	brlo L32
	.dbline -2
L28:
	adiw R28,4
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym l temp 0 A[4:4]c
	.dbsym r i 20 c
	.dbsym r data 20 i
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 230
; 	 {
; 	      usart_tx(temp[i]);
; 		  delay_nms(1);
; 	 }
; } 
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 232
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 233
;  port_init();
	xcall _port_init
	.dbline 235
;  //uart0_init();
;  timer0_125Kinit();
	xcall _timer0_125Kinit
	.dbline 236
;  timer2_250init();
	xcall _timer2_250init
	.dbline 237
;  uart0_init();
	xcall _uart0_init
	.dbline 238
;  timer1_init();
	xcall _timer1_init
	.dbline 239
;  int0_init();
	xcall _int0_init
	.dbline 244
; 
;  //MCUCR = 0x03;
;  //GICR  = 0x40;
;  //TIMSK = 0x00; //timer interrupt sources
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L36:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 249
;  //all peripherals are now initialized
; }
; 
; void main(void)
; {	 
	.dbline 250
; 	 CLI();
	cli
	.dbline 251
; 	 port_init();
	xcall _port_init
	.dbline 252
; 	 init_devices();
	xcall _init_devices
	.dbline 256
; 	 //T0_250K();
; 	 //INT0_INIT();
; 	 //T1_INIT();
; 	 SEI();
	sei
L38:
	.dbline 259
L39:
	.dbline 258
	xjmp L38
X2:
	.dbline -2
L37:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile zong.c
_VIN::
	.blkb 2
	.dbsym e VIN _VIN i
_T1_NUM::
	.blkb 4
	.dbsym e T1_NUM _T1_NUM l

⌨️ 快捷键说明

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