📄 main.s
字号:
.module main.c
.area data(ram, con, rel)
_DAC4_value::
.blkb 1
.area idata
.byte 1
.area data(ram, con, rel)
.dbfile D:\hujie\main.c
.dbsym e DAC4_value _DAC4_value c
_K1::
.blkb 4
.area idata
.word 0x26e9,0x3fc1
.area data(ram, con, rel)
.dbfile D:\hujie\main.c
.dbsym e K1 _K1 D
_mode::
.blkb 1
.area idata
.byte 1
.area data(ram, con, rel)
.dbfile D:\hujie\main.c
.dbsym e mode _mode c
_arv_ADC::
.blkb 4
.area idata
.word 0,0
.area data(ram, con, rel)
.dbfile D:\hujie\main.c
.dbsym e arv_ADC _arv_ADC l
_arv_count::
.blkb 4
.area idata
.word 0,0
.area data(ram, con, rel)
.dbfile D:\hujie\main.c
.dbsym e arv_count _arv_count l
.area text(rom, con, rel)
.dbfile D:\hujie\main.c
.dbfunc e main _main fV
.even
_main::
sbiw R28,4
.dbline -1
.dbline 28
; #include <eeprom.h>
; #include <io8515v.h>
; #include "init.h"
; #include "key5.h"
; #include "1602LCD.h"
; #define DEFAULT_K1 1.509
; #define DEFAULT_T 100
; #define MIN_T 50
; // globals:
; unsigned int value; // 电流数值
; //unsigned int *p; // 数据指针
; unsigned char DAC4_value=1;
; float K1=DEFAULT_K1;
; unsigned int ADC; // AD转换值
; unsigned int ADC_GD;
; unsigned int DAC; // DA转换值
; unsigned char time_count; // 计数寄存器
; float POUNT;
; unsigned char value_table[5]; // 数据缓冲区
; unsigned char mode=1; // 模式标志
; unsigned int value_temp; // 数据寄存器
; unsigned char j; // 光标位置
; unsigned long arv_ADC=0;
; unsigned long arv_count=0;
; unsigned int Time1;
;
; void main(void)
; {
.dbline 29
; mode_choice();
rcall _mode_choice
.dbline 30
; init_devices(); // 硬件初始化
rcall _init_devices
rjmp L3
L2:
.dbline 33
.dbline 34
ldi R24,<_value
ldi R25,>_value
std y+3,R25
std y+2,R24
ldi R24,4
std y+0,R24
clr R18
ldi R16,2
rcall _key_service
.dbline 35
L3:
.dbline 32
rjmp L2
X0:
.dbline -2
.dbline 36
;
; while(1) // 主循环
; {
; key_service(2,0,4,&value ); // 键盘服务
; }
; }
L1:
adiw R28,4
.dbline 0 ; func end
ret
.dbend
.dbfunc e SaveToEEPROM _SaveToEEPROM fV
; i -> R20,R21
; add -> R22,R23
; len -> R10
; off -> R12
.even
_SaveToEEPROM::
rcall push_gset4
mov R10,R18
mov R12,R16
ldd R22,y+8
ldd R23,y+9
.dbline -1
.dbline 38
; void SaveToEEPROM(unsigned char off,unsigned char len,unsigned add)
; {
.dbline 40
; int i;
; for(i=0;i<len;i++)
clr R20
clr R21
rjmp L9
L6:
.dbline 41
mov R2,R12
clr R3
mov R24,R2
subi R24,255 ; addi 1
mov R12,R24
ldi R24,<_value_table
ldi R25,>_value_table
mov R30,R2
clr R31
add R30,R24
adc R31,R25
ldd R18,z+0
mov R2,R22
mov R3,R23
subi R22,255 ; offset = 1
sbci R23,255
mov R16,R2
mov R17,R3
rcall _EEPROMwrite
L7:
.dbline 40
subi R20,255 ; offset = 1
sbci R21,255
L9:
.dbline 40
mov R2,R10
clr R3
cp R20,R2
cpc R21,R3
brlt L6
.dbline -2
.dbline 42
; EEPROMwrite(add++,value_table[off++]);
; }
L5:
rcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r i 20 I
.dbsym r add 22 i
.dbsym r len 10 c
.dbsym r off 12 c
.dbend
.dbfunc e changK1 _changK1 fi
.even
_changK1::
rcall push_gset1
sbiw R28,4
.dbline -1
.dbline 44
; unsigned int changK1(void)
; {
.dbline 45
; if(K1>6.5) K1=6.5;
ldi R16,<L13
ldi R17,>L13
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_K1+2
lds R5,_K1+2+1
lds R2,_K1
lds R3,_K1+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
rcall cmp32f
brge L11
.dbline 45
ldi R16,<L14
ldi R17,>L14
rcall lpm32
sts _K1+1,R17
sts _K1,R16
sts _K1+2+1,R19
sts _K1+2,R18
L11:
.dbline 46
; return K1*10000;
ldi R16,<L17
ldi R17,>L17
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_K1+2
lds R5,_K1+2+1
lds R2,_K1
lds R3,_K1+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
rcall mpy32f
mov R30,R28
mov R31,R29
std z+0,R16
std z+1,R17
std z+2,R18
std z+3,R19
mov R30,R28
mov R31,R29
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L18
ldi R17,>L18
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall cmp32f
brlt L15
mov R30,R28
mov R31,R29
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L18
ldi R17,>L18
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall sub32f
rcall fp2int
mov R20,R16
mov R21,R17
subi R20,0 ; offset = 32768
sbci R21,128
rjmp L16
L15:
mov R30,R28
mov R31,R29
ldd R16,z+0
ldd R17,z+1
ldd R18,z+2
ldd R19,z+3
rcall fp2int
mov R20,R16
mov R21,R17
L16:
mov R16,R20
mov R17,R21
.dbline -2
L10:
adiw R28,4
rcall pop_gset1
.dbline 0 ; func end
ret
.dbend
.dbfunc e mode_choice _mode_choice fV
; flag -> R20
; key_temp -> R10
.even
_mode_choice::
rcall push_gset4
sbiw R28,6
.dbline -1
.dbline 49
; }
; void mode_choice(void)
; {
.dbline 50
; unsigned char flag=1;
ldi R20,1
.dbline 53
; unsigned char key_temp;
;
; LCD_init();
rcall _LCD_init
.dbline 54
; K1=EEPROMread(0x00)+EEPROMread(0x01)*0.1+EEPROMread(0x02)*0.01+EEPROMread(0x03)*0.001+EEPROMread(0x04)*0.0001;
clr R16
clr R17
rcall _EEPROMread
mov R2,R16
ldi R16,1
ldi R17,0
push R2
rcall _EEPROMread
pop R2
mov R4,R16
ldi R16,2
ldi R17,0
push R4
push R2
rcall _EEPROMread
pop R2
pop R4
mov R6,R16
ldi R16,3
ldi R17,0
push R6
push R4
push R2
rcall _EEPROMread
pop R2
pop R4
pop R6
mov R8,R16
ldi R16,4
ldi R17,0
push R8
push R6
push R4
push R2
rcall _EEPROMread
pop R2
pop R4
pop R6
pop R8
mov R24,R16
mov R16,R2
clr R17
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
ldi R16,<L20
ldi R17,>L20
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
mov R16,R4
clr R17
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall mpy32fs
rcall add32fs
ldi R16,<L21
ldi R17,>L21
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
mov R16,R6
clr R17
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall mpy32fs
rcall add32fs
ldi R16,<L22
ldi R17,>L22
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
mov R16,R8
clr R17
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall mpy32fs
rcall add32fs
ldi R16,<L23
ldi R17,>L23
rcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
mov R16,R24
clr R17
rcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
rcall mpy32fs
rcall add32f
sts _K1+1,R17
sts _K1,R16
sts _K1+2+1,R19
sts _K1+2,R18
.dbline 55
; Time1=EEPROMread(0x05)*1000+EEPROMread(0x06)*100+EEPROMread(0x07)*10+EEPROMread(0x08);
ldi R16,5
ldi R17,0
rcall _EEPROMread
mov R2,R16
ldi R16,6
ldi R17,0
push R2
rcall _EEPROMread
pop R2
mov R4,R16
ldi R16,7
ldi R17,0
push R4
push R2
rcall _EEPROMread
pop R2
pop R4
mov R6,R16
ldi R16,8
ldi R17,0
push R6
push R4
push R2
rcall _EEPROMread
pop R2
pop R4
pop R6
mov R8,R16
mov R18,R4
clr R19
ldi R16,100
ldi R17,0
rcall mpy16s
mov R4,R16
mov R5,R17
mov R18,R2
clr R19
ldi R16,1000
ldi R17,3
rcall mpy16s
mov R2,R16
mov R3,R17
add R2,R4
adc R3,R5
mov R18,R6
clr R19
ldi R16,10
ldi R17,0
rcall mpy16s
add R2,R16
adc R3,R17
clr R9
add R2,R8
adc R3,R9
sts _Time1+1,R3
sts _Time1,R2
.dbline 56
; if(Time1<MIN_T) Time1=MIN_T;
mov R24,R2
mov R25,R3
cpi R24,50
ldi R30,0
cpc R25,R30
brsh L24
.dbline 56
ldi R24,50
ldi R25,0
sts _Time1+1,R25
sts _Time1,R24
L24:
L26:
.dbline 58
; mode_again:
; LCD_clr();
rcall _LCD_clr
.dbline 59
; LCD_write_string(0,0,"K= ,T= ");
ldi R24,<L27
ldi R25,>L27
std y+1,R25
std y+0,R24
clr R18
clr R16
rcall _LCD_write_string
.dbline 60
; LCD_display(2,0,5,changK1());
rcall _changK1
mov R2,R16
mov R3,R17
clr R4
clr R5
std y+2,R2
std y+3,R3
std y+4,R4
std y+5,R5
ldi R24,5
std y+0,R24
clr R18
ldi R16,2
rcall _LCD_display
.dbline 61
; LCD_display(10,0,4,Time1);
lds R2,_Time1
lds R3,_Time1+1
clr R4
clr R5
std y+2,R2
std y+3,R3
std y+4,R4
std y+5,R5
ldi R24,4
std y+0,R24
clr R18
ldi R16,10
rcall _LCD_display
.dbline 62
; LCD_write_string(0,1,"Fn:Mod C:Def");
ldi R24,<L28
ldi R25,>L28
std y+1,R25
std y+0,R24
ldi R18,1
clr R16
rcall _LCD_write_string
rjmp L30
L29:
.dbline 64
; while(flag)
; {
.dbline 65
; key_temp=keypad();
rcall _keypad
mov R10,R16
.dbline 66
; if(key_temp==KEY_OK)
cpi R16,5
brne L32
.dbline 67
; {
.dbline 68
; Time1=0-Time1;
lds R2,_Time1
lds R3,_Time1+1
clr R4
clr R5
sub R4,R2
sbc R5,R3
sts _Time1+1,R5
sts _Time1,R4
.dbline 69
; TCNT1H=Time1>>8;
mov R2,R4
mov R3,R5
mov R2,R3
clr R3
out 0x2d,R2
.dbline 70
; TCNT1L=Time1&0xff;
mov R24,R4
mov R25,R5
andi R25,0
out 0x2c,R24
.dbline 71
; break;
rjmp L31
L32:
.dbline 73
; }
; if(key_temp==KEY_CU)
mov R24,R10
cpi R24,2
brne L34
.dbline 74
; {
.dbline 75
; K1=DEFAULT_K1;
ldi R16,<L36
ldi R17,>L36
rcall lpm32
sts _K1+1,R17
sts _K1,R16
sts _K1+2+1,R19
sts _K1+2,R18
.dbline 76
; data_init(changK1());
rcall _changK1
rcall _data_init
.dbline 77
; SaveToEEPROM(0,5,0);
clr R2
clr R3
std y+1,R3
std y+0,R2
ldi R18,5
clr R16
rcall _SaveToEEPROM
.dbline 78
; Time1=DEFAULT_T;
ldi R24,100
ldi R25,0
sts _Time1+1,R25
sts _Time1,R24
.dbline 79
; data_init(Time1);
mov R16,R24
mov R17,R25
rcall _data_init
.dbline 80
; SaveToEEPROM(1,4,5);
ldi R24,5
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,4
ldi R16,1
rcall _SaveToEEPROM
.dbline 81
; goto mode_again;
rjmp L26
L34:
.dbline 83
; }
; if(key_temp==KEY_FN)
mov R24,R10
cpi R24,1
breq X3
rjmp L37
X3:
.dbline 84
; {
.dbline 85
; LCD_clr();
rcall _LCD_clr
.dbline 86
; LCD_display(0,0,5,changK1());
rcall _changK1
mov R2,R16
mov R3,R17
clr R4
clr R5
std y+2,R2
std y+3,R3
std y+4,R4
std y+5,R5
ldi R24,5
std y+0,R24
clr R18
clr R16
rcall _LCD_display
.dbline 87
; LCD_write_string(6,0,"-10e4");
ldi R24,<L39
ldi R25,>L39
std y+1,R25
std y+0,R24
clr R18
ldi R16,6
rcall _LCD_write_string
.dbline 88
; LCD_write_string(0,1,"^ Set K");
ldi R24,<L40
ldi R25,>L40
std y+1,R25
std y+0,R24
ldi R18,1
clr R16
rcall _LCD_write_string
.dbline 89
; j=0;
clr R2
sts _j,R2
.dbline 90
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -