📄 main.s
字号:
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 296
sts _LVS+2,R10
.dbline 297
; temp=display_val;temp=(temp/10)%10;LVS[1]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 297
ldi R18,10
ldi R19,0
movw R16,R10
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 297
sts _LVS+1,R10
.dbline 298
; temp=display_val;temp=temp%10;LVS[0]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 298
ldi R18,10
ldi R19,0
movw R16,R10
xcall mod16u
movw R10,R16
.dbline 298
sts _LVS,R10
.dbline 299
; DisplayOneChar(4,1,LVS[3]+0x30);
lds R24,_LVS+3
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,4
xcall _DisplayOneChar
.dbline 300
; DisplayOneChar(5,1,LVS[2]+0x30);
lds R24,_LVS+2
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,5
xcall _DisplayOneChar
.dbline 301
; DisplayOneChar(6,1,LVS[1]+0x30);
lds R24,_LVS+1
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,6
xcall _DisplayOneChar
.dbline 302
; DisplayOneChar(7,1,LVS[0]+0x30);
lds R24,_LVS
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,7
xcall _DisplayOneChar
.dbline 303
; break;
xjmp L41
L87:
.dbline 305
;
; case 11:POW_OFF;Delay_nms(100);POW_27V;SPEED_0V;//转换成27V,TPV
sbi 0x12,1
.dbline 305
ldi R16,100
ldi R17,0
xcall _Delay_nms
.dbline 305
cbi 0x12,2
.dbline 305
sbi 0x12,0
.dbline 306
; Delay_nms(100);POW_ON;status=12;
ldi R16,100
ldi R17,0
xcall _Delay_nms
.dbline 306
cbi 0x12,1
.dbline 306
ldi R24,12
sts _status,R24
.dbline 307
; break;
xjmp L41
L88:
.dbline 309
;
; case 12:Wait6S_Start_Flag=1;cnt=0;status=13;//启动6S
ldi R24,1
sts _Wait6S_Start_Flag,R24
.dbline 309
clr R2
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 309
ldi R24,13
sts _status,R24
.dbline 310
; break;
xjmp L41
L90:
.dbline 312
ldi R16,10
ldi R17,0
xcall _Delay_nms
L91:
.dbline 312
;
; case 13:while(Wait6S_End_Flag==0)Delay_nms(10);Wait6S_End_Flag=0;status=14;cnt=0;//等待6S定时结束
lds R2,_Wait6S_End_Flag
tst R2
breq L90
.dbline 312
clr R2
sts _Wait6S_End_Flag,R2
.dbline 312
ldi R24,14
sts _status,R24
.dbline 312
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 313
; break;
xjmp L41
L93:
.dbline 315
;
; case 14:Wait10S_Start_Flag=1;cnt=0;clr_T1();
ldi R24,1
sts _Wait10S_Start_Flag,R24
.dbline 315
clr R2
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 315
xcall _clr_T1
.dbline 316
; TCCR1B = 0x06;display_val=0;status=15;//启动10S并开始T1计数
ldi R24,6
out 0x2e,R24
.dbline 316
clr R2
clr R3
sts _display_val+1,R3
sts _display_val,R2
.dbline 316
ldi R24,15
sts _status,R24
.dbline 317
; break;
xjmp L41
L95:
.dbline 319
ldi R16,10
ldi R17,0
xcall _Delay_nms
L96:
.dbline 319
;
; case 15:while(Wait10S_End_Flag==0)Delay_nms(10);Wait10S_End_Flag=0;status=16;cnt=0;//等待10S定时结束
lds R2,_Wait10S_End_Flag
tst R2
breq L95
.dbline 319
clr R2
sts _Wait10S_End_Flag,R2
.dbline 319
ldi R24,16
sts _status,R24
.dbline 319
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 320
; break;
xjmp L41
L98:
.dbline 322
;
; case 16:TCCR1B = 0x00;display_val=read_T1();status=17;//读取T1的计数(TPV)
clr R2
out 0x2e,R2
.dbline 322
xcall _read_T1
sts _display_val+1,R17
sts _display_val,R16
.dbline 322
ldi R24,17
sts _status,R24
.dbline 323
; f=(float)display_val;f=f*3.425;display_val=(uint)f;//修正
ldi R16,<L53
ldi R17,>L53
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R16,_display_val
lds R17,_display_val+1
lsr R17
ror R16
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
lds R16,_display_val
lds R17,_display_val+1
andi R16,1
andi R17,0
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
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 323
ldi R16,<L99
ldi R17,>L99
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 323
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 L100
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 L101
L100:
movw R30,R28
ldd R16,z+2
ldd R17,z+3
ldd R18,z+4
ldd R19,z+5
xcall fp2int
movw R20,R16
L101:
sts _display_val+1,R21
sts _display_val,R20
.dbline 324
; TTPV=display_val;//暂存TVP
movw R2,R20
sts _TTPV+1,R3
sts _TTPV,R2
.dbline 325
; if((TTPV>1850)&&(TTPV<2200))OutFlag++;//判断TPV
ldi R24,1850
ldi R25,7
lds R2,_TTPV
lds R3,_TTPV+1
cp R24,R2
cpc R25,R3
brsh L102
movw R24,R2
cpi R24,152
ldi R30,8
cpc R25,R30
brsh L102
.dbline 325
lds R24,_OutFlag
subi R24,255 ; addi 1
sts _OutFlag,R24
L102:
.dbline 326
; temp=display_val;temp=temp/1000;TPV[3]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 326
ldi R18,1000
ldi R19,3
movw R16,R10
xcall div16u
movw R10,R16
.dbline 326
sts _TPV+3,R10
.dbline 327
; temp=display_val;temp=(temp/100)%10;TPV[2]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 327
ldi R18,100
ldi R19,0
movw R16,R10
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 327
sts _TPV+2,R10
.dbline 328
; temp=display_val;temp=(temp/10)%10;TPV[1]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 328
ldi R18,10
ldi R19,0
movw R16,R10
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 328
sts _TPV+1,R10
.dbline 329
; temp=display_val;temp=temp%10;TPV[0]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 329
ldi R18,10
ldi R19,0
movw R16,R10
xcall mod16u
movw R10,R16
.dbline 329
sts _TPV,R10
.dbline 330
; DisplayOneChar(12,1,TPV[3]+0x30);
lds R24,_TPV+3
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,12
xcall _DisplayOneChar
.dbline 331
; DisplayOneChar(13,1,TPV[2]+0x30);
lds R24,_TPV+2
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,13
xcall _DisplayOneChar
.dbline 332
; DisplayOneChar(14,1,TPV[1]+0x30);
lds R24,_TPV+1
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,14
xcall _DisplayOneChar
.dbline 333
; DisplayOneChar(15,1,TPV[0]+0x30);
lds R24,_TPV
subi R24,208 ; addi 48
std y+0,R24
ldi R18,1
ldi R16,15
xcall _DisplayOneChar
.dbline 334
; break;
xjmp L41
L110:
.dbline 336
;
; case 17:SPEED_5V;status=18;//转换成27V,RPM
cbi 0x12,0
.dbline 336
ldi R24,18
sts _status,R24
.dbline 337
; break;
xjmp L41
L111:
.dbline 339
;
; case 18:Wait6S_Start_Flag=1;cnt=0;status=19;//启动6S
ldi R24,1
sts _Wait6S_Start_Flag,R24
.dbline 339
clr R2
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 339
ldi R24,19
sts _status,R24
.dbline 340
; break;
xjmp L41
L113:
.dbline 342
ldi R16,10
ldi R17,0
xcall _Delay_nms
L114:
.dbline 342
;
; case 19:while(Wait6S_End_Flag==0)Delay_nms(10);Wait6S_End_Flag=0;status=20;cnt=0;//等待6S定时结束
lds R2,_Wait6S_End_Flag
tst R2
breq L113
.dbline 342
clr R2
sts _Wait6S_End_Flag,R2
.dbline 342
ldi R24,20
sts _status,R24
.dbline 342
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 343
; break;
xjmp L41
L116:
.dbline 345
;
; case 20:Wait10S_Start_Flag=1;cnt=0;clr_T1();
ldi R24,1
sts _Wait10S_Start_Flag,R24
.dbline 345
clr R2
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 345
xcall _clr_T1
.dbline 346
; TCCR1B = 0x06;status=21;//启动10S并开始计数
ldi R24,6
out 0x2e,R24
.dbline 346
ldi R24,21
sts _status,R24
.dbline 347
; break;
xjmp L41
L118:
.dbline 349
ldi R16,10
ldi R17,0
xcall _Delay_nms
L119:
.dbline 349
;
; case 21:while(Wait10S_End_Flag==0)Delay_nms(10);Wait10S_End_Flag=0;status=22;cnt=0;//等待10S定时结束
lds R2,_Wait10S_End_Flag
tst R2
breq L118
.dbline 349
clr R2
sts _Wait10S_End_Flag,R2
.dbline 349
ldi R24,22
sts _status,R24
.dbline 349
clr R3
sts _cnt+1,R3
sts _cnt,R2
.dbline 350
; break;
xjmp L41
L121:
.dbline 352
;
; case 22:TCCR1B = 0x00;display_val=read_T1();status=23;//读取T1的计数(RPM)
clr R2
out 0x2e,R2
.dbline 352
xcall _read_T1
sts _display_val+1,R17
sts _display_val,R16
.dbline 352
ldi R24,23
sts _status,R24
.dbline 353
; f=(float)display_val;f=f*3;display_val=(uint)f;//修正
ldi R16,<L53
ldi R17,>L53
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R16,_display_val
lds R17,_display_val+1
lsr R17
ror R16
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
lds R16,_display_val
lds R17,_display_val+1
andi R16,1
andi R17,0
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
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 353
ldi R16,<L122
ldi R17,>L122
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 353
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 L123
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 L124
L123:
movw R30,R28
ldd R16,z+2
ldd R17,z+3
ldd R18,z+4
ldd R19,z+5
xcall fp2int
movw R20,R16
L124:
sts _display_val+1,R21
sts _display_val,R20
.dbline 354
; RRPM=display_val;//暂存RPM
movw R2,R20
sts _RRPM+1,R3
sts _RRPM,R2
.dbline 355
; if((RRPM>3600)&&(RRPM<4000))OutFlag++;//判断RPM
ldi R24,3600
ldi R25,14
lds R2,_RRPM
lds R3,_RRPM+1
cp R24,R2
cpc R25,R3
brsh L125
movw R24,R2
cpi R24,160
ldi R30,15
cpc R25,R30
brsh L125
.dbline 355
lds R24,_OutFlag
subi R24,255 ; addi 1
sts _OutFlag,R24
L125:
.dbline 356
; temp=display_val;temp=temp/1000;RPM[3]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 356
ldi R18,1000
ldi R19,3
movw R16,R10
xcall div16u
movw R10,R16
.dbline 356
sts _RPM+3,R10
.dbline 357
; temp=display_val;temp=(temp/100)%10;RPM[2]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 357
ldi R18,100
ldi R19,0
movw R16,R10
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 357
sts _RPM+2,R10
.dbline 358
; temp=display_val;temp=(temp/10)%10;RPM[1]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 358
ldi R18,10
ldi R19,0
movw R16,R10
xcall div16u
ldi R18,10
ldi R19,0
xcall mod16u
movw R10,R16
.dbline 358
sts _RPM+1,R10
.dbline 359
; temp=display_val;temp=temp%10;RPM[0]=(uchar)temp;
lds R10,_display_val
lds R11,_display_val+1
.dbline 359
ldi R18,10
ldi R19,0
movw R16,R10
xcall mod16u
movw R10,R16
.dbline 359
sts _RPM,R10
.dbline 360
; DisplayOneChar(4,2,RPM[3]+0x30);
lds R24,_RPM+3
subi R24,208 ; addi 48
std y+0,R24
ldi R18,2
ldi R16,4
xcall _DisplayOneChar
.dbline 361
; DisplayOneChar(5,2,RPM[2]+0x30);
lds R24,_RPM+2
subi R24,208 ; addi 48
std y+0,R24
ldi R18,2
ldi R16,5
xcall _DisplayOneChar
.dbline 362
; DisplayOneChar(6,2,RPM[1]+0x30);
lds R24,_RPM+1
subi R24,208 ; addi 48
std y+0,R24
ldi R18,2
ldi R16,6
xcall _DisplayOneChar
.dbline 363
; DisplayOneChar(7,2,RPM[0]+0x30);
lds R24,_RPM
subi R24,208 ; addi 48
std y+0,R24
ldi R18,2
ldi R16,7
xcall _DisplayOneChar
.dbline 364
; break;
xjmp L41
L133:
.dbline 366
;
; case 23:current=average();status=24;//取样最大运行电流
xcall _average
sts _current+1,R17
sts _current,R16
.dbline 366
ldi R24,24
sts _status,R24
.dbline 367
; current=current-14;
movw R24,R16
sbiw R24,14
sts _current+1,R25
sts _current,R24
.dbline 368
; f=(float)current;f=(f*2560)/1024;
ldi R16,<L53
ldi R17,>L53
xcall lpm32
st -y,R19
st -y,R18
st -y,R17
st -y,R16
lds R16,_current
lds R17,_current+1
lsr R17
ror R16
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
st -y,R16
xcall empy32fs
lds R16,_current
lds R17,_current+1
andi R16,1
andi R17,0
xcall int2fp
st -y,R19
st -y,R18
st -y,R17
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -