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

📄 main.s

📁 原创
💻 S
📖 第 1 页 / 共 3 页
字号:
; 
; uint8 receFCom[6]={0};            //解包缓冲
; uint8 receDComCount = 0;          //解包计数器
; 
; uint8 testFlag = 0;
; 
; //包头的特殊码表
; const uint8 receNFtab[62] = {0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,
; 	                         0x0f,0x1f,0x2f,0x3f,0x4f,0x5f,0x6f,0x7f,0x8f,0x9f,
; 					         0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,
; 	                         0x0e,0x1e,0x2e,0x3e,0x4e,0x5e,0x6e,0x7e,0x8e,0x9e,
; 					         0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,
; 	                         0x0c,0x1c,0x2c,0x3c,0x4c,0x5c,0x6c,0x7c,0x8c,0x9c,
; 					         0xd0,0xd1												  	 
; };
; 
; 
; 
; void port_init(void)
; {
	.dbline 90
;  PORTA = 0xe0;
	ldi R24,224
	out 0x1b,R24
	.dbline 91
;  DDRA  = 0x18;
	ldi R24,24
	out 0x1a,R24
	.dbline 92
;  PORTB = 0x00;
	clr R2
	out 0x18,R2
	.dbline 93
;  DDRB  = 0xFF;
	ldi R24,255
	out 0x17,R24
	.dbline 94
;  PORTD = 0x80;
	ldi R24,128
	out 0x12,R24
	.dbline 95
;  DDRD  = 0xfA;
	ldi R24,250
	out 0x11,R24
	.dbline 96
;  U7(0xff);
	ldi R16,255
	xcall _U7
	.dbline 97
;  U9(0xff);
	ldi R16,255
	xcall _U9
	.dbline 98
;  U18(0xff);
	ldi R16,255
	xcall _U18
	.dbline 99
;  U19(0xff);
	ldi R16,255
	xcall _U19
	.dbline 100
;  PORTD = 0x00; 
	clr R2
	out 0x12,R2
	.dbline 101
;  DDRC = 0b10011111;
	ldi R24,159
	out 0x14,R24
	.dbline 102
;  PORTC= 0b11111111;
	ldi R24,255
	out 0x15,R24
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer1_init _timer1_init fV
	.even
_timer1_init::
	.dbline -1
	.dbline 110
; }
; 
; //TIMER1 initialize - prescale:64
; // WGM: 4) CTC, TOP=OCRnA
; // desired value: 100mSec
; // actual value: 99.996mSec (0.0%)
; void timer1_init(void)
; {
	.dbline 111
;  TCCR1B = 0x00; //stop
	clr R2
	out 0x2e,R2
	.dbline 112
;  TCNT1H = 0xBC; //setup
	ldi R24,188
	out 0x2d,R24
	.dbline 113
;  TCNT1L = 0x82;
	ldi R24,130
	out 0x2c,R24
	.dbline 114
;  OCR1AH = 0x43;
	ldi R24,67
	out 0x2b,R24
	.dbline 115
;  OCR1AL = 0x7E;
	ldi R24,126
	out 0x2a,R24
	.dbline 116
;  OCR1BH = 0x43;
	ldi R24,67
	out 0x29,R24
	.dbline 117
;  OCR1BL = 0x7E;
	ldi R24,126
	out 0x28,R24
	.dbline 118
;  ICR1H  = 0x43;
	ldi R24,67
	out 0x27,R24
	.dbline 119
;  ICR1L  = 0x7E;
	ldi R24,126
	out 0x26,R24
	.dbline 120
;  TCCR1A = 0x00;
	out 0x2f,R2
	.dbline 121
;  TCCR1B = 0x0B; //start Timer
	ldi R24,11
	out 0x2e,R24
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 129
; }
; 
; //TIMER0 initialize - prescale:64
; // WGM: Normal
; // desired value: 1mSec
; // actual value:  0.995mSec (0.5%)
; void timer0_init(void)
; {
	.dbline 130
;  TCCR0 = 0x00; //stop
	clr R2
	out 0x33,R2
	.dbline 131
;  TCNT0 = 0x54; //set count
	ldi R24,84
	out 0x32,R24
	.dbline 132
;  OCR0  = 0xAC;  //set compare
	ldi R24,172
	out 0x3c,R24
	.dbline 133
;  TCCR0 = 0x03; //start timer
	ldi R24,3
	out 0x33,R24
	.dbline -2
L3:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 36
	jmp _timer0_ovf_isr
	.area text(rom, con, rel)
	.dbfile E:\avrwork3_pt100\main.c
	.area data(ram, con, rel)
	.dbfile E:\avrwork3_pt100\main.c
L5:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\avrwork3_pt100\main.c
	.area text(rom, con, rel)
	.dbfile E:\avrwork3_pt100\main.c
	.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
	.dbsym s a L5 c
	.even
_timer0_ovf_isr::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 138
	.dbline 140
	ldi R24,84
	out 0x32,R24
	.dbline 141
	lds R24,_sendpro
	subi R24,255    ; addi 1
	sts _sendpro,R24
	.dbline 143
	lds R24,L5
	subi R24,255    ; addi 1
	sts L5,R24
	.dbline 144
	cpi R24,25
	brne L6
	.dbline 144
	.dbline 145
	clr R2
	sts L5,R2
	.dbline 146
	ldi R24,1
	sts _t_send_flag,R24
	.dbline 147
L6:
	.dbline -2
L4:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 24
	jmp _time1_compa_isr
	.area text(rom, con, rel)
	.dbfile E:\avrwork3_pt100\main.c
	.dbfunc e time1_compa_isr _time1_compa_isr fV
	.even
_time1_compa_isr::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 154
; }
; 
; #pragma interrupt_handler timer0_ovf_isr:10
; void timer0_ovf_isr(void)
; {
;  static uint8 a=0;
;  TCNT0 = 0x54; //reload counter value
;  sendpro++;
;  
;  a++;
;  if(25==a){
;    a=0;
;    t_send_flag = 1;                                   //发送周期
;  }
; 
; }
; 
; 
; #pragma interrupt_handler time1_compa_isr:7
; void time1_compa_isr(void)
; {
	.dbline 156
; //  Time_Int++;			  				   			  //温度0.1秒的标志
;   PORTA^=0x10;                                        //LED闪烁
	ldi R24,16
	in R2,0x1b
	eor R2,R24
	out 0x1b,R2
	.dbline 157
;   testFlag++;
	lds R24,_testFlag
	subi R24,255    ; addi 1
	sts _testFlag,R24
	.dbline -2
L8:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 4
	jmp _int0_isr
	.area text(rom, con, rel)
	.dbfile E:\avrwork3_pt100\main.c
	.dbfunc e int0_isr _int0_isr fV
	.even
_int0_isr::
	.dbline -1
	.dbline 162
; }
; 
; #pragma interrupt_handler int0_isr:2
; void int0_isr(void)
; {
	.dbline -2
L9:
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 56
	jmp _adc_isr
	.area text(rom, con, rel)
	.dbfile E:\avrwork3_pt100\main.c
	.dbfunc e adc_isr _adc_isr fV
	.even
_adc_isr::
	.dbline -1
	.dbline 169
;  
; }
; 
; 
; #pragma interrupt_handler adc_isr:15
; void adc_isr(void)
; {
	.dbline -2
L10:
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e adc_init _adc_init fV
	.even
_adc_init::
	.dbline -1
	.dbline 178
;  //conversion complete, read value (int) using...
;  // value=ADCL;            //Read 8 low bits first (important)
;  // value|=(int)ADCH << 8; //read 2 high bits and shift into top byte
; }
; 
; //ADC initialize
; // Conversion time: 150uS
; void adc_init(void)
; {
	.dbline 179
;  ADCSR = 0x00; //disable adc
	clr R2
	out 0x6,R2
	.dbline 180
;  ADMUX = 0xc0; //select adc input 0
	ldi R24,192
	out 0x7,R24
	.dbline 182
; // ACSR  = 0x80;
;  ADCSRA = 0x87;
	ldi R24,135
	out 0x6,R24
	.dbline -2
L11:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 187
; }
; 
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
	.dbline 189
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
	cli
	.dbline 190
;  port_init();
	xcall _port_init
	.dbline 191
;  timer0_init();
	xcall _timer0_init
	.dbline 192
;  timer1_init();
	xcall _timer1_init
	.dbline 193
;  InitUART( 71 ); 
	ldi R16,71
	xcall _InitUART
	.dbline 194
;  TempInit();
	xcall _TempInit
	.dbline 195
;  adc_init();
	xcall _adc_init
	.dbline 197
;  
;  MCUCR = 0x02;
	ldi R24,2
	out 0x35,R24
	.dbline 198
;  GICR  = 0x00;
	clr R2
	out 0x3b,R2
	.dbline 199
;  TIMSK = 0x11; //timer interrupt sources
	ldi R24,17
	out 0x39,R24
	.dbline 200
;  SEI(); //re-enable interrupts
	sei
	.dbline -2
L12:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e read_adc _read_adc fi
	.even
_read_adc::
	.dbline -1
	.dbline 212
;  //all peripherals are now initialized
; 
; 
;    
; 
;  
; 
; }
; 
; 
; unsigned int read_adc(void)//查询方式读取ADC单端通道
;    {
	.dbline 213
;       ADMUX=(0xc0|0x00); //adc_input:单端通道 0x00~0x07,0x1E,0x1F
	ldi R24,192
	out 0x7,R24
	.dbline 215
;       //0xc0:选择内部2.56V参考电压
;       ADCSRA|=(1<<ADSC); //启动AD转换
	sbi 0x6,6
L14:
	.dbline 216
L15:
	.dbline 216
;       while ((ADCSRA&(1<<ADIF))==0); 
	sbis 0x6,4
	rjmp L14
	.dbline 217
;       ADCSRA|=(1<<ADIF); //写1清除标志位
	sbi 0x6,4
	.dbline 218
;       return ADC; //ADC=ADCH:ADCL
	in R16,0x4
	in R17,0x5
	.dbline -2
L13:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e AdAverage _AdAverage fi
;            sum -> y+68
;          count -> y+72
;           temp -> R10,R11
;              j -> R12
;      value_buf -> y+0
;              i -> R14
	.even
_AdAverage::
	xcall push_gset5x
	sbiw R28,63
	sbiw R28,10  ; offset = 73
	.dbline -1
	.dbline 224
;    }
; 
;    #define N (34)
; 
; unsigned int AdAverage(void)
; {
	.dbline 228
; 	unsigned char count,i,j;
; 	unsigned int value_buf[N];
; 	unsigned int temp;
; 	unsigned long sum=0;
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	movw R30,R28
	subi R30,188  ; addi 68
	sbci R31,255
	std z+0,R24
	std z+1,R25
	std z+2,R26
	std z+3,R27
	.dbline 229
; 	for (count=0;count<N;count++)
	clr R0
	movw R30,R28
	subi R30,184  ; addi 72
	sbci R31,255
	std z+0,R0
	xjmp L21
L18:
	.dbline 230
	.dbline 231
	xcall _read_adc
	movw R2,R16
	ldi R24,2
	movw R30,R28
	subi R30,184  ; addi 72
	sbci R31,255
	ldd R0,z+0
	mul R24,R0
	movw R30,R0
	movw R24,R28
	add R30,R24
	adc R31,R25
	std z+1,R3
	std z+0,R2
	.dbline 233
L19:
	.dbline 229
	movw R30,R28
	subi R30,184  ; addi 72
	sbci R31,255
	ldd R0,z+0
	inc R0
	movw R30,R28
	subi R30,184  ; addi 72
	sbci R31,255
	std z+0,R0
L21:
	.dbline 229
	movw R30,R28
	subi R30,184  ; addi 72
	sbci R31,255
	ldd R24,z+0
	cpi R24,34
	brlo L18
	.dbline 234
; 	{
; 		value_buf[count] = read_adc();
; 
; 	}
; 	for (j=0;j<N-1;j++)
	clr R12
	xjmp L25
L22:
	.dbline 235
; 	{
	.dbline 236
; 		for (i=0;i<N-j;i++)
	clr R14
	xjmp L29
L26:
	.dbline 237
; 		{
	.dbline 238
; 			if ( value_buf[i]>value_buf[i+1] )
	ldi R24,2
	mul R24,R14
	movw R24,R28
	adiw R24,2
	movw R30,R0
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	movw R24,R28
	movw R30,R0
	add R30,R24
	adc R31,R25
	ldd R4,z+0
	ldd R5,z+1
	cp R2,R4
	cpc R3,R5
	brsh L30
	.dbline 239
; 			{
	.dbline 240
; 				temp = value_buf[i];
	ldi R24,2
	mul R24,R14
	movw R30,R0
	movw R24,R28
	add R30,R24
	adc R31,R25
	ldd R10,z+0
	ldd R11,z+1
	.dbline 241
; 				value_buf[i] = value_buf[i+1]; 
	ldi R24,2
	mul R24,R14
	movw R24,R28
	adiw R24,2
	movw R30,R0
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	movw R24,R28
	movw R30,R0
	add R30,R24
	adc R31,R25
	std z+1,R3
	std z+0,R2
	.dbline 242
; 				value_buf[i+1] = temp;
	ldi R24,2
	mul R24,R14
	movw R30,R0
	movw R24,R28
	adiw R24,2
	add R30,R24
	adc R31,R25
	std z+1,R11
	std z+0,R10
	.dbline 243
; 			}
L30:
	.dbline 244
L27:
	.dbline 236
	inc R14
L29:
	.dbline 236
	ldi R24,34
	sub R24,R12
	cp R14,R24
	brsh X0
	xjmp L26
X0:
	.dbline 245
L23:
	.dbline 234
	inc R12
L25:
	.dbline 234
	mov R24,R12
	cpi R24,33
	brsh X1
	xjmp L22
X1:
	.dbline 246
; 		}
; 	}
; 	for(count=1;count<N-1;count++)
	clr R0
	inc R0
	movw R30,R28
	subi R30,184  ; addi 72
	sbci R31,255
	std z+0,R0
	xjmp L38
L35:
	.dbline 247
	ldi R24,2
	movw R30,R28
	subi R30,184  ; addi 72
	sbci R31,255
	ldd R0,z+0
	mul R24,R0
	movw R30,R0

⌨️ 快捷键说明

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