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

📄 main.s

📁 数控电压源程序数控电压源程序数控电压源程序数控电压源程序
💻 S
📖 第 1 页 / 共 3 页
字号:
	.module main.c
	.area data(ram, con, rel)
_adc_vol::
	.blkb 4
	.area idata
	.word 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e adc_vol _adc_vol L
_read_vol::
	.blkb 4
	.area idata
	.word 0,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e read_vol _read_vol L
_ad_is_ok::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e ad_is_ok _ad_is_ok c
_ad_flag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e ad_flag _ad_flag c
_AD_COUNT::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e AD_COUNT _AD_COUNT i
_counter::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e counter _counter i
_time_delay::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e time_delay _time_delay i
_key_is_ok::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e key_is_ok _key_is_ok i
_key_value1::
	.blkb 2
	.area idata
	.word 16
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e key_value1 _key_value1 i
_key_value2::
	.blkb 2
	.area idata
	.word 16
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e key_value2 _key_value2 i
_Set_Value::
	.blkb 2
	.area idata
	.word 10
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e Set_Value _Set_Value i
_VOL_L::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e VOL_L _VOL_L i
_VOL_H::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e VOL_H _VOL_H i
_VOL_H0::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e VOL_H0 _VOL_H0 i
_VOL_L0::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e VOL_L0 _VOL_L0 i
_VOL_P::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e VOL_P _VOL_P c
_real_vol::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e real_vol _real_vol c
_clear_flag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e clear_flag _clear_flag c
_ahead_flag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e ahead_flag _ahead_flag c
_back_flag::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e back_flag _back_flag c
_ENTER::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e ENTER _ENTER c
_state:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym s state _state c
_cn:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym s cn _cn c
_welcome::
	.blkb 12
	.area idata
	.byte 'v,'o,'l,'t,45,'s,'o,'u,'r,'c,'e,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e welcome _welcome A[12:12]c
_st::
	.blkb 16
	.area idata
	.byte 'S,'y,'s,'t,'e,'m,45,'s,'t,'a,'r,'t,'i,'n,'g,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e st _st A[16:16]c
_setting::
	.blkb 5
	.area idata
	.byte 's,'e,'t,58,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e setting _setting A[5:5]c
_measure::
	.blkb 9
	.area idata
	.byte 'M,'e,'a,'s,'u,'r,'e,58,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e measure _measure A[9:9]c
_error::
	.blkb 6
	.area idata
	.byte 'e,'r,'r,'o,'r,0
	.area data(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbsym e error _error A[6:6]c
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbfunc e system_init _system_init fV
	.even
_system_init::
	.dbline -1
	.dbline 57
; //包含所需头文件
; #include <ioM16v.h>
; #include <macros.h>
; #include "delay.h"
; #include "LCD1602.H"
; #include "boxing.h"
; /*------宏定义------*/
; #define uchar	unsigned char
; #define uint	unsigned int
; 
; #define DAC_DATA    PORTB
; #define DAC_DDR     DDRB
; 
; uint Adverage_vol;
; long  adc_vol=0;
; long read_vol=0;
; unsigned int adc_calc(void);
; void control(void);
; uchar ad_is_ok=0;
; void adc_init(void);
; 
; unsigned char ad_flag=0;
; uint  AD_COUNT=0;
; uint counter=0;
; uint time_delay=0;
; uint key_is_ok=0;
; uint key_value1=16;
; uint key_value2=16;
; uint Set_Value=10;
; uchar Set_Value_H;
; uchar Set_Value_L;
; 
; uint VOL_L=0;
; uint VOL_H=0;
; uint VOL_H0=0;
; uint VOL_L0=0;
; 
; uchar VOL_P=0;
; uchar real_vol=0;
; 
; uchar clear_flag=0;
; uchar ahead_flag=0;
; uchar back_flag=0;
; uint setting_val;
; uchar ENTER=0;
; static uchar  state=0,cn=0;
; uint SET_VALUE[4];
; 
; uchar welcome[] = {"volt-source"};      //开机欢迎文字
; uchar st[] = {"System-starting"}; 
; uchar setting[] = {"set:"};   //设定值
; uchar measure[] = {"Measure:"};   // 测量值
; uchar error[]={"error"};
; 
; 
; void system_init()
; {
	.dbline 58
;   Write_Position(1,1);
	ldi R18,1
	ldi R19,0
	ldi R16,1
	ldi R17,0
	xcall _Write_Position
	.dbline 59
;   Write_String(welcome);
	ldi R16,<_welcome
	ldi R17,>_welcome
	xcall _Write_String
	.dbline 60
;   Write_Position(2,1);
	ldi R18,1
	ldi R19,0
	ldi R16,2
	ldi R17,0
	xcall _Write_Position
	.dbline 61
;   Write_String(st);
	ldi R16,<_st
	ldi R17,>_st
	xcall _Write_String
	.dbline 62
;   delay_nms(1500);
	ldi R16,1500
	ldi R17,5
	xcall _delay_nms
	.dbline 63
;   Clear_Screen;
	ldi R16,1
	xcall _Write_Command
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e dec_to_bin _dec_to_bin fc
;          temp1 -> R20
;              i -> R22,R23
;           temp -> R10,R11
;           data -> R12,R13
	.even
_dec_to_bin::
	xcall push_gset4
	movw R12,R16
	.dbline -1
	.dbline 67
; }
;  //用于将十进制数转换成IO口上的二进制数
; uchar  dec_to_bin(uint data)
; {
	.dbline 69
; 
;   uint i=0;
	clr R22
	clr R23
	.dbline 70
;   uint temp=0;
	clr R10
	clr R11
	.dbline 71
;   uchar temp1=0x00;
	clr R20
	.dbline 72
;   temp=data;
	movw R10,R12
	.dbline 73
;   for(;i<8;i++)
	xjmp L6
L3:
	.dbline 74
;   {
	.dbline 75
;    if((temp%2)==1)
	movw R24,R10
	andi R24,1
	andi R25,0
	cpi R24,1
	ldi R30,0
	cpc R25,R30
	brne L7
	.dbline 76
; 	{
	.dbline 77
; 	 temp1 |=(1<<i);
	ldi R16,1
	ldi R17,0
	movw R18,R22
	xcall lsl16
	mov R2,R20
	clr R3
	or R2,R16
	or R3,R17
	mov R20,R2
	.dbline 79
; 	
; 	 }
L7:
	.dbline 80
;    if((temp%2)==0) 
	sbrc R10,0
	rjmp L9
	.dbline 81
; 	{
	.dbline 82
; 	 temp1 &=~(1<<i);
	ldi R16,1
	ldi R17,0
	movw R18,R22
	xcall lsl16
	movw R2,R16
	com R2
	com R3
	mov R4,R20
	clr R5
	and R4,R2
	and R5,R3
	mov R20,R4
	.dbline 83
; 	 }
L9:
	.dbline 84
	lsr R11
	ror R10
	.dbline 85
L4:
	.dbline 73
	subi R22,255  ; offset = 1
	sbci R23,255
L6:
	.dbline 73
	cpi R22,8
	ldi R30,0
	cpc R23,R30
	brlo L3
	.dbline 87
; 	 temp =temp/2;
;    }
;  
; 	 return (temp1);
	mov R16,R20
	.dbline -2
L2:
	xcall pop_gset4
	.dbline 0 ; func end
	ret
	.dbsym r temp1 20 c
	.dbsym r i 22 i
	.dbsym r temp 10 i
	.dbsym r data 12 i
	.dbend
	.dbfunc e Display_VOL _Display_VOL fV
	.even
_Display_VOL::
	xcall push_gset2
	.dbline -1
	.dbline 91
; }
; 
; void Display_VOL(void)
; {
	.dbline 93
;  // Set_Value=10*SET_VALUE[1]+SET_VALUE[3];
;   Set_Value_H=Set_Value/10+0x30;
	ldi R18,10
	ldi R19,0
	lds R16,_Set_Value
	lds R17,_Set_Value+1
	xcall div16u
	movw R24,R16
	adiw R24,48
	sts _Set_Value_H,R24
	.dbline 94
;   Set_Value_L=Set_Value%10+0x30;
	ldi R18,10
	ldi R19,0
	lds R16,_Set_Value
	lds R17,_Set_Value+1
	xcall mod16u
	movw R24,R16
	adiw R24,48
	sts _Set_Value_L,R24
	.dbline 95
;   Write_Position(1,1);
	ldi R18,1
	ldi R19,0
	ldi R16,1
	ldi R17,0
	xcall _Write_Position
	.dbline 96
;   Write_String(setting);
	ldi R16,<_setting
	ldi R17,>_setting
	xcall _Write_String
	.dbline 98
;   
;   Write_Position(1,5);
	ldi R18,5
	ldi R19,0
	ldi R16,1
	ldi R17,0
	xcall _Write_Position
	.dbline 99
;   Write_Data(Set_Value_H);
	lds R16,_Set_Value_H
	clr R17
	xcall _Write_Data
	.dbline 100
;   Write_String(".");
	ldi R16,<L12
	ldi R17,>L12
	xcall _Write_String
	.dbline 101
;   Write_Data(Set_Value_L);
	lds R16,_Set_Value_L
	clr R17
	xcall _Write_Data
	.dbline 102
;   Write_String("v");
	ldi R16,<L13
	ldi R17,>L13
	xcall _Write_String
	.dbline 104
;  
;   adc_vol=Adverage_vol*2+40;//作为补偿电压值
	lds R18,_Adverage_vol
	lds R19,_Adverage_vol+1
	ldi R16,2
	ldi R17,0
	xcall empy16s
	movw R24,R16
	adiw R24,40
	movw R2,R24
	clr R4
	clr R5
	sts _adc_vol+1,R3
	sts _adc_vol,R2
	sts _adc_vol+2+1,R5
	sts _adc_vol+2,R4
	.dbline 105
;   VOL_H0=adc_vol/1000+0x30;
	ldi R20,232
	ldi R21,3
	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 div32s
	movw R2,R16
	movw R4,R18
	ldi R20,48
	ldi R21,0
	ldi R22,0
	ldi R23,0
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	sts _VOL_H0+1,R3
	sts _VOL_H0,R2
	.dbline 106
;   VOL_H=adc_vol/100%10+0x30;
	ldi R20,100
	ldi R21,0
	ldi R22,0
	ldi R23,0
	lds R4,_adc_vol+2
	lds R5,_adc_vol+2+1
	lds R2,_adc_vol
	lds R3,_adc_vol+1
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32s
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall mod32s
	movw R2,R16
	movw R4,R18
	ldi R20,48
	ldi R21,0
	ldi R22,0
	ldi R23,0
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	sts _VOL_H+1,R3
	sts _VOL_H,R2
	.dbline 109
; //  VOL_L0=adc_vol/10%10+0x30;
; 
;   Write_Position(2,1);
	ldi R18,1
	ldi R19,0
	ldi R16,2
	ldi R17,0
	xcall _Write_Position
	.dbline 110
;   Write_String("real_vol:");
	ldi R16,<L14
	ldi R17,>L14
	xcall _Write_String
	.dbline 111
;   Write_Position(2,10);
	ldi R18,10
	ldi R19,0
	ldi R16,2
	ldi R17,0
	xcall _Write_Position
	.dbline 112
;   Write_Data(VOL_H0);
	lds R16,_VOL_H0
	lds R17,_VOL_H0+1
	xcall _Write_Data
	.dbline 113
;   Write_Data(0x2e);
	ldi R16,46
	ldi R17,0
	xcall _Write_Data
	.dbline 114
;   Write_Data(VOL_H);
	lds R16,_VOL_H
	lds R17,_VOL_H+1
	xcall _Write_Data
	.dbline 116
;  // Write_Data(VOL_L0);
;   Write_Position(2,13);
	ldi R18,13
	ldi R19,0
	ldi R16,2
	ldi R17,0
	xcall _Write_Position
	.dbline 117
;   Write_String("v");
	ldi R16,<L13
	ldi R17,>L13
	xcall _Write_String
	.dbline -2
L11:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
L16:
	.blkb 2
L17:
	.blkb 2
	.area text(rom, con, rel)
	.dbfile E:\张秋伟\我的实验\数控电压源\main.c
	.dbfunc e KeyScan _KeyScan fi
	.dbsym s key_line L17 i
	.dbsym s key_value L16 i
;     key_return -> R20,R21
;              i -> R22
	.even
_KeyScan::
	xcall push_gset2
	.dbline -1
	.dbline 122
;  
; }
; #define key_mask  0b00001111
; uint KeyScan(void)
; {
	.dbline 124
;  static uint key_value,key_line;
;  uint key_return=16;
	ldi R20,16
	ldi R21,0
	.dbline 126
;  uchar i;
;  DDRD=0xf0;
	ldi R24,240
	out 0x11,R24
	.dbline 127
;    key_line=0b00010000;
	ldi R24,16
	ldi R25,0
	sts L17+1,R25
	sts L17,R24
	.dbline 128
;    for(i=1;i<=4;i++)
	ldi R22,1
	xjmp L21
L18:
	.dbline 129
;    {
	.dbline 130
;    PORTD=~key_line;
	lds R2,L17
	lds R3,L17+1
	com R2
	com R3
	out 0x12,R2
	.dbline 131
;    PORTD=~key_line;
	lds R2,L17
	lds R3,L17+1
	com R2
	com R3
	out 0x12,R2
	.dbline 132
;    key_value=key_mask&PIND;
	in R24,0x10
	clr R25
	andi R24,15
	andi R25,0
	sts L16+1,R25
	sts L16,R24
	.dbline 133
;    if(key_value==key_mask)
	cpi R24,15
	ldi R30,0
	cpc R25,R30
	brne L20
	.dbline 134
;      key_line<<=1;
	lds R2,L17
	lds R3,L17+1
	lsl R2
	rol R3
	sts L17+1,R3
	sts L17,R2
	.dbline 136
;      else
; 	 break;
L23:
	.dbline 137
L19:
	.dbline 128
	inc R22
L21:
	.dbline 128
	ldi R24,4
	cp R24,R22
	brsh L18
L20:
	.dbline 138
;    }
; 	delay_nms(5);
	ldi R16,5
	ldi R17,0
	xcall _delay_nms
	.dbline 139
;   if(key_value==(key_mask&PIND))
	in R24,0x10
	clr R25
	andi R24,15
	andi R25,0
	lds R2,L16
	lds R3,L16+1
	cp R2,R24
	cpc R3,R25
	breq X1
	xjmp L24
X1:
	.dbline 140
;    {
	.dbline 142
;     
;     switch(key_line|key_value)
	lds R22,L17
	lds R23,L17+1
	or R22,R2
	or R23,R3
	cpi R22,39
	ldi R30,0
	cpc R23,R30
	brne X2
	xjmp L36
X2:
	cpi R22,43
	ldi R30,0
	cpc R23,R30
	brne X3
	xjmp L35
X3:
	cpi R22,45
	ldi R30,0
	cpc R23,R30
	brne X4
	xjmp L34
X4:
	cpi R22,46
	ldi R30,0
	cpc R23,R30
	brne X5
	xjmp L33
X5:
	ldi R24,46
	ldi R25,0
	cp R24,R22
	cpc R25,R23
	brlt L46
L45:
	cpi R22,23
	ldi R30,0
	cpc R23,R30
	brne X6
	xjmp L32
X6:
	cpi R22,27
	ldi R30,0
	cpc R23,R30
	brne X7
	xjmp L31
X7:
	cpi R22,29
	ldi R30,0
	cpc R23,R30
	brne X8
	xjmp L30
X8:
	cpi R22,30
	ldi R30,0
	cpc R23,R30
	breq L29
	xjmp L26
L46:
	cpi R22,71
	ldi R30,0
	cpc R23,R30
	brne X9
	xjmp L40
X9:
	cpi R22,75
	ldi R30,0
	cpc R23,R30
	brne X10
	xjmp L39
X10:
	cpi R22,77
	ldi R30,0
	cpc R23,R30
	brne X11
	xjmp L38
X11:
	cpi R22,78
	ldi R30,0
	cpc R23,R30
	breq L37
	cpi R22,71
	ldi R30,0
	cpc R23,R30
	brge X12
	xjmp L26
X12:
L47:
	cpi R22,135
	ldi R30,0
	cpc R23,R30
	brne X13
	xjmp L44
X13:
	cpi R22,139
	ldi R30,0
	cpc R23,R30
	brne X14
	xjmp L43
X14:
	cpi R22,141
	ldi R30,0
	cpc R23,R30
	breq L42
	cpi R22,142
	ldi R30,0
	cpc R23,R30
	breq L41
	xjmp L26
X0:
	.dbline 143
;     {
L29:
	.dbline 144
;     case 0b00011110:key_return=7;
	ldi R20,7
	ldi R21,0
	.dbline 145
; 	                break;
	xjmp L27
L30:
	.dbline 146
; 	case 0b00011101:key_return=8;
	ldi R20,8
	ldi R21,0
	.dbline 147
; 	                break;
	xjmp L27
L31:
	.dbline 148
; 	case 0b00011011:key_return=9;
	ldi R20,9
	ldi R21,0
	.dbline 149
; 	                break;	
	xjmp L27
L32:
	.dbline 150
; 	case 0b00010111:key_return=11;
	ldi R20,11
	ldi R21,0
	.dbline 151
; 	                break;	
	xjmp L27
L33:
	.dbline 152
; 	case 0b00101110:key_return=4;
	ldi R20,4
	ldi R21,0
	.dbline 153
; 	                break;	
	xjmp L27
L34:
	.dbline 154
; 	case 0b00101101:key_return=5;
	ldi R20,5
	ldi R21,0
	.dbline 155
; 	                break;
	xjmp L27
L35:
	.dbline 156
;     case 0b00101011:key_return=6;
	ldi R20,6
	ldi R21,0

⌨️ 快捷键说明

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