📄 mc_stm8s_bldc_drive.ls
字号:
306 012f 04 dc.b 4
307 0130 01 dc.b 1
308 0131 00 dc.b 0
309 0132 02 dc.b 2
310 0133 06 dc.b 6
311 0134 _bHallSteps_CCW:
312 0134 06 dc.b 6
313 0135 04 dc.b 4
314 0136 00 dc.b 0
315 0137 05 dc.b 5
316 0138 02 dc.b 2
317 0139 03 dc.b 3
318 013a 01 dc.b 1
319 013b 06 dc.b 6
320 bsct
321 0017 _bHallSteps:
322 0017 012c dc.w _bHallSteps_CW
323 0019 _bComHanderEnable:
324 0019 00 dc.b 0
325 001a _hTim3Cnt:
326 001a 0000 dc.w 0
327 001c _hTim3Th:
328 001c 0000 dc.w 0
1045 switch .const
1046 013c L01:
1047 013c 000003e8 dc.l 1000
1048 0140 L21:
1049 0140 000029a0 dc.l 10656
1050 0144 L41:
1051 0144 00001388 dc.l 5000
1052 ; 618 void dev_driveInit(pvdev_device_t pdevice)
1052 ; 619 {
1053 scross off
1054 switch .text
1055 0000 _dev_driveInit:
1057 0000 89 pushw x
1058 0001 89 pushw x
1059 00000002 OFST: set 2
1062 ; 620 PBLDC_Struct_t pBLDC_Struct = Get_BLDC_Struct();
1064 0002 cd0000 call _Get_BLDC_Struct
1066 0005 1f01 ldw (OFST-1,sp),x
1067 ; 621 g_pBLDC_Struct = pBLDC_Struct;
1069 0007 bf03 ldw _g_pBLDC_Struct,x
1070 ; 622 g_pMotorVar = pBLDC_Struct->pBLDC_Var;
1072 0009 fe ldw x,(x)
1073 000a bf05 ldw L5_g_pMotorVar,x
1074 ; 623 g_pDevice = pdevice;
1076 000c 1e03 ldw x,(OFST+1,sp)
1077 000e bf01 ldw _g_pDevice,x
1078 ; 626 hDutyCntTh = (u16)(((u32)hArrPwmVal*DUTY_CYCLE_TH_TON)/100);
1080 0010 ae02cf ldw x,#719
1081 0013 bf31 ldw _hDutyCntTh,x
1082 ; 629 hCntDeadDtime = (u16)(((u32)g_pBLDC_Struct->pBLDC_Const->hDeadTime * STM8_FREQ_MHZ )/1000);
1084 0015 be03 ldw x,_g_pBLDC_Struct
1085 0017 ee02 ldw x,(2,x)
1086 0019 a610 ld a,#16
1087 001b ee0a ldw x,(10,x)
1088 001d cd0000 call c_cmulx
1090 0020 ae013c ldw x,#L01
1091 0023 cd0000 call c_ludv
1093 0026 be02 ldw x,c_lreg+2
1094 0028 bf2f ldw _hCntDeadDtime,x
1095 ; 632 CurrentLimitCnt = (u16)(MILLIAMP_TOCNT (g_pBLDC_Struct->pBLDC_Const->hCurrent_Limitation));
1097 002a be03 ldw x,_g_pBLDC_Struct
1098 002c ee02 ldw x,(2,x)
1099 002e 90ae04c4 ldw y,#1220
1100 0032 ee08 ldw x,(8,x)
1101 0034 cd0000 call c_umul
1103 0037 ae013c ldw x,#L01
1104 003a cd0000 call c_ludv
1106 003d ae0140 ldw x,#L21
1107 0040 cd0000 call c_lmul
1109 0043 ae0144 ldw x,#L41
1110 0046 cd0000 call c_ludv
1112 0049 be02 ldw x,c_lreg+2
1113 004b bf1c ldw _CurrentLimitCnt,x
1114 ; 638 pcounter_reg = &(pdevice->regs.r16[VDEV_REG16_HALL_COUNTS]);
1116 004d 1e03 ldw x,(OFST+1,sp)
1117 004f ee02 ldw x,(2,x)
1118 0051 1c0002 addw x,#2
1119 0054 bf0a ldw L51_pcounter_reg,x
1120 ; 641 pDutyCycleCounts_reg = &(pdevice->regs.r16[VDEV_REG16_BLDC_DUTY_CYCLE_COUNTS]);
1122 0056 1e03 ldw x,(OFST+1,sp)
1123 0058 ee02 ldw x,(2,x)
1124 005a 1c0008 addw x,#8
1125 005d bf08 ldw L71_pDutyCycleCounts_reg,x
1126 ; 643 Init_TIM1();
1128 005f cd049f call _Init_TIM1
1130 ; 644 Init_TIM2();
1132 0062 cd052c call _Init_TIM2
1134 ; 645 Init_ADC();
1136 0065 cd0348 call _Init_ADC
1138 ; 654 LS_A_PORT->ODR &= (u8)(~LS_A_PIN);
1140 0068 721f500a bres 20490,#7
1141 ; 658 LS_A_PORT->DDR |= LS_A_PIN;
1143 006c 721e500c bset 20492,#7
1144 ; 659 LS_A_PORT->CR1 |= LS_A_PIN;
1146 0070 721e500d bset 20493,#7
1147 ; 660 LS_A_PORT->CR2 |= LS_A_PIN;
1149 0074 721e500e bset 20494,#7
1150 ; 662 LS_B_PORT->ODR &= (u8)(~LS_B_PIN);
1152 0078 721d500a bres 20490,#6
1153 ; 666 LS_B_PORT->DDR |= LS_B_PIN;
1155 007c 721c500c bset 20492,#6
1156 ; 667 LS_B_PORT->CR1 |= LS_B_PIN;
1158 0080 721c500d bset 20493,#6
1159 ; 668 LS_B_PORT->CR2 |= LS_B_PIN;
1161 0084 721c500e bset 20494,#6
1162 ; 670 LS_C_PORT->ODR &= (u8)(~LS_C_PIN);
1164 0088 721b500a bres 20490,#5
1165 ; 674 LS_C_PORT->DDR |= LS_C_PIN;
1167 008c 721a500c bset 20492,#5
1168 ; 675 LS_C_PORT->CR1 |= LS_C_PIN;
1170 0090 721a500d bset 20493,#5
1171 ; 676 LS_C_PORT->CR2 |= LS_C_PIN;
1173 ; 680 vtimer_SetTimer(ADC_SAMPLE_TIMER,ADC_SAMPLE_TIMEOUT,&Application_ADC_Manager);
1175 0094 ae0276 ldw x,#_Application_ADC_Manager
1176 0097 721a500e bset 20494,#5
1177 009b 89 pushw x
1178 009c ae000a ldw x,#10
1179 009f 89 pushw x
1180 00a0 a608 ld a,#8
1181 00a2 cd0000 call _vtimer_SetTimer
1183 00a5 5b08 addw sp,#8
1184 ; 681 }
1187 00a7 81 ret
1210 ; 683 void dev_driveIdle(void)
1210 ; 684 {
1211 switch .text
1212 00a8 _dev_driveIdle:
1216 ; 685 }
1219 00a8 81 ret
1292 ; 687 MC_FuncRetVal_t dev_driveStartUpInit(void)
1292 ; 688 {
1293 switch .text
1294 00a9 _dev_driveStartUpInit:
1296 00a9 89 pushw x
1297 00000002 OFST: set 2
1300 ; 690 if (g_pBLDC_Struct->pBLDC_Var->hTarget_rotor_speed > 0)
1302 00aa 5f clrw x
1303 00ab 1f01 ldw (OFST-1,sp),x
1304 00ad 92ce03 ldw x,[_g_pBLDC_Struct.w]
1305 00b0 ee04 ldw x,(4,x)
1306 00b2 1301 cpw x,(OFST-1,sp)
1307 00b4 2d1e jrsle L564
1308 ; 692 BEMFSteps = BEMFSteps_CW;
1310 00b6 ae0094 ldw x,#_BEMFSteps_CW
1311 00b9 bf11 ldw _BEMFSteps,x
1312 ; 693 PhaseSteps = PhaseSteps_CW;
1314 00bb ae0004 ldw x,#_PhaseSteps_CW
1315 00be bf0d ldw _PhaseSteps,x
1316 ; 694 Fast_Demag_Steps = Fast_Demag_Steps_CW;
1318 00c0 ae0022 ldw x,#_Fast_Demag_Steps_CW
1319 00c3 bf0f ldw _Fast_Demag_Steps,x
1320 ; 697 LS_Steps = LS_Steps_CW;
1322 00c5 ae0040 ldw x,#_LS_Steps_CW
1323 00c8 bf09 ldw _LS_Steps,x
1324 ; 698 LS_Steps_SW = LS_Steps_SW_CW;
1326 00ca ae0046 ldw x,#_LS_Steps_SW_CW
1327 00cd bf0b ldw _LS_Steps_SW,x
1328 ; 702 bHallSteps = bHallSteps_CW;
1330 00cf ae012c ldw x,#_bHallSteps_CW
1332 00d2 201c jra L764
1333 00d4 L564:
1334 ; 707 BEMFSteps = BEMFSteps_CCW;
1336 00d4 ae00a0 ldw x,#_BEMFSteps_CCW
1337 00d7 bf11 ldw _BEMFSteps,x
1338 ; 708 PhaseSteps = PhaseSteps_CCW;
1340 00d9 ae0058 ldw x,#_PhaseSteps_CCW
1341 00dc bf0d ldw _PhaseSteps,x
1342 ; 709 Fast_Demag_Steps = Fast_Demag_Steps_CCW;
1344 00de ae0076 ldw x,#_Fast_Demag_Steps_CCW
1345 00e1 bf0f ldw _Fast_Demag_Steps,x
1346 ; 712 LS_Steps = LS_Steps_CCW;
1348 00e3 ae004c ldw x,#_LS_Steps_CCW
1349 00e6 bf09 ldw _LS_Steps,x
1350 ; 713 LS_Steps_SW = LS_Steps_SW_CCW;
1352 00e8 ae0052 ldw x,#_LS_Steps_SW_CCW
1353 00eb bf0b ldw _LS_Steps_SW,x
1354 ; 717 bHallSteps = bHallSteps_CCW;
1356 00ed ae0134 ldw x,#_bHallSteps_CCW
1357 00f0 L764:
1358 00f0 bf17 ldw _bHallSteps,x
1359 ; 721 StartUpStatus = STARTUP_BOOTSTRAP;
1361 00f2 35010000 mov L3_StartUpStatus,#1
1362 ; 722 vtimer_SetTimer(MTC_ALIGN_RAMP_TIMER,5,0);
1364 00f6 5f clrw x
1365 00f7 89 pushw x
1366 00f8 ae0005 ldw x,#5
1367 00fb 89 pushw x
1368 00fc a606 ld a,#6
1369 00fe cd0000 call _vtimer_SetTimer
1371 0101 5b04 addw sp,#4
1372 ; 724 return FUNCTION_ENDED;
1374 0103 a601 ld a,#1
1377 0105 85 popw x
1378 0106 81 ret
1420 ; 727 MC_FuncRetVal_t dev_driveStartUp(void)
1420 ; 728 {
1421 switch .text
1422 0107 _dev_driveStartUp:
1426 ; 729 switch (StartUpStatus)
1428 0107 b600 ld a,L3_StartUpStatus
1430 ; 817 break;
1431 0109 4a dec a
1432 010a 270f jreq L374
1433 010c 4a dec a
1434 010d 2756 jreq L574
1435 010f 4a dec a
1436 0110 275f jreq L774
1437 0112 4a dec a
1438 0113 2603cc019c jreq L105
1439 0118 cc01c2 jra L515
1440 ; 731 case STARTUP_IDLE:
1440 ; 732 break;
1442 011b L374:
1443 ; 734 case STARTUP_BOOTSTRAP:
1443 ; 735 if (BootStrap() == TRUE)
1445 011b cd08f8 call _BootStrap
1447 011e 4a dec a
1448 011f 26f7 jrne L515
1449 ; 737 Align_State = ALIGN_IDLE;
1451 0121 b716 ld _Align_State,a
1452 ; 745 TIM2_InitCapturePolarity();
1454 0123 cd056e call _TIM2_InitCapturePolarity
1456 ; 748 Current_Step = bHallStartStep;
1458 0126 b60c ld a,_bHallStartStep
1459 0128 b72e ld _Current_Step,a
1460 ; 749 TIM1->CCMR1 = PhaseSteps[Current_Step].CCMR_1;
1462 012a 97 ld xl,a
1463 012b a605 ld a,#5
1464 012d 42 mul x,a
1465 012e 92d60d ld a,([_PhaseSteps.w],x)
1466 0131 c75258 ld 21080,a
1467 ; 750 TIM1->CCMR2 = PhaseSteps[Current_Step].CCMR_2;
1469 0134 72bb000d addw x,_PhaseSteps
1470 0138 e601 ld a,(1,x)
1471 013a c75259 ld 21081,a
1472 ; 751 TIM1->CCMR3 = PhaseSteps[Current_Step].CCMR_3;
1474 013d b62e ld a,_Current_Step
1475 013f 97 ld xl,a
1476 0140 a605 ld a,#5
1477 0142 42 mul x,a
1478 0143 72bb000d addw x,_PhaseSteps
1479 0147 e602 ld a,(2,x)
1480 0149 c7525a ld 21082,a
1481 ; 752 TIM1->CCER1 = PhaseSteps[Current_Step].CCER_1;
1483 014c e603 ld a,(3,x)
1484 014e c7525c ld 21084,a
1485 ; 753 TIM1->CCER2 = PhaseSteps[Current_Step].CCER_2;
1487 0151 e604 ld a,(4,x)
1488 0153 c7525d ld 21085,a
1489 ; 755 Previous_Zero_Cross_Time = 0;
1491 0156 5f clrw x
1492 0157 bf22 ldw _Previous_Zero_Cross_Time,x
1493 ; 756 Z_Detection_Type = Z_DETECT_PWM_ON;
1495 0159 35010017 mov _Z_Detection_Type,#1
1496 ; 758 StartUpStatus = STARTUP_START;
1498 015d 35030000 mov L3_StartUpStatus,#3
1499 ; 760 first_cap = 0;
1501 0161 3f16 clr _first_cap
1502 0163 205d jra L515
1503 0165 L574:
1504 ; 764 case STARTUP_ALIGN:
1504 ; 765 if( AlignRotor() )
1506 0165 cd091c call _AlignRotor
1508 0168 4d tnz a
1509 0169 2757 jreq L515
1510 ; 767 StartUpStatus = STARTUP_START;
1512 016b 35030000 mov L3_StartUpStatus,#3
1513 016f 2051 jra L515
1514 0171 L774:
1515 ; 771 case STARTUP_START:
1515 ; 772 #ifdef SENSORLESS
1515 ; 773 MTC_Status |= MTC_STEP_MODE;
1515 ; 774 #endif
1515 ; 775 #ifdef HALL
1515 ; 776 MTC_Status |= MTC_STEP_MODE;
1517 0171 7210002b bset _MTC_Status,#0
1518 ; 778 MTC_Status &= (u8)(~(MTC_STARTUP_FAILED|MTC_OVER_CURRENT_FAIL|MTC_LAST_FORCED_STEP|MTC_MOTOR_STALLED));
1520 0175 b62b ld a,_MTC_Status
1521 0177 a4e1 and a,#225
1522 0179 b72b ld _MTC_Status,a
1523 ; 781 hTim3Th = 0;
1525 017b 5f clrw x
1526 017c bf1c ldw _hTim3Th,x
1527 ; 783 StartMotor();
1529 017e cd0a2f call _StartMotor
1531 ; 786 hTim3Cnt = 0;
1533 0181 5f clrw x
1534 0182 bf1a ldw _hTim3Cnt,x
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -