📄 ac20-1.s
字号:
.module ac20-1.c
.area lit(rom, con, rel)
_seg::
.byte 63,6
.byte 91,'O
.byte 'f,'m
.byte 125,7
.byte 127,'o
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e seg _seg A[10:10]kc
_act::
.byte 223,191
.byte 127,239
.dbsym e act _act A[4:4]kc
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
_stoptime::
.blkb 1
.area idata
.byte 3
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e stoptime _stoptime c
_study_speed_temp::
.blkb 1
.area idata
.byte 4
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e study_speed_temp _study_speed_temp c
_open_max_temp::
.blkb 1
.area idata
.byte 4
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e open_max_temp _open_max_temp c
_open_min_temp::
.blkb 1
.area idata
.byte 4
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e open_min_temp _open_min_temp c
_close_max_temp::
.blkb 1
.area idata
.byte 1
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e close_max_temp _close_max_temp c
_close_min_temp::
.blkb 1
.area idata
.byte 4
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e close_min_temp _close_min_temp c
.area lit(rom, con, rel)
_stoptime_tab::
.word 500
.word 1000
.word 2000
.word 3000
.word 4000
.word 5000
.word 6000
.word 7000
.word 8000
.word 9000
.dbsym e stoptime_tab _stoptime_tab A[20:10]ki
_round_cnt_tab::
.byte 5,6
.byte 7,8
.byte 9,10
.byte 15,20
.byte 25,30
.dbsym e round_cnt_tab _round_cnt_tab A[10:10]kc
_study_speed_tab::
.byte 5,7
.byte 9,11
.byte 13,15
.byte 20,25
.byte 30,35
.dbsym e study_speed_tab _study_speed_tab A[10:10]kc
_open_max_tab::
.byte 'd,'x
.byte 140,150
.byte 155,160
.byte 165,170
.byte 175,180
.dbsym e open_max_tab _open_max_tab A[10:10]kc
_open_min_tab::
.byte 5,7
.byte 8,9
.byte 10,15
.byte 20,25
.byte 30,35
.dbsym e open_min_tab _open_min_tab A[10:10]kc
_close_max_tab::
.byte 'd,'x
.byte 140,150
.byte 155,160
.byte 165,170
.byte 175,180
.dbsym e close_max_tab _close_max_tab A[10:10]kc
_close_min_tab::
.byte 5,7
.byte 8,9
.byte 10,15
.byte 20,25
.byte 30,35
.dbsym e close_min_tab _close_min_tab A[10:10]kc
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
_FX::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e FX _FX c
_ddata::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e ddata _ddata c
_wide::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbsym e wide _wide c
.area text(rom, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbfunc e delay _delay fV
; i -> R20,R21
; j -> R22,R23
; k -> R16,R17
.even
_delay::
xcall push_gset2
.dbline -1
.dbline 113
; #include<iom16v.h> //文件包含
; #include<eeprom.h>
; #define uchar unsigned char //变量类型的宏定义
; #define uint unsigned int
;
; uchar const seg[10]={0x3f,0x06,0x5b,0x4f,0x66, //数码管段码设定
; 0x6d,0x7d,0x07,0x7f,0x6f};
; uchar const act[4]={0xdf,0xbf,0x7f,0xef}; //数码管位码设定
;
; /***********************输入量设定*************************/
; uchar stoptime=3; //靠墙停顿时间设定
; uchar study_speed; //学习时的速度设定
; uchar study_speed_temp=4;
;
; uchar open_max,open_min; //开门最大速度、最小速度设定
; uchar open_max_temp=4,open_min_temp=4;
;
; uchar close_max,close_min; //关门最大速度、最小速度设定
; uchar close_max_temp=1,close_min_temp=4;
;
; /*****************输入量的列表****************/
; uint const stoptime_tab[10]={500,1000,2000,3000,4000,5000,
; 6000,7000,8000,9000};
; uchar const round_cnt_tab[10]={5,6,7,8,9,10,15,20,25,30};
; uchar const study_speed_tab[10]={5,7,9,11,13,15,
; 20,25,30,35};
; uchar const open_max_tab[10]={100,120,140,150,155,
; 160,165,170,175,180};
; uchar const open_min_tab[10]={5,7,8,9,10,
; 15,20,25,30,35};
; uchar const close_max_tab[10]={100,120,140,150,155,
; 160,165,170,175,180};
; uchar const close_min_tab[10]={5,7,8,9,10,
; 15,20,25,30,35};
;
; uint round_cnt; //直流电机旋转的圈数
; int changdu; //实际门扇移动的长度
; uint st_changdu; //设定门扇移动的长度
; uint allchangdu_x; //总长度(中间变量)
; uint allchangdu; //总长度
; uint sp_pl; //脉冲计数变量
; uchar set_status; //设定状态
; uchar status; //工作状态
;
; /***********临时变量***********/
; uint cnt_500;
; uchar fst,val;
; uchar temp;
; uchar x;uchar FX=0;
; uchar eep_temp;
;
; uchar open_inc_tab[16]; //开门加速函数的计算表
; uchar open_dec_tab[16]; //开门减速函数的计算表
; uchar close_inc_tab[16]; //关门加速函数的计算表
; uchar close_dec_tab[16]; //关门减速函数的计算表
;
; uchar openflag;
; uchar dis_bit,ddata=0;
; /***********************************************/
; uchar inc_dec_flag; //加减速的标志
; uchar wide=0; //加减速的脉冲宽度变量
;
; /****************常量定义***************/
; #define L 1;
; #define R 0;
; #define ON 0;
; #define OFF 1;
; #define ALL 1
; #define HALF 0
;
; /**************端口高低电平定义****************/
; #define PWMOUT_0 (PORTD=PORTD|0x80) //PWM端输出0
; #define PWMOUT_1 (PORTD=PORTD&0x7f) //PWM端输出1
; #define SACE_0 (PORTD=PORTD|0x40) //SACE端输出0
; #define SACE_1 (PORTD=PORTD&0xbf) //SACE端输出1
; #define FANXIANG_L (PORTD=PORTD|0x20) //方向向左
; #define FANXIANG_R (PORTD=PORTD&0xdf) //方向向右
; #define RELAY_ON (PORTD=PORTD&0xf7) //继电器吸合
; #define RELAY_OFF (PORTD=PORTD|0x08) //继电器断开
; #define LOCK_ON (PORTD=PORTD&0xef) //锁停门扇打开
; #define LOCK_OFF (PORTD=PORTD|0x10) //锁停门扇关闭
;
; #define CON_SMAIL (PORTC&0x01) //门扇打开微小的距离运行
; #define TANTE1 (PINC&0x40) //门外侧的红外感应探测器1
; #define TANTE2 (PINC&0x02) //门内侧的红外感应探测器2
; #define KEY_SET (PINB&0x01) //按键输入SET
; #define KEY_ADD (PINB&0x02) //按键输入ADD
; #define KEY_OK (PINB&0x04) //按键输入OK
; #define OFF_ALLTANTE (PINB&0x08) //关闭全部的红外感应探测器
; #define OFF_TANTE1 (PINB&0x10) //关闭门外侧的红外感应探测器1
; #define HALF_RUN (PIND&0x01) //门扇半开运行
; #define ALLOPEN_STOP (PIND&0x02) //门扇全开后锁停
; #define STOP (PINC&0x10) //门扇锁停
;
; /****************EEPROM内部地址定义*********************/
; #define stoptime_address 10
; #define study_speed_address 15
; #define open_max_address 20
; #define open_min_address 25
; #define close_max_address 30
; #define close_min_address 35
;
; /***********************************************************/
; uchar openstop; //门全开后停止不动的标志
; uchar tante_flag; //门外侧的红外感应探测器1允许使用的标志
;
; /******************函数声明***********************/
; void start(void);
; //void fai_zhan(void);
;
; /****************延时子函数*******************/
; void delay(uint k)
; {
.dbline 115
clr R20
clr R21
xjmp L5
L2:
.dbline 115
; uint i,j;
; for(i=0;i<k;i++){
.dbline 116
; for(j=0;j<1500;j++)
clr R22
clr R23
xjmp L9
L6:
.dbline 117
.dbline 117
.dbline 117
L7:
.dbline 116
subi R22,255 ; offset = 1
sbci R23,255
L9:
.dbline 116
cpi R22,220
ldi R30,5
cpc R23,R30
brlo L6
.dbline 117
L3:
.dbline 115
subi R20,255 ; offset = 1
sbci R21,255
L5:
.dbline 115
cp R20,R16
cpc R21,R17
brlo L2
.dbline -2
L1:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r j 22 i
.dbsym r k 16 i
.dbend
.dbfunc e init_IO _init_IO fV
.even
_init_IO::
sbiw R28,2
.dbline -1
.dbline 122
; {;}}
; }
;
; /*==========初始化单片机I/O口子函数==========*/
; void init_IO(void)
; {DDRA=0x7f;
.dbline 122
ldi R24,127
out 0x1a,R24
.dbline 123
; PORTA=0x00;
clr R2
out 0x1b,R2
.dbline 124
; DDRB=0xe0;
ldi R24,224
out 0x17,R24
.dbline 125
; PORTB=0xff;
ldi R24,255
out 0x18,R24
.dbline 126
; DDRC=0x01;
ldi R24,1
out 0x14,R24
.dbline 127
; PORTC=0xff;
ldi R24,255
out 0x15,R24
.dbline 128
; DDRD=0xf8;
ldi R24,248
out 0x11,R24
.dbline 129
; PORTD=0xff;
ldi R24,255
out 0x12,R24
.dbline 131
; //-----------------------------
; PWMOUT_0;
sbi 0x12,7
.dbline 132
; SACE_0;
sbi 0x12,6
.dbline 133
; TCCR0=0x04;
ldi R24,4
out 0x33,R24
.dbline 134
; TCNT0=0xd9;
ldi R24,217
out 0x32,R24
.dbline 135
; GICR=0x40;/*c0;*/
ldi R24,64
out 0x3b,R24
.dbline 136
; MCUCR=0x02;/*0a;*/
ldi R24,2
out 0x35,R24
.dbline 137
; TIMSK=0x01;
ldi R24,1
out 0x39,R24
.dbline 138
; TCCR2=0x71;
ldi R24,113
out 0x25,R24
.dbline 139
; FANXIANG_R;
in R24,0x12
andi R24,223
out 0x12,R24
.dbline 140
; round_cnt=0;
clr R3
sts _round_cnt+1,R3
sts _round_cnt,R2
.dbline 141
; changdu=0;
sts _changdu+1,R3
sts _changdu,R2
.dbline 142
; sp_pl=0;
sts _sp_pl+1,R3
sts _sp_pl,R2
.dbline 143
; allchangdu=0;
sts _allchangdu+1,R3
sts _allchangdu,R2
.dbline 144
; changdu=0;
sts _changdu+1,R3
sts _changdu,R2
.dbline 145
; st_changdu=0;
sts _st_changdu+1,R3
sts _st_changdu,R2
.dbline 146
; status=0;
sts _status,R2
.dbline 147
; inc_dec_flag=0;
sts _inc_dec_flag,R2
.dbline 149
; //***********************************
; eep_temp=0;
sts _eep_temp,R2
.dbline 150
; EEPROM_READ(stoptime_address+1,eep_temp);
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_eep_temp
ldi R19,>_eep_temp
ldi R16,11
ldi R17,0
xcall _EEPROMReadBytes
.dbline 151
; if(eep_temp==55)
lds R24,_eep_temp
cpi R24,55
brne L11
.dbline 152
; {EEPROM_READ(stoptime_address,stoptime);}
.dbline 152
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_stoptime
ldi R19,>_stoptime
ldi R16,10
ldi R17,0
xcall _EEPROMReadBytes
.dbline 152
L11:
.dbline 154
; //************************************
; eep_temp=0;
clr R2
sts _eep_temp,R2
.dbline 155
; EEPROM_READ(open_max_address+1,eep_temp);
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_eep_temp
ldi R19,>_eep_temp
ldi R16,21
ldi R17,0
xcall _EEPROMReadBytes
.dbline 156
; if(eep_temp==55)
lds R24,_eep_temp
cpi R24,55
brne L13
.dbline 157
; {EEPROM_READ(open_max_address,open_max_temp);}
.dbline 157
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_open_max_temp
ldi R19,>_open_max_temp
ldi R16,20
ldi R17,0
xcall _EEPROMReadBytes
.dbline 157
L13:
.dbline 159
; //*************************************
; eep_temp=0;
clr R2
sts _eep_temp,R2
.dbline 160
; EEPROM_READ(open_min_address+1,eep_temp);
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_eep_temp
ldi R19,>_eep_temp
ldi R16,26
ldi R17,0
xcall _EEPROMReadBytes
.dbline 161
; if(eep_temp==55)
lds R24,_eep_temp
cpi R24,55
brne L15
.dbline 162
; {EEPROM_READ(open_min_address,open_min_temp);}
.dbline 162
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_open_min_temp
ldi R19,>_open_min_temp
ldi R16,25
ldi R17,0
xcall _EEPROMReadBytes
.dbline 162
L15:
.dbline 164
; //*************************************
; eep_temp=0;
clr R2
sts _eep_temp,R2
.dbline 165
; EEPROM_READ(close_max_address+1,eep_temp);
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_eep_temp
ldi R19,>_eep_temp
ldi R16,31
ldi R17,0
xcall _EEPROMReadBytes
.dbline 166
; if(eep_temp==55)
lds R24,_eep_temp
cpi R24,55
brne L17
.dbline 167
; {EEPROM_READ(close_max_address,open_max_temp);}
.dbline 167
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_open_max_temp
ldi R19,>_open_max_temp
ldi R16,30
ldi R17,0
xcall _EEPROMReadBytes
.dbline 167
L17:
.dbline 169
; //*************************************
; eep_temp=0;
clr R2
sts _eep_temp,R2
.dbline 170
; EEPROM_READ(close_min_address+1,eep_temp);
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_eep_temp
ldi R19,>_eep_temp
ldi R16,36
ldi R17,0
xcall _EEPROMReadBytes
.dbline 171
; if(eep_temp==55)
lds R24,_eep_temp
cpi R24,55
brne L19
.dbline 172
; {EEPROM_READ(close_min_address,open_min_temp);}
.dbline 172
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_open_min_temp
ldi R19,>_open_min_temp
ldi R16,35
ldi R17,0
xcall _EEPROMReadBytes
.dbline 172
L19:
.dbline 174
clr R2
sts _eep_temp,R2
.dbline 175
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_eep_temp
ldi R19,>_eep_temp
ldi R16,16
ldi R17,0
xcall _EEPROMReadBytes
.dbline 176
lds R24,_eep_temp
cpi R24,55
brne L21
.dbline 177
.dbline 177
ldi R24,1
ldi R25,0
std y+1,R25
std y+0,R24
ldi R18,<_study_speed_temp
ldi R19,>_study_speed_temp
ldi R16,15
ldi R17,0
xcall _EEPROMReadBytes
.dbline 177
L21:
.dbline -2
L10:
adiw R28,2
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 36
jmp _timer0
.area text(rom, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbfunc e timer0 _timer0 fV
.even
_timer0::
st -y,R2
st -y,R3
st -y,R16
st -y,R17
st -y,R18
st -y,R19
st -y,R24
st -y,R25
st -y,R30
st -y,R31
in R2,0x3f
st -y,R2
xcall push_gset1
.dbline -1
.dbline 184
; //*************************************
; eep_temp=0;
; EEPROM_READ(study_speed_address+1,eep_temp);
; if(eep_temp==55)
; {EEPROM_READ(study_speed_address,study_speed_temp);}
; }
;
; /*===================================================*/
; /***定时器T0的1ms中断,用于数码管显示及检测运行状态的马达堵转情况***/
; #pragma interrupt_handler timer0:10
; void timer0(void)
; {SREG|=0x80;
.dbline 184
bset 7
.dbline 185
; round_cnt++;
lds R24,_round_cnt
lds R25,_round_cnt+1
adiw R24,1
sts _round_cnt+1,R25
sts _round_cnt,R24
.dbline 186
; dis_bit++;
lds R24,_dis_bit
subi R24,255 ; addi 1
sts _dis_bit,R24
.dbline 187
; if(dis_bit>2)dis_bit=0;
ldi R24,2
lds R2,_dis_bit
cp R24,R2
brsh L24
.dbline 187
clr R2
sts _dis_bit,R2
L24:
.dbline 188
; if(fst==1)cnt_500++;
lds R24,_fst
cpi R24,1
brne L26
.dbline 188
lds R24,_cnt_500
lds R25,_cnt_500+1
adiw R24,1
sts _cnt_500+1,R25
sts _cnt_500,R24
L26:
.dbline 189
; if(cnt_500>500){fst=2;round_cnt=0;cnt_500=0;}
ldi R24,500
ldi R25,1
lds R2,_cnt_500
lds R3,_cnt_500+1
cp R24,R2
cpc R25,R3
brsh L28
.dbline 189
.dbline 189
ldi R24,2
sts _fst,R24
.dbline 189
clr R2
clr R3
sts _round_cnt+1,R3
sts _round_cnt,R2
.dbline 189
sts _cnt_500+1,R3
sts _cnt_500,R2
.dbline 189
L28:
.dbline 191
;
; switch(dis_bit)
lds R20,_dis_bit
clr R21
cpi R20,0
cpc R20,R21
breq L33
X0:
cpi R20,1
ldi R30,0
cpc R21,R30
breq L34
cpi R20,2
ldi R30,0
cpc R21,R30
brne X4
xjmp L36
X4:
xjmp L31
X1:
.dbline 192
; {
L33:
.dbline 193
; case 0:PORTA=seg[status%10];PORTB=act[0];break;
ldi R18,10
ldi R19,0
lds R16,_status
clr R17
xcall mod16s
movw R30,R16
ldi R24,<_seg
ldi R25,>_seg
add R30,R24
adc R31,R25
lpm R30,Z
out 0x1b,R30
.dbline 193
ldi R30,<_act
ldi R31,>_act
lpm R30,Z
out 0x18,R30
.dbline 193
xjmp L31
L34:
.dbline 194
; case 1:PORTA=seg[(status%100)/10];PORTB=act[1];break;
ldi R18,100
ldi R19,0
lds R16,_status
clr R17
xcall mod16s
ldi R18,10
ldi R19,0
xcall div16s
movw R30,R16
ldi R24,<_seg
ldi R25,>_seg
add R30,R24
adc R31,R25
lpm R30,Z
out 0x1b,R30
.dbline 194
ldi R30,<_act+1
ldi R31,>_act+1
lpm R30,Z
out 0x18,R30
.dbline 194
xjmp L31
L36:
.dbline 195
; case 2:PORTA=seg[status/100];PORTB=act[2];break;
ldi R18,100
ldi R19,0
lds R16,_status
clr R17
xcall div16s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -