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

📄 main.s

📁 数控电压源程序数控电压源程序数控电压源程序数控电压源程序
💻 S
📖 第 1 页 / 共 3 页
字号:
	clr R2
	sts _auto_flag,R2
L119:
	.dbline 320
L113:
	.dbline 309
	lds R24,_auto_flag
	cpi R24,4
	breq L112
	.dbline 321
;          }
;          break;
L84:
L85:
	.dbline -2
L83:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbend
	.dbfunc e function_DAC _function_DAC fV
;              i -> R20,R21
	.even
_function_DAC::
	xcall push_gset1
	.dbline -1
	.dbline 342
;  /* case 4:
;          Write_Position(1,12); 
;          Write_String("sin"); 
; 		  for(;auto_flag == 4;)
;          {
; 		  
; 		   uint i;
; 		   for(i=0;i<=200;i++)
; 		   {
; 		    DAC_DATA=Sin[i];
; 			delay_nus(10);
; 		   
; 		   if(KeyScan()==15)
; 	        auto_flag=5;
;          }
;          break;*/
;   }
; 
; }
; void function_DAC()
; {
	.dbline 343
;   if(ENTER==1)
	lds R24,_ENTER
	cpi R24,1
	brne L122
	.dbline 344
;  {
	.dbline 345
;   ENTER=0;
	clr R2
	sts _ENTER,R2
	.dbline 346
;   DAC_DATA=Set_Value;
	lds R2,_Set_Value
	lds R3,_Set_Value+1
	out 0x18,R2
	.dbline 347
;   control();
	xcall _control
	.dbline 348
;  }
L122:
	.dbline 349
;  if(ahead_flag)
	lds R2,_ahead_flag
	tst R2
	breq L124
	.dbline 350
;  {
	.dbline 351
;    ahead_flag=0;
	clr R2
	sts _ahead_flag,R2
	.dbline 352
;    if(Set_Value<99)
	lds R24,_Set_Value
	lds R25,_Set_Value+1
	cpi R24,99
	ldi R30,0
	cpc R25,R30
	brsh L126
	.dbline 353
; 	{
	.dbline 354
; 	  Set_Value++;
	adiw R24,1
	sts _Set_Value+1,R25
	sts _Set_Value,R24
	.dbline 355
; 	  DAC_DATA=Set_Value;
	out 0x18,R24
	.dbline 356
; 	  control();
	xcall _control
	.dbline 357
;    }
L126:
	.dbline 358
;  }
L124:
	.dbline 360
;  
;  if(back_flag)
	lds R2,_back_flag
	tst R2
	breq L128
	.dbline 361
;  {
	.dbline 362
;    back_flag=0;
	clr R2
	sts _back_flag,R2
	.dbline 363
;     if(Set_Value>0)
	lds R2,_Set_Value
	lds R3,_Set_Value+1
	tst R2
	brne X40
	tst R3
	breq L130
X40:
	.dbline 364
; 	{
	.dbline 365
; 	 Set_Value--;
	lds R24,_Set_Value
	lds R25,_Set_Value+1
	sbiw R24,1
	sts _Set_Value+1,R25
	sts _Set_Value,R24
	.dbline 366
; 	 DAC_DATA=Set_Value;
	out 0x18,R24
	.dbline 367
; 	 control();
	xcall _control
	.dbline 368
; 	}
L130:
	.dbline 369
;  }
L128:
	.dbline 371
;  
;  if(clear_flag)
	lds R2,_clear_flag
	tst R2
	breq L132
	.dbline 372
;  {
	.dbline 373
;   uint i=0;
	clr R20
	clr R21
	.dbline 374
;   clear_flag=0;
	clr R2
	sts _clear_flag,R2
	.dbline 375
;   auto_flag=0;
	sts _auto_flag,R2
	.dbline 376
;   cn=0;
	sts _cn,R2
	.dbline 377
;   Clear_Screen;
	ldi R16,1
	xcall _Write_Command
	.dbline 378
;   for(i=0;i<4;i++)
	xjmp L137
L134:
	.dbline 379
	.dbline 380
	ldi R16,2
	ldi R17,0
	movw R18,R20
	xcall empy16s
	movw R30,R16
	ldi R24,<_SET_VALUE
	ldi R25,>_SET_VALUE
	add R30,R24
	adc R31,R25
	clr R2
	clr R3
	std z+1,R3
	std z+0,R2
	.dbline 381
L135:
	.dbline 378
	subi R20,255  ; offset = 1
	sbci R21,255
L137:
	.dbline 378
	cpi R20,4
	ldi R30,0
	cpc R21,R30
	brlo L134
	.dbline 382
	clr R2
	clr R3
	sts _Set_Value+1,R3
	sts _Set_Value,R2
	.dbline 383
	out 0x18,R2
	.dbline 384
	xcall _control
	.dbline 385
L132:
	.dbline -2
L121:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbend
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
_temp_vol::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e temp_vol _temp_vol i
_temp_value::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e temp_value _temp_value i
	.area vector(rom, abs)
	.org 56
	jmp _adc_isr
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbfunc e adc_isr _adc_isr fV
;        voltage -> y+0
	.even
_adc_isr::
	xcall push_lset
	sbiw R28,4
	.dbline -1
	.dbline 393
;    {
; 	SET_VALUE[i]=0;
;    }
;   Set_Value=0;
;   DAC_DATA=Set_Value;
;   control();
;  }
; }
; 
; uint temp_vol=0;
; uint temp_value=0;
; uchar temp_H,temp_L;
; #pragma interrupt_handler adc_isr:15
; void adc_isr(void)
; {
	.dbline 395
;   unsigned long int voltage;
;   voltage=adc_calc();
	xcall _adc_calc
	movw R2,R16
	clr R4
	clr R5
	movw R30,R28
	std z+0,R2
	std z+1,R3
	std z+2,R4
	std z+3,R5
	.dbline 396
;   Adverage_vol=voltage;
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	sts _Adverage_vol+1,R3
	sts _Adverage_vol,R2
	.dbline 397
;   ad_flag=1;
	ldi R24,1
	sts _ad_flag,R24
	.dbline -2
L138:
	adiw R28,4
	xcall pop_lset
	.dbline 0 ; func end
	reti
	.dbsym l voltage 0 l
	.dbend
	.dbfunc e control _control fV
	.even
_control::
	.dbline -1
	.dbline 401
; }
; 
;  void control(void)
;  {
	.dbline 402
;   temp_vol=2*Adverage_vol+45;
	lds R18,_Adverage_vol
	lds R19,_Adverage_vol+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R24,R16
	adiw R24,45
	sts _temp_vol+1,R25
	sts _temp_vol,R24
	.dbline 403
;   temp_vol=temp_vol/100;
	ldi R18,100
	ldi R19,0
	movw R16,R24
	xcall div16u
	sts _temp_vol+1,R17
	sts _temp_vol,R16
	.dbline 404
;   temp_value=Set_Value;
	lds R2,_Set_Value
	lds R3,_Set_Value+1
	sts _temp_value+1,R3
	sts _temp_value,R2
	.dbline 405
;   if(cn ==0)
	lds R2,_cn
	tst R2
	breq X42
	xjmp L140
X42:
	.dbline 406
;   {
	xjmp L143
L142:
	.dbline 408
;    while(temp_vol < Set_Value)
;    {
	.dbline 409
;       if(temp_value>=255);
	lds R24,_temp_value
	lds R25,_temp_value+1
	cpi R24,255
	ldi R30,0
	cpc R25,R30
	brlo L145
	.dbline 409
	xjmp L146
L145:
	.dbline 411
; 	   else
; 	   temp_value++;
	lds R24,_temp_value
	lds R25,_temp_value+1
	adiw R24,1
	sts _temp_value+1,R25
	sts _temp_value,R24
L146:
	.dbline 412
; 	  DAC_DATA=temp_value;
	lds R2,_temp_value
	lds R3,_temp_value+1
	out 0x18,R2
	.dbline 413
; 	  ADCSRA|=BIT(ADSC);
	sbi 0x6,6
L147:
	.dbline 414
L148:
	.dbline 414
	lds R2,_ad_flag
	tst R2
	breq L147
	.dbline 415
	clr R2
	sts _ad_flag,R2
	.dbline 416
	lds R18,_Adverage_vol
	lds R19,_Adverage_vol+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R24,R16
	adiw R24,40
	sts _temp_vol+1,R25
	sts _temp_vol,R24
	.dbline 417
	ldi R18,100
	ldi R19,0
	movw R16,R24
	xcall div16u
	sts _temp_vol+1,R17
	sts _temp_vol,R16
	.dbline 418
L143:
	.dbline 407
	lds R2,_Set_Value
	lds R3,_Set_Value+1
	lds R4,_temp_vol
	lds R5,_temp_vol+1
	cp R4,R2
	cpc R5,R3
	brsh X43
	xjmp L142
X43:
	xjmp L151
L150:
	.dbline 421
; 	  while(!ad_flag);
; 	  ad_flag=0;
; 	  temp_vol=(unsigned int)2*Adverage_vol+40;
;       temp_vol=(unsigned int)temp_vol/100;
;    }
;   
;    while(temp_vol> Set_Value)
;    {
	.dbline 422
;     if(temp_value <=0) ;
	lds R2,_temp_value
	lds R3,_temp_value+1
	tst R2
	brne L153
	tst R3
	brne L153
X41:
	.dbline 422
	xjmp L154
L153:
	.dbline 424
; 	  else
;       temp_value--;
	lds R24,_temp_value
	lds R25,_temp_value+1
	sbiw R24,1
	sts _temp_value+1,R25
	sts _temp_value,R24
L154:
	.dbline 425
; 	  DAC_DATA=temp_value;
	lds R2,_temp_value
	lds R3,_temp_value+1
	out 0x18,R2
	.dbline 426
; 	  ADCSRA|=BIT(ADSC);
	sbi 0x6,6
L155:
	.dbline 427
L156:
	.dbline 427
	lds R2,_ad_flag
	tst R2
	breq L155
	.dbline 428
	clr R2
	sts _ad_flag,R2
	.dbline 429
	lds R18,_Adverage_vol
	lds R19,_Adverage_vol+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R24,R16
	adiw R24,40
	sts _temp_vol+1,R25
	sts _temp_vol,R24
	.dbline 430
	ldi R18,100
	ldi R19,0
	movw R16,R24
	xcall div16u
	sts _temp_vol+1,R17
	sts _temp_vol,R16
	.dbline 431
L151:
	.dbline 420
	lds R2,_Set_Value
	lds R3,_Set_Value+1
	lds R4,_temp_vol
	lds R5,_temp_vol+1
	cp R2,R4
	cpc R3,R5
	brsh X44
	xjmp L150
X44:
	.dbline 432
L140:
	.dbline -2
L139:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e port_init _port_init fV
	.even
_port_init::
	.dbline -1
	.dbline 438
; 	  while(!ad_flag);
; 	  ad_flag=0;
; 	  temp_vol=(unsigned int)2*Adverage_vol+40;
;       temp_vol=(unsigned int)temp_vol/100;
;    }
;   }   
;  }
; 
;  
; //端口初始化
; void port_init(void)
; {
	.dbline 439
;  PORTA = 0x00;//低三位作为1602控制端
	clr R2
	out 0x1b,R2
	.dbline 440
;  DDRA  = 0x07;//低三位作为1602控制端
	ldi R24,7
	out 0x1a,R24
	.dbline 441
;  PORTD = 0x0F;//矩阵键盘的接口
	ldi R24,15
	out 0x12,R24
	.dbline 442
;  DDRD  = 0xF0;
	ldi R24,240
	out 0x11,R24
	.dbline 443
;  PORTB = 0x00;//DAC0832的数据控制端
	out 0x18,R2
	.dbline 444
;  DDRB  = 0xFF;//DAC0832的数据控制端
	ldi R24,255
	out 0x17,R24
	.dbline 445
;  PORTC = 0x00;//PC口作为1602的数据端
	out 0x15,R2
	.dbline 446
;  DDRC  = 0xFF;//PC口作为1602的数据端
	out 0x14,R24
	.dbline -2
L158:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e timer0_init _timer0_init fV
	.even
_timer0_init::
	.dbline -1
	.dbline 451
; }
; 
; //定时器T0初始化
; void timer0_init(void)
; {
	.dbline 452
;  TCCR0  = 0x00;//停止定时器
	clr R2
	out 0x33,R2
	.dbline 453
;  TCNT0 = 0x25;//初始值
	ldi R24,37
	out 0x32,R24
	.dbline 454
;  OCR0   = 0xC0;//匹配值
	ldi R24,192
	out 0x3c,R24
	.dbline 455
;  TIMSK |= 0x02;//中断允许
	in R24,0x39
	ori R24,2
	out 0x39,R24
	.dbline 456
;  TCCR0  = 0x04;//启动定时器
	ldi R24,4
	out 0x33,R24
	.dbline -2
L159:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 76
	jmp _timer0_comp_isr
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbfunc e timer0_comp_isr _timer0_comp_isr fV
	.even
_timer0_comp_isr::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R25
	st -y,R30
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 463
; }
; 
; 
; //T0比较中断服务程序
; #pragma interrupt_handler timer0_comp_isr:20
; void timer0_comp_isr(void)
; {
	.dbline 466
;  //中断发生时刻在TCNT0=OCR0
;     
;   if(++counter>=4)
	lds R24,_counter
	lds R25,_counter+1
	adiw R24,1
	sts _counter+1,R25
	sts _counter,R24
	cpi R24,4
	ldi R30,0
	cpc R25,R30
	brlo L161
	.dbline 467
;   {
	.dbline 468
;    counter=0;
	clr R2
	clr R3
	sts _counter+1,R3
	sts _counter,R2
	.dbline 469
;    key_is_ok=1;
	ldi R24,1
	ldi R25,0
	sts _key_is_ok+1,R25
	sts _key_is_ok,R24
	.dbline 470
;   }
L161:
	.dbline 471
	lds R24,_AD_COUNT
	lds R25,_AD_COUNT+1
	adiw R24,1
	sts _AD_COUNT+1,R25
	sts _AD_COUNT,R24
	cpi R24,5
	ldi R30,0
	cpc R25,R30
	brlo L163
	.dbline 472
	.dbline 473
	clr R2
	clr R3
	sts _AD_COUNT+1,R3
	sts _AD_COUNT,R2
	.dbline 474
	ldi R24,1
	sts _ad_is_ok,R24
	.dbline 475
L163:
	.dbline -2
L160:
	ld R2,y+
	out 0x3f,R2
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e init_devices _init_devices fV
	.even
_init_devices::
	.dbline -1
	.dbline 481
;   if(++AD_COUNT>=5)
;   {
;    AD_COUNT=0;
;    ad_is_ok=1;
;   } 
;   
; }
;  
; 
; void init_devices(void)
; {
	.dbline 482
;  CLI(); //禁止所有中断
	cli
	.dbline 483
;  MCUCR  = 0x00;
	clr R2
	out 0x35,R2
	.dbline 484
;  GICR   = 0x00;
	out 0x3b,R2
	.dbline 485
;  port_init();
	xcall _port_init
	.dbline 486
;  Initialize_LCD();
	xcall _Initialize_LCD
	.dbline 487
;  timer0_init();
	xcall _timer0_init
	.dbline 488
;  adc_init();
	xcall _adc_init
	.dbline 489
;  SEI();//开全局中断
	sei
	.dbline -2
L165:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
;        keycode -> R20,R21
;              i -> R20,R21
	.even
_main::
	.dbline -1
	.dbline 495
; }
; 
; //主函数
; 
; void main(void)
; {
	.dbline 496
; uint i=0,keycode=16;
	clr R20
	clr R21
	.dbline 496
	ldi R20,16
	.dbline 497
;  init_devices();
	xcall _init_devices
	.dbline 499
;  //在这继续添加你的代码
;  system_init();
	xcall _system_init
	.dbline 500
;  DAC_DDR=0xff;
	ldi R24,255
	out 0x17,R24
	.dbline 501
;  DAC_DATA=Set_Value;
	lds R2,_Set_Value
	lds R3,_Set_Value+1
	out 0x18,R2
	xjmp L168
L167:
	.dbline 504
; 
;  while(1)
;  { 
	.dbline 505
;    Display_VOL();
	xcall _Display_VOL
	.dbline 506
;    function_DAC();
	xcall _function_DAC
	.dbline 507
;    control();  
	xcall _control
	.dbline 508
;    signal_function();
	xcall _signal_function
	.dbline 509
;    control();  
	xcall _control
	.dbline 510
;    if(key_is_ok)
	lds R2,_key_is_ok
	lds R3,_key_is_ok+1
	tst R2
	brne X45
	tst R3
	breq L170
X45:
	.dbline 511
;    {
	.dbline 512
;     read_keyvalue();
	xcall _read_keyvalue
	.dbline 513
; 	key_is_ok=0;
	clr R2
	clr R3
	sts _key_is_ok+1,R3
	sts _key_is_ok,R2
	.dbline 514
;    } 
L170:
	.dbline 515
;    if(ad_is_ok)
	lds R2,_ad_is_ok
	tst R2
	breq L172
	.dbline 516
;    {
	.dbline 517
;     ad_is_ok=0;
	clr R2
	sts _ad_is_ok,R2
	.dbline 518
;     ADCSRA|=BIT(ADSC);
	sbi 0x6,6
	.dbline 519
;    } 
L172:
	.dbline 520
L168:
	.dbline 503
	xjmp L167
X46:
	.dbline -2
L166:
	.dbline 0 ; func end
	ret
	.dbsym r keycode 20 i
	.dbsym r i 20 i
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
_temp_L::
	.blkb 1
	.dbsym e temp_L _temp_L c
_temp_H::
	.blkb 1
	.dbsym e temp_H _temp_H c
_SET_VALUE::
	.blkb 8
	.dbsym e SET_VALUE _SET_VALUE A[8:4]i
_setting_val::
	.blkb 2
	.dbsym e setting_val _setting_val i
_Set_Value_L::
	.blkb 1
	.dbsym e Set_Value_L _Set_Value_L c
_Set_Value_H::
	.blkb 1
	.dbsym e Set_Value_H _Set_Value_H c
_Adverage_vol::
	.blkb 2
	.dbsym e Adverage_vol _Adverage_vol i
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L111:
	.blkb 4
	.area idata
	.byte 's,'a,'w,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L104:
	.blkb 4
	.area idata
	.byte 's,'q,'u,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L98:
	.blkb 4
	.area idata
	.byte 45,32,32,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L92:
	.blkb 4
	.area idata
	.byte 43,32,32,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L88:
	.blkb 4
	.area idata
	.byte 'o,'f,'f,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L14:
	.blkb 10
	.area idata
	.byte 'r,'e,'a,'l,95,'v,'o,'l,58,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L13:
	.blkb 2
	.area idata
	.byte 'v,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L12:
	.blkb 2
	.area idata
	.byte 46,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c

⌨️ 快捷键说明

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