📄 ac20-1.s
字号:
movw R30,R16
ldi R24,<_seg
ldi R25,>_seg
add R30,R24
adc R31,R25
lpm R30,Z
out 0x1b,R30
.dbline 195
ldi R30,<_act+2
ldi R31,>_act+2
lpm R30,Z
out 0x18,R30
.dbline 195
.dbline 196
; default:break;
L31:
.dbline 198
; }
; TCNT0=0xd9;
ldi R24,217
out 0x32,R24
.dbline 199
; switch (status)
lds R20,_status
clr R21
cpi R20,80
ldi R30,0
cpc R21,R30
brne X5
xjmp L56
X5:
ldi R24,80
ldi R25,0
cp R24,R20
cpc R25,R21
brlt L81
L80:
cpi R20,50
ldi R30,0
cpc R21,R30
brne X6
xjmp L47
X6:
ldi R24,50
ldi R25,0
cp R24,R20
cpc R25,R21
brlt L83
L82:
cpi R20,0
cpc R20,R21
brne X7
xjmp L41
X7:
X2:
cpi R20,0
ldi R30,0
cpc R21,R30
brge X8
xjmp L39
X8:
L84:
cpi R20,20
ldi R30,0
cpc R21,R30
brne X9
xjmp L44
X9:
xjmp L39
L83:
cpi R20,60
ldi R30,0
cpc R21,R30
brne X10
xjmp L50
X10:
cpi R20,60
ldi R30,0
cpc R21,R30
brge X11
xjmp L39
X11:
L85:
cpi R20,70
ldi R30,0
cpc R21,R30
brne X12
xjmp L53
X12:
xjmp L39
L81:
cpi R20,110
ldi R30,0
cpc R21,R30
brne X13
xjmp L69
X13:
ldi R24,110
ldi R25,0
cp R24,R20
cpc R25,R21
brlt L87
L86:
cpi R20,85
ldi R30,0
cpc R21,R30
brne X14
xjmp L61
X14:
cpi R20,85
ldi R30,0
cpc R21,R30
brge X15
xjmp L39
X15:
L88:
cpi R20,100
ldi R30,0
cpc R21,R30
brne X16
xjmp L66
X16:
xjmp L39
L87:
cpi R20,120
ldi R30,0
cpc R21,R30
brne X17
xjmp L72
X17:
cpi R20,120
ldi R30,0
cpc R21,R30
brge X18
xjmp L39
X18:
L89:
cpi R20,130
ldi R30,0
cpc R21,R30
brne X19
xjmp L75
X19:
xjmp L39
X3:
.dbline 200
; { //门全开后转状态10
L41:
.dbline 201
; case 0:if(round_cnt>200){status=10;}break;
ldi R24,200
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X20
xjmp L39
X20:
.dbline 201
.dbline 201
ldi R24,10
sts _status,R24
.dbline 201
.dbline 201
xjmp L39
L44:
.dbline 203
; //门全关后转状态30停止
; case 20:if(round_cnt>200){status=30;}break;
ldi R24,200
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X21
xjmp L39
X21:
.dbline 203
.dbline 203
ldi R24,30
sts _status,R24
.dbline 203
.dbline 203
xjmp L39
L47:
.dbline 204
; case 50:if(round_cnt>100){/*reset;*/}break;
ldi R24,100
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X22
xjmp L39
X22:
.dbline 204
.dbline 204
.dbline 204
xjmp L39
L50:
.dbline 205
; case 60:if(round_cnt>100){/*reset*/}break;
ldi R24,100
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X23
xjmp L39
X23:
.dbline 205
.dbline 205
.dbline 205
xjmp L39
L53:
.dbline 206
; case 70:if(round_cnt>100){/*reset*/}break;
ldi R24,100
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X24
xjmp L39
X24:
.dbline 206
.dbline 206
.dbline 206
xjmp L39
L56:
.dbline 208
; //开门慢速状态80时,间隔500ms,分二次判断撞墙后,转状态90
; case 80:{if((fst==0)&&(round_cnt>150))fst=1;
.dbline 208
lds R2,_fst
tst R2
brne L57
ldi R24,150
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brsh L57
.dbline 208
ldi R24,1
sts _fst,R24
L57:
.dbline 209
; if((fst==2)&&(round_cnt>150))status=90;
lds R24,_fst
cpi R24,2
breq X25
xjmp L39
X25:
ldi R24,150
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X26
xjmp L39
X26:
.dbline 209
ldi R24,90
sts _status,R24
.dbline 210
; }break;
.dbline 210
xjmp L39
L61:
.dbline 212
; //开门慢速状态85时,间隔500ms,分二次判断撞墙后,转状态90
; case 85:{if((fst==0)&&(round_cnt>200))fst=1;
.dbline 212
lds R2,_fst
tst R2
brne L62
ldi R24,200
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brsh L62
.dbline 212
ldi R24,1
sts _fst,R24
L62:
.dbline 213
; if((fst==2)&&(round_cnt>200))status=90;
lds R24,_fst
cpi R24,2
breq X27
xjmp L39
X27:
ldi R24,200
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X28
xjmp L39
X28:
.dbline 213
ldi R24,90
sts _status,R24
.dbline 214
; }break;
.dbline 214
xjmp L39
L66:
.dbline 216
; //关门加速状态100时, 判断撞人后,转状态105
; case 100:if(round_cnt>300){status=105;sp_pl=0;}break;
ldi R24,300
ldi R25,1
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brlo X29
xjmp L39
X29:
.dbline 216
.dbline 216
ldi R24,105
sts _status,R24
.dbline 216
clr R2
clr R3
sts _sp_pl+1,R3
sts _sp_pl,R2
.dbline 216
.dbline 216
xjmp L39
L69:
.dbline 218
; //关门全速状态110时, 判断撞人后,转状态116
; case 110:if(round_cnt>30){status=116;sp_pl=0;}break;
ldi R24,30
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brsh L39
.dbline 218
.dbline 218
ldi R24,116
sts _status,R24
.dbline 218
clr R2
clr R3
sts _sp_pl+1,R3
sts _sp_pl,R2
.dbline 218
.dbline 218
xjmp L39
L72:
.dbline 219
; case 120:if(round_cnt>100){status=116;sp_pl=0;}break;
ldi R24,100
ldi R25,0
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brsh L39
.dbline 219
.dbline 219
ldi R24,116
sts _status,R24
.dbline 219
clr R2
clr R3
sts _sp_pl+1,R3
sts _sp_pl,R2
.dbline 219
.dbline 219
xjmp L39
L75:
.dbline 221
ldi R24,8
ldi R25,0
lds R2,_changdu
lds R3,_changdu+1
cp R24,R2
cpc R25,R3
brlt L39
.dbline 221
.dbline 221
ldi R24,200
lds R2,_round_cnt
lds R3,_round_cnt+1
cp R24,R2
cpc R25,R3
brsh L39
.dbline 221
ldi R24,140
sts _status,R24
.dbline 221
.dbline 222
.dbline 223
L39:
.dbline -2
L23:
xcall pop_gset1
ld R2,y+
out 0x3f,R2
ld R31,y+
ld R30,y+
ld R25,y+
ld R24,y+
ld R19,y+
ld R18,y+
ld R17,y+
ld R16,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 4
jmp _ext_int0
.area text(rom, con, rel)
.dbfile d:\MYDOCU~1\ac20-1\ac20-1.c
.dbfunc e ext_int0 _ext_int0 fV
.even
_ext_int0::
st -y,R2
st -y,R3
st -y,R4
st -y,R5
st -y,R24
st -y,R25
in R2,0x3f
st -y,R2
.dbline -1
.dbline 231
; //关门慢速状态130时,门合拢后转状态140停止
; case 130:if(changdu<=8){if(round_cnt>200)status=140;}
; break;
; default:break;
; }
; }
;
;
; /*======INT0的马达光电编码器中断=========*/
; #pragma interrupt_handler ext_int0:2
; void ext_int0(void)
; {SREG|=0x80;
.dbline 231
bset 7
.dbline 232
; round_cnt=0;
clr R2
clr R3
sts _round_cnt+1,R3
sts _round_cnt,R2
.dbline 233
; if(status<90)changdu++;
lds R24,_status
cpi R24,90
brsh L91
.dbline 233
lds R24,_changdu
lds R25,_changdu+1
adiw R24,1
sts _changdu+1,R25
sts _changdu,R24
L91:
.dbline 234
; if(changdu>9999)changdu=9999;
ldi R24,9999
ldi R25,39
lds R2,_changdu
lds R3,_changdu+1
cp R24,R2
cpc R25,R3
brge L93
.dbline 234
sts _changdu+1,R25
sts _changdu,R24
L93:
.dbline 235
; if((status>90)&&(status<140))changdu--;
ldi R24,90
lds R2,_status
cp R24,R2
brsh L95
mov R24,R2
cpi R24,140
brsh L95
.dbline 235
lds R24,_changdu
lds R25,_changdu+1
sbiw R24,1
sts _changdu+1,R25
sts _changdu,R24
L95:
.dbline 236
; if(changdu<=0){changdu=0;}
clr R2
clr R3
lds R4,_changdu
lds R5,_changdu+1
cp R2,R4
cpc R3,R5
brlt L97
.dbline 236
.dbline 236
sts _changdu+1,R3
sts _changdu,R2
.dbline 236
L97:
.dbline 237
; if(inc_dec_flag)sp_pl++;
lds R2,_inc_dec_flag
tst R2
breq L99
.dbline 237
lds R24,_sp_pl
lds R25,_sp_pl+1
adiw R24,1
sts _sp_pl+1,R25
sts _sp_pl,R24
L99:
.dbline 238
ldi R24,9999
ldi R25,39
lds R2,_sp_pl
lds R3,_sp_pl+1
cp R24,R2
cpc R25,R3
brsh L101
.dbline 238
sts _sp_pl+1,R25
sts _sp_pl,R24
L101:
.dbline -2
L90:
ld R2,y+
out 0x3f,R2
ld R25,y+
ld R24,y+
ld R5,y+
ld R4,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e open_inc_speed _open_inc_speed fV
; sp_pl -> R16,R17
.even
_open_inc_speed::
.dbline -1
.dbline 244
; if(sp_pl>9999)sp_pl=9999;
; }
;
;
; /*==========开门时的加速子函数===========*/
; void open_inc_speed(uint sp_pl)
; {
.dbline 245
; switch (sp_pl)
cpi R16,50
ldi R30,0
cpc R17,R30
brne X31
xjmp L119
X31:
ldi R24,50
ldi R25,0
cp R24,R16
cpc R25,R17
brge X32
xjmp L138
X32:
L137:
cpi R16,20
ldi R30,0
cpc R17,R30
brne X33
xjmp L111
X33:
ldi R24,20
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L140
L139:
cpi R16,5
ldi R30,0
cpc R17,R30
brne X34
xjmp L107
X34:
ldi R24,5
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L142
L141:
cpi R16,1
ldi R30,0
cpc R17,R30
brne X35
xjmp L106
X35:
xjmp L105
L142:
cpi R16,10
ldi R30,0
cpc R17,R30
brne X36
xjmp L109
X36:
xjmp L105
L140:
cpi R16,35
ldi R30,0
cpc R17,R30
brne X37
xjmp L115
X37:
ldi R24,35
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L144
L143:
cpi R16,25
ldi R30,0
cpc R17,R30
brne X38
xjmp L113
X38:
xjmp L105
L144:
cpi R16,45
ldi R30,0
cpc R17,R30
brne X39
xjmp L117
X39:
xjmp L105
L138:
cpi R16,85
ldi R30,0
cpc R17,R30
brne X40
xjmp L127
X40:
ldi R24,85
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L146
L145:
cpi R16,65
ldi R30,0
cpc R17,R30
brne X41
xjmp L123
X41:
ldi R24,65
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L148
L147:
cpi R16,60
ldi R30,0
cpc R17,R30
brne X42
xjmp L121
X42:
xjmp L105
L148:
cpi R16,75
ldi R30,0
cpc R17,R30
brne X43
xjmp L125
X43:
xjmp L105
L146:
cpi R16,100
ldi R30,0
cpc R17,R30
brne X44
xjmp L131
X44:
ldi R24,100
ldi R25,0
cp R24,R16
cpc R25,R17
brlt L150
L149:
cpi R16,90
ldi R30,0
cpc R17,R30
brne X45
xjmp L129
X45:
xjmp L105
L150:
cpi R16,105
ldi R30,0
cpc R17,R30
brne X46
xjmp L133
X46:
cpi R16,105
ldi R30,0
cpc R17,R30
brge X47
xjmp L105
X47:
L151:
cpi R16,115
ldi R30,0
cpc R17,R30
brne X48
xjmp L135
X48:
xjmp L105
X30:
.dbline 246
; {
L106:
.dbline 247
; case 1:wide=open_inc_tab[0];break;
lds R2,_open_inc_tab
sts _wide,R2
.dbline 247
xjmp L105
L107:
.dbline 248
; case 5:wide=open_inc_tab[1];break;
lds R2,_open_inc_tab+1
sts _wide,R2
.dbline 248
xjmp L105
L109:
.dbline 249
; case 10:wide=open_inc_tab[2];break;
lds R2,_open_inc_tab+2
sts _wide,R2
.dbline 249
xjmp L105
L111:
.dbline 250
; case 20:wide=open_inc_tab[3];break;
lds R2,_open_inc_tab+3
sts _wide,R2
.dbline 250
xjmp L105
L113:
.dbline 251
; case 25:wide=open_inc_tab[4];break;
lds R2,_open_inc_tab+4
sts _wide,R2
.dbline 251
xjmp L105
L115:
.dbline 252
; case 35:wide=open_inc_tab[5];break;
lds R2,_open_inc_tab+5
sts _wide,R2
.dbline 252
xjmp L105
L117:
.dbline 253
; case 45:wide=open_inc_tab[6];break;
lds R2,_open_inc_tab+6
sts _wide,R2
.dbline 253
xjmp L105
L119:
.dbline 254
; case 50:wide=open_inc_tab[7];break;
lds R2,_open_inc_tab+7
sts _wide,R2
.dbline 254
xjmp L105
L121:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -