📄 main.s
字号:
st -y,R16
xcall add32f
movw R30,R28
std z+2,R16
std z+3,R17
std z+4,R18
std z+5,R19
.dbline 368
ldi R16,<L54
ldi R17,>L54
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+6
ldd R3,z+7
ldd R4,z+8
ldd R5,z+9
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32fs
ldi R16,<L55
ldi R17,>L55
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall div32f
movw R30,R28
std z+2,R16
std z+3,R17
std z+4,R18
std z+5,R19
.dbline 369
; f=f*0.95;//修正
ldi R16,<L134
ldi R17,>L134
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
movw R30,R28
; stack offset 4
ldd R2,z+6
ldd R3,z+7
ldd R4,z+8
ldd R5,z+9
st -y,R5
st -y,R4
st -y,R3
st -y,R2
xcall empy32f
movw R30,R28
std z+2,R16
std z+3,R17
std z+4,R18
std z+5,R19
.dbline 370
; RRC=f;//暂存最大运行电流
movw R30,R28
ldd R2,z+2
ldd R3,z+3
ldd R4,z+4
ldd R5,z+5
sts _RRC+1,R3
sts _RRC,R2
sts _RRC+2+1,R5
sts _RRC+2,R4
.dbline 371
; if(RRC<550)OutFlag++;//判断最大运行电流大小
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L137
ldi R17,>L137
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brge L135
.dbline 371
lds R24,_OutFlag
subi R24,255 ; addi 1
sts _OutFlag,R24
L135:
.dbline 373
;
; current=(uint)f;
movw R30,R28
ldd R2,z+2
ldd R3,z+3
ldd R4,z+4
ldd R5,z+5
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L62
ldi R17,>L62
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall cmp32f
brlt L138
movw R30,R28
ldd R2,z+2
ldd R3,z+3
ldd R4,z+4
ldd R5,z+5
st -y,R5
st -y,R4
st -y,R3
st -y,R2
ldi R16,<L62
ldi R17,>L62
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall sub32f
xcall fp2int
movw R20,R16
subi R20,0 ; offset = 32768
sbci R21,128
xjmp L139
L138:
movw R30,R28
ldd R16,z+2
ldd R17,z+3
ldd R18,z+4
ldd R19,z+5
xcall fp2int
movw R20,R16
L139:
sts _current+1,R21
sts _current,R20
.dbline 374
; temp=current;temp=temp/1000;RC[3]=(uchar)temp;
movw R10,R20
.dbline 374
ldi R18,1000
ldi R19,3
movw R16,R10
xcall div16u
movw R10,R16
.dbline 374
sts _RC+3,R10
.dbline 375
; temp=current;temp=(temp/100)%10;RC[2]=(uchar)temp;
lds R10,_current
lds R11,_current+1
.dbline 375
ldi R18,100
ldi R19,0
movw R16,R10
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 375
sts _RC+2,R10
.dbline 376
; temp=current;temp=(temp/10)%10;RC[1]=(uchar)temp;
lds R10,_current
lds R11,_current+1
.dbline 376
ldi R18,10
ldi R19,0
movw R16,R10
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 376
sts _RC+1,R10
.dbline 377
; temp=current;temp=temp%10;RC[0]=(uchar)temp;
lds R10,_current
lds R11,_current+1
.dbline 377
ldi R18,10
ldi R19,0
movw R16,R10
xcall mod16u
movw R10,R16
.dbline 377
sts _RC,R10
.dbline 378
; DisplayOneChar(11,2,RC[3]+0x30);
lds R24,_RC+3
subi R24,208 ; addi 48
std y+0,R24
ldi R18,2
ldi R16,11
xcall _DisplayOneChar
.dbline 379
; DisplayOneChar(12,2,0x2e);
ldi R24,46
std y+0,R24
ldi R18,2
ldi R16,12
xcall _DisplayOneChar
.dbline 380
; DisplayOneChar(13,2,RC[2]+0x30);
lds R24,_RC+2
subi R24,208 ; addi 48
std y+0,R24
ldi R18,2
ldi R16,13
xcall _DisplayOneChar
.dbline 381
; DisplayOneChar(14,2,RC[1]+0x30);
lds R24,_RC+1
subi R24,208 ; addi 48
std y+0,R24
ldi R18,2
ldi R16,14
xcall _DisplayOneChar
.dbline 382
; break;
xjmp L41
L146:
.dbline 384
;
; case 24:POW_OFF;Delay_nms(100);POW_14V;status=25;//关闭27V及POW
sbi 0x12,1
.dbline 384
ldi R16,100
ldi R17,0
xcall _Delay_nms
.dbline 384
sbi 0x12,2
.dbline 384
ldi R24,25
sts _status,R24
.dbline 385
; break;
xjmp L41
L147:
.dbline 387
;
; case 25:AIR_ON;Wait6S_Start_Flag=1;cnt=0;status=26;//启动2S及气缸
cbi 0x12,3
.dbline 387
ldi R24,1
sts _Wait6S_Start_Flag,R24
.dbline 387
clr R2
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 387
ldi R24,26
sts _status,R24
.dbline 388
; break;
xjmp L41
L148:
.dbline 390
;
; case 26:ePutstr(0,0,result);//显示输出结果
ldi R24,<_result
ldi R25,>_result
std y+1,R25
std y+0,R24
clr R18
clr R16
xcall _ePutstr
.dbline 391
; if(OutFlag==5)
lds R24,_OutFlag
cpi R24,5
brne L149
.dbline 392
; {
.dbline 393
; DisplayOneChar(12,3,'P');//显示PASS
ldi R24,80
std y+0,R24
ldi R18,3
ldi R16,12
xcall _DisplayOneChar
.dbline 394
; DisplayOneChar(13,3,'A');
ldi R24,65
std y+0,R24
ldi R18,3
ldi R16,13
xcall _DisplayOneChar
.dbline 395
; DisplayOneChar(14,3,'S');
ldi R24,83
std y+0,R24
ldi R18,3
ldi R16,14
xcall _DisplayOneChar
.dbline 396
; DisplayOneChar(15,3,'S');
ldi R24,83
std y+0,R24
ldi R18,3
ldi R16,15
xcall _DisplayOneChar
.dbline 397
; }
xjmp L152
L149:
.dbline 399
; else
; {
.dbline 400
; DisplayOneChar(12,3,'F');//显示FAIL
ldi R24,70
std y+0,R24
ldi R18,3
ldi R16,12
xcall _DisplayOneChar
.dbline 401
; DisplayOneChar(13,3,'A');
ldi R24,65
std y+0,R24
ldi R18,3
ldi R16,13
xcall _DisplayOneChar
.dbline 402
; DisplayOneChar(14,3,'I');
ldi R24,73
std y+0,R24
ldi R18,3
ldi R16,14
xcall _DisplayOneChar
.dbline 403
; DisplayOneChar(15,3,'L');
ldi R24,76
std y+0,R24
ldi R18,3
ldi R16,15
xcall _DisplayOneChar
.dbline 404
; }
xjmp L152
L151:
.dbline 406
; while(Wait6S_End_Flag==0)//等待2S定时结束
; {
.dbline 407
; if(OutFlag==5){LCM_BLCON_ON;BZ_ON;Delay_nms(100);BZ_OFF;}//合格响一下
lds R24,_OutFlag
cpi R24,5
brne L154
.dbline 407
.dbline 407
cbi 0x12,4
.dbline 407
cbi 0x12,7
.dbline 407
ldi R16,100
ldi R17,0
xcall _Delay_nms
.dbline 407
sbi 0x12,7
.dbline 407
xjmp L155
L154:
.dbline 408
; else {BZ_ON;LCM_BLCON_ON;Delay_nms(50);
.dbline 408
cbi 0x12,7
.dbline 408
cbi 0x12,4
.dbline 408
ldi R16,50
ldi R17,0
xcall _Delay_nms
.dbline 409
; BZ_OFF;LCM_BLCON_OFF;Delay_nms(50);}//不合格连续响
sbi 0x12,7
.dbline 409
sbi 0x12,4
.dbline 409
ldi R16,50
ldi R17,0
xcall _Delay_nms
.dbline 409
L155:
.dbline 410
L152:
.dbline 405
lds R2,_Wait6S_End_Flag
tst R2
breq L151
.dbline 412
; }
;
; Wait6S_End_Flag=0;
clr R2
sts _Wait6S_End_Flag,R2
.dbline 414
;
; AIR_OFF;cnt=0;//关闭气缸
sbi 0x12,3
.dbline 414
clr R3
sts _cnt+1,R3
sts _cnt,R2
xjmp L157
L156:
.dbline 416
; while(status==26)
; {scan_key();WDR();
.dbline 416
xcall _scan_key
.dbline 416
wdr
.dbline 417
; if(OutFlag<5)
lds R24,_OutFlag
cpi R24,5
brsh L159
.dbline 418
; {BZ_ON;LCM_BLCON_ON;Delay_nms(50);BZ_OFF;LCM_BLCON_OFF;Delay_nms(50);}
.dbline 418
cbi 0x12,7
.dbline 418
cbi 0x12,4
.dbline 418
ldi R16,50
ldi R17,0
xcall _Delay_nms
.dbline 418
sbi 0x12,7
.dbline 418
sbi 0x12,4
.dbline 418
ldi R16,50
ldi R17,0
xcall _Delay_nms
.dbline 418
L159:
.dbline 419
L157:
.dbline 415
lds R24,_status
cpi R24,26
breq L156
.dbline 420
; }
; break;
xjmp L41
L161:
.dbline 421
; case 27:status=0;display_val=0;current=0;//清零所有变量
clr R2
sts _status,R2
.dbline 421
clr R3
sts _display_val+1,R3
sts _display_val,R2
.dbline 421
sts _current+1,R3
sts _current,R2
.dbline 422
; clr_T1();cnt=0;
xcall _clr_T1
.dbline 422
clr R2
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 423
clr R20
xjmp L165
L162:
.dbline 423
ldi R24,<_LVS
ldi R25,>_LVS
mov R30,R20
clr R31
add R30,R24
adc R31,R25
clr R2
std z+0,R2
L163:
.dbline 423
inc R20
L165:
.dbline 423
; for(i=0;i<4;i++)LVS[i]=0;
cpi R20,4
brlo L162
.dbline 424
clr R20
xjmp L169
L166:
.dbline 424
ldi R24,<_TPV
ldi R25,>_TPV
mov R30,R20
clr R31
add R30,R24
adc R31,R25
clr R2
std z+0,R2
L167:
.dbline 424
inc R20
L169:
.dbline 424
; for(i=0;i<4;i++)TPV[i]=0;
cpi R20,4
brlo L166
.dbline 425
clr R20
xjmp L173
L170:
.dbline 425
ldi R24,<_RPM
ldi R25,>_RPM
mov R30,R20
clr R31
add R30,R24
adc R31,R25
clr R2
std z+0,R2
L171:
.dbline 425
inc R20
L173:
.dbline 425
; for(i=0;i<4;i++)RPM[i]=0;
cpi R20,4
brlo L170
.dbline 426
clr R20
xjmp L177
L174:
.dbline 426
ldi R24,<_LC
ldi R25,>_LC
mov R30,R20
clr R31
add R30,R24
adc R31,R25
clr R2
std z+0,R2
L175:
.dbline 426
inc R20
L177:
.dbline 426
; for(i=0;i<4;i++)LC[i]=0;
cpi R20,4
brlo L174
.dbline 427
clr R20
xjmp L181
L178:
.dbline 427
ldi R24,<_RC
ldi R25,>_RC
mov R30,R20
clr R31
add R30,R24
adc R31,R25
clr R2
std z+0,R2
L179:
.dbline 427
inc R20
L181:
.dbline 427
; for(i=0;i<4;i++)RC[i]=0;
cpi R20,4
brlo L178
.dbline 428
; RRC=0;LLC=0;OutFlag=0;LCM_BLCON_OFF;
ldi R16,<L182
ldi R17,>L182
xcall lpm32
sts _RRC+1,R17
sts _RRC,R16
sts _RRC+2+1,R19
sts _RRC+2,R18
.dbline 428
ldi R16,<L182
ldi R17,>L182
xcall lpm32
sts _LLC+1,R17
sts _LLC,R16
sts _LLC+2+1,R19
sts _LLC+2,R18
.dbline 428
clr R2
sts _OutFlag,R2
.dbline 428
sbi 0x12,4
.dbline 429
; break;
.dbline 431
;
; default:break;
L41:
.dbline 433
L38:
.dbline 234
xjmp L37
X1:
.dbline -2
L36:
adiw R28,6
.dbline 0 ; func end
ret
.dbsym l f 2 D
.dbsym r temp 10 i
.dbsym r i 20 c
.dbend
.dbfunc e ADC_Convert _ADC_Convert fi
; temp1 -> R18,R19
; temp2 -> R16,R17
.even
_ADC_Convert::
.dbline -1
.dbline 437
; }
; }
; }
; //************************************
; uint ADC_Convert(void)//ADC转换
; {uint temp1,temp2;
.dbline 438
; temp1=(uint)ADCL;
in R18,0x4
clr R19
.dbline 439
; temp2=(uint)ADCH;
in R16,0x5
clr R17
.dbline 440
; temp2=(temp2<<8)+temp1;
movw R2,R16
mov R3,R2
clr R2
add R2,R18
adc R3,R19
movw R16,R2
.dbline 441
; return(temp2);
.dbline -2
L184:
.dbline 0 ; func end
ret
.dbsym r temp1 18 i
.dbsym r temp2 16 i
.dbend
.dbfunc e Delay_1ms _Delay_1ms fV
; i -> R16,R17
.even
_Delay_1ms::
.dbline -1
.dbline 445
; }
; //****************************************
; void Delay_1ms(void) //1mS延时子函数
; { uint i;
.dbline 446
; for(i=1;i<(uint)(xtal*143-2);i++)
ldi R16,1
ldi R17,0
xjmp L189
L186:
.dbline 447
L187:
.dbline 446
subi R16,255 ; offset = 1
sbci R17,255
L189:
.dbline 446
cpi R16,118
ldi R30,4
cpc R17,R30
brlo L186
.dbline -2
L185:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbend
.dbfunc e Delay_nms _Delay_nms fV
; i -> R20,R21
; n -> R22,R23
.even
_Delay_nms::
xcall push_gset2
movw R22,R16
.dbline -1
.dbline 451
; ;
; }
; //=============================================
; void Delay_nms(uint n) //n*1mS延时子函数
; {
.dbline 452
; uint i=0;
clr R20
clr R21
xjmp L192
L191:
.dbline 454
.dbline 454
xcall _Delay_1ms
.dbline 454
wdr
.dbline 455
subi R20,255 ; offset = 1
sbci R21,255
.dbline 456
L192:
.dbline 453
; while(i<n)
cp R20,R22
cpc R21,R23
brlo L191
.dbline -2
L190:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r n 22 i
.dbend
.area bss(ram, con, rel)
.dbfile D:\ac18-1\main.c
_LLC::
.blkb 4
.dbsym e LLC _LLC D
_RRC::
.blkb 4
.dbsym e RRC _RRC D
_RRPM::
.blkb 2
.dbsym e RRPM _RRPM i
_TTPV::
.blkb 2
.dbsym e TTPV _TTPV i
_LLVS::
.blkb 2
.dbsym e LLVS _LLVS i
_LC::
.blkb 4
.dbsym e LC _LC A[4:4]c
_RC::
.blkb 4
.dbsym e RC _RC A[4:4]c
_RPM::
.blkb 4
.dbsym e RPM _RPM A[4:4]c
_TPV::
.blkb 4
.dbsym e TPV _TPV A[4:4]c
_LVS::
.blkb 4
.dbsym e LVS _LVS A[4:4]c
.area lit(rom, con, rel)
L182:
.word 0x0,0x0
L137:
.word 0x8000,0x4409
L134:
.word 0x3333,0x3f73
L122:
.word 0x0,0x4040
L99:
.word 0x3333,0x405b
L76:
.word 0x851f,0x409f
L62:
.word 0x0,0x4700
L59:
.word 0x0,0x43f0
L56:
.word 0x0,0x4088
L55:
.word 0x0,0x4480
L54:
.word 0x0,0x4520
L53:
.word 0x0,0x4000
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -