📄 main.s
字号:
ror R16
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
movw R16,R10
andi R16,1
andi R17,0
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall add32fs
lds R4,_dw_speed+2
lds R5,_dw_speed+2+1
lds R2,_dw_speed
lds R3,_dw_speed+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32f
sts _P_speed+1,R17
sts _P_speed,R16
sts _P_speed+2+1,R19
sts _P_speed+2,R18
.dbline 308
;
; if (guogan==1)
lds R24,_guogan
cpi R24,1
breq X30
xjmp L196
X30:
.dbline 309
; {
.dbline 310
; ganwei=ganwei+P_speed*4000;
lds R4,_ganwei+2
lds R5,_ganwei+2+1
lds R2,_ganwei
lds R3,_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L198
ldi R17,>L198
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_P_speed+2
lds R5,_P_speed+2+1
lds R2,_P_speed
lds R3,_P_speed+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32fs
xcall add32f
sts _ganwei+1,R17
sts _ganwei,R16
sts _ganwei+2+1,R19
sts _ganwei+2,R18
.dbline 311
; if (next_gan==1)
lds R24,_next_gan
cpi R24,1
brne L199
.dbline 312
; {
.dbline 313
; next_ganwei=next_ganwei*4000;
ldi R16,<L198
ldi R17,>L198
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_next_ganwei+2
lds R5,_next_ganwei+2+1
lds R2,_next_ganwei
lds R3,_next_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32f
sts _next_ganwei+1,R17
sts _next_ganwei,R16
sts _next_ganwei+2+1,R19
sts _next_ganwei+2,R18
.dbline 314
; }
L199:
.dbline 315
; if (first_gan==1) //如果是第一次进行切刀,则启动步进电机,并调速至与皮带一致
lds R24,_first_gan
cpi R24,1
breq X31
xjmp L201
X31:
.dbline 316
; {
.dbline 317
; if (next_ganwei>-40)
ldi R16,<L205
ldi R17,>L205
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_next_ganwei+2
lds R5,_next_ganwei+2+1
lds R2,_next_ganwei
lds R3,_next_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brlt X32
xjmp L202
X32:
.dbline 318
; {
.dbline 319
; M_state=1;
ldi R24,1
sts _M_state,R24
.dbline 320
; juli=60;
ldi R16,<L206
ldi R17,>L206
xcall lpm32
sts _juli+1,R17
sts _juli,R16
sts _juli+2+1,R19
sts _juli+2,R18
.dbline 321
; first_gan=0;
clr R2
sts _first_gan,R2
.dbline 322
; ganwei=next_ganwei;
lds R4,_next_ganwei+2
lds R5,_next_ganwei+2+1
lds R2,_next_ganwei
lds R3,_next_ganwei+1
sts _ganwei+1,R3
sts _ganwei,R2
sts _ganwei+2+1,R5
sts _ganwei+2,R4
.dbline 323
; next_gan=0;
clr R2
sts _next_gan,R2
.dbline 324
; next_ganwei=-500;
ldi R16,<L207
ldi R17,>L207
xcall lpm32
sts _next_ganwei+1,R17
sts _next_ganwei,R16
sts _next_ganwei+2+1,R19
sts _next_ganwei+2,R18
.dbline 325
; }
.dbline 326
; }
xjmp L202
L201:
.dbline 328
; else
; {
.dbline 329
; if (!((M_state==6) || (M_state==7)) && (ganwei>(jidao*longth_guamian+20)) && (ganwei<(ganju-160)))
lds R24,_M_state
cpi R24,6
brne X33
xjmp L208
X33:
cpi R24,7
brne X34
xjmp L208
X34:
lds R16,_jidao
clr R17
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_longth_guamian+2
lds R5,_longth_guamian+2+1
lds R2,_longth_guamian
lds R3,_longth_guamian+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32fs
ldi R16,<L210
ldi R17,>L210
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall add32fs
lds R4,_ganwei+2
lds R5,_ganwei+2+1
lds R2,_ganwei
lds R3,_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brge L208
lds R4,_ganwei+2
lds R5,_ganwei+2+1
lds R2,_ganwei
lds R3,_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
lds R4,_ganju+2
lds R5,_ganju+2+1
lds R2,_ganju
lds R3,_ganju+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L211
ldi R17,>L211
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32fs
xcall cmp32f
brge L208
.dbline 330
; {
.dbline 331
; M_state=6;
ldi R24,6
sts _M_state,R24
.dbline 332
; }
L208:
.dbline 333
; if (!((M_state==0) || (M_state==2)) && (ganwei>(ganju-160)) && (next_ganwei<-40))
lds R2,_M_state
tst R2
brne X35
xjmp L212
X35:
mov R24,R2
cpi R24,2
breq L212
lds R4,_ganju+2
lds R5,_ganju+2+1
lds R2,_ganju
lds R3,_ganju+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L211
ldi R17,>L211
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32fs
lds R4,_ganwei+2
lds R5,_ganwei+2+1
lds R2,_ganwei
lds R3,_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brge L212
lds R4,_next_ganwei+2
lds R5,_next_ganwei+2+1
lds R2,_next_ganwei
lds R3,_next_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L205
ldi R17,>L205
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brge L212
.dbline 334
; {
.dbline 335
; M_state=2;
ldi R24,2
sts _M_state,R24
.dbline 336
; }
L212:
.dbline 337
; if ((next_ganwei>-40) && (M_state==0))
ldi R16,<L205
ldi R17,>L205
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_next_ganwei+2
lds R5,_next_ganwei+2+1
lds R2,_next_ganwei
lds R3,_next_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brge L214
lds R2,_M_state
tst R2
brne L214
.dbline 338
; {
.dbline 339
; M_state=1;
ldi R24,1
sts _M_state,R24
.dbline 340
; juli=60;
ldi R16,<L206
ldi R17,>L206
xcall lpm32
sts _juli+1,R17
sts _juli,R16
sts _juli+2+1,R19
sts _juli+2,R18
.dbline 341
; ganwei=next_ganwei;
lds R4,_next_ganwei+2
lds R5,_next_ganwei+2+1
lds R2,_next_ganwei
lds R3,_next_ganwei+1
sts _ganwei+1,R3
sts _ganwei,R2
sts _ganwei+2+1,R5
sts _ganwei+2,R4
.dbline 342
; next_gan=0;
clr R2
sts _next_gan,R2
.dbline 343
; next_ganwei=-500;
ldi R16,<L207
ldi R17,>L207
xcall lpm32
sts _next_ganwei+1,R17
sts _next_ganwei,R16
sts _next_ganwei+2+1,R19
sts _next_ganwei+2,R18
.dbline 344
; jileigan--;
lds R24,_jileigan
subi R24,1
sts _jileigan,R24
.dbline 345
; }
L214:
.dbline 346
; if (ganwei>(ganju*1.10)) //缺杆保护
ldi R16,<L218
ldi R17,>L218
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_ganju+2
lds R5,_ganju+2+1
lds R2,_ganju
lds R3,_ganju+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32fs
lds R4,_ganwei+2
lds R5,_ganwei+2+1
lds R2,_ganwei
lds R3,_ganwei+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brge L216
.dbline 347
; {
.dbline 348
; M_state=0;
clr R2
sts _M_state,R2
.dbline 349
; first_gan=1;
ldi R24,1
sts _first_gan,R24
.dbline 350
; }
L216:
.dbline 351
; }
L202:
.dbline 352
; }
L196:
.dbline 353
lds R24,_key_num
subi R24,255 ; addi 1
sts _key_num,R24
.dbline 354
cpi R24,50
brne L219
.dbline 355
.dbline 356
clr R2
sts _key_num,R2
.dbline 359
ldi R24,1
sts _on_key,R24
.dbline 360
L219:
.dbline -2
L195:
xcall pop_gset3
xcall pop_lset
.dbline 0 ; func end
reti
.dbsym r adc0 10 i
.dbend
.dbfunc e twi_init _twi_init fV
.even
_twi_init::
.dbline -1
.dbline 366
; key_num++; //50次中断后查一次按键,每秒查十次
; if (key_num==50)
; {
; key_num=0;
; //key=ZLG7290_GetKey(); //读取键值
; //if (key>0) on_key=1; //设置按键标志
; on_key=1;
; }
; }
;
; //TWI initialize
; // bit rate:12
; void twi_init(void)
; {
.dbline 372
; //TWCR= 0X00; //disable twi
; //TWBR= 0x10; //set bit rate
; //TWSR= 0x02; //set prescale
; //TWAR= 0x00; //set slave address
; //TWCR= 0x44; //enable twi
; TWBR=0xD0;
ldi R24,208
out 0x0,R24
.dbline 373
; TWAR=0x00;
clr R2
out 0x2,R2
.dbline 374
; TWCR=0x44;
ldi R24,68
out 0x36,R24
.dbline -2
L221:
.dbline 0 ; func end
ret
.dbend
.dbfunc e adc_init _adc_init fV
.even
_adc_init::
.dbline -1
.dbline 380
; }
;
; //ADC initialize
; // Conversion time: 1uS
; void adc_init(void)
; {
.dbline 381
; ADCSR = 0x00; //disable adc
clr R2
out 0x6,R2
.dbline 382
; ADMUX = 0xC0; //select adc input 0
ldi R24,192
out 0x7,R24
.dbline 383
; ACSR = 0x80;
ldi R24,128
out 0x8,R24
.dbline 384
; ADCSRA = 0xE7;
ldi R24,231
out 0x6,R24
.dbline -2
L222:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 4
jmp _int0_isr
.area text(rom, con, rel)
.dbfile D:\gmj_1\main.c
.dbfunc e int0_isr _int0_isr fV
.even
_int0_isr::
st -y,R2
st -y,R3
st -y,R4
st -y,R5
st -y,R16
st -y,R17
st -y,R18
st -y,R19
st -y,R24
st -y,R25
st -y,R26
st -y,R27
in R2,0x3f
st -y,R2
.dbline -1
.dbline 389
; }
;
; #pragma interrupt_handler int0_isr:2
; void int0_isr(void)
; {
.dbline 391
; //external interupt on INT0
; next_gan=1;
ldi R24,1
sts _next_gan,R24
.dbline 392
; next_ganwei=0-juli_jcd;
ldi R16,<L224
ldi R17,>L224
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_juli_jcd+2
lds R5,_juli_jcd+2+1
lds R2,_juli_jcd
lds R3,_juli_jcd+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall sub32f
sts _next_ganwei+1,R17
sts _next_ganwei,R16
sts _next_ganwei+2+1,R19
sts _next_ganwei+2,R18
.dbline -2
L223:
ld R2,y+
out 0x3f,R2
ld R27,y+
ld R26,y+
ld R25,y+
ld R24,y+
ld R19,y+
ld R18,y+
ld R17,y+
ld R16,y+
ld R5,y+
ld R4,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 8
jmp _int1_isr
.area text(rom, con, rel)
.dbfile D:\gmj_1\main.c
.dbfunc e int1_isr _int1_isr fV
; tmp -> R12
; time0_jsq -> R10,R11
.even
_int1_isr::
st -y,R2
st -y,R3
st -y,R4
st -y,R5
st -y,R8
st -y,R9
st -y,R16
st -y,R17
st -y,R18
st -y,R19
st -y,R24
st -y,R25
st -y,R26
st -y,R27
st -y,R30
st -y,R31
in R2,0x3f
st -y,R2
xcall push_gset4
.dbline -1
.dbline 397
; }
;
; #pragma interrupt_handler int1_isr:3
; void int1_isr(void)
; {
.dbline 402
; //external interupt on INT1
; unsigned char tmp;
; unsigned int time0_jsq; //可控硅触发计时
; // Place your code here
; if (pidai_yunxing==1) //如果处于皮带运行状态,则继续。
lds R24,_pidai_yunxing
cpi R24,1
breq X38
xjmp L226
X38:
.dbline 403
; {
.dbline 404
; TCNT0=0; //time0初始化计时值
clr R2
out 0x32,R2
.dbline 405
; TCCR0=2; //time0开始计时
ldi R24,2
out 0x33,R24
.dbline 406
; time0_jsq=pre_jsq; //计算上一次的触发时间
lds R10,_pre_jsq
lds R11,_pre_jsq+1
.dbline 407
; if ((P_speed>(set_speed*1.01)) || (P_speed<(set_speed*0.99)) ) //发果速度波动超过1%,则进行速度调整
ldi R16,<L231
ldi R17,>L231
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_set_speed+2
lds R5,_set_speed+2+1
lds R2,_set_speed
lds R3,_set_speed+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32fs
lds R4,_P_speed+2
lds R5,_P_speed+2+1
lds R2,_P_speed
lds R3,_P_speed+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall cmp32f
brlt L230
lds R4,_P_speed+2
lds R5,_P_speed+2+1
lds R2,_P_speed
lds R3,_P_speed+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L232
ldi R17,>L232
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R4,_set_speed+2
lds R5,_set_speed+2+1
lds R2,_set_speed
lds R3,_set_speed+1
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32fs
xcall cmp32f
brlt X39
xjmp L228
X39:
L230:
.dbline 408
; {
.dbline 409
; switch(dj_jibie) //逐步逼近法进行速度加减调整,tmp为速度调整的加减量
lds R12,_dj_jibie
clr R13
tst R12
brne X36
tst R13
breq L236
X36:
movw R24,R12
cpi R24,1
ldi R30,0
cpc R25,R30
breq L237
cpi R24,2
ldi R30,0
cpc R25,R30
breq L238
cpi R24,3
ldi R30,0
cpc R25,R30
breq L239
cpi R24,4
ldi R30,0
cpc R25,R30
breq L240
cpi R24,5
ldi R30,0
cpc R25,R30
breq L241
cpi R24,6
ldi R30,0
cpc R25,R30
breq L242
xjmp L233
X37:
.dbline 410
; {
L236:
.dbline 411
; case 0: tmp=64; break; //依据逼近度确定加减量
ldi R24,64
mov R12,R24
.dbline 411
xjmp L234
L237:
.dbline 412
; case 1: tmp=32; break;
ldi R24,32
mov R12,R24
.dbline 412
xjmp L234
L238:
.dbline 413
; case 2: tmp=16; break;
ldi R24,16
mov R12,R24
.dbline 413
xjmp L234
L239:
.dbline 414
; case 3: tmp=8; break;
ldi R24,8
mov R12,R24
.dbline 414
xjmp L234
L240:
.dbline 415
; case 4: tmp=4; break;
ldi R24,4
mov R12,R24
.dbline 415
xjmp L234
L241:
.dbline 416
; case 5: tmp=2; break;
ldi R24,2
mov R12,R24
.dbline 416
xjmp L234
L242:
.dbline 417
; case 6: tmp=1; break;
clr R12
inc R12
.dbline 417
L233:
L234:
.dbline 419
; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -