?? mtc.ls
字號:
1251 ; 478 MCPUL = 0; // 0% duty cycle on U Channel
1253 002f 3f68 clr _MCPUL
1254 ; 479 MCPUH = 0;
1256 0031 3f67 clr _MCPUH
1257 ; 485 MCPVL = 0; // 0% duty cycle on V Channel
1259 0033 3f66 clr _MCPVL
1260 ; 486 MCPVH = 0;
1262 0035 3f65 clr _MCPVH
1263 ; 489 MCRC = mem_MCRC;
1265 0037 a643 ld a,#67
1266 0039 b75c ld _MCRC,a
1267 ; 491 MCFR = mem_MCFR;
1269 003b a609 ld a,#9
1270 003d b75f ld _MCFR,a
1271 ; 492 MDFR = mem_MDFR;
1273 003f a613 ld a,#19
1274 0041 b75e ld _MDFR,a
1275 ; 497 MREF &= (u8)(~CFAV_MASK); // No Chopper, OAZ input
1277 0043 1b60 bres _MREF,#5
1278 ; 500 MotorStatus = 0; // Needed to manage switched to autoswitched transition
1280 0045 3f09 clr _MotorStatus
1281 ; 502 ClrBit(Flag_MTC,SWITCH_TO_VOLTAGE_PWMON);
1283 0047 c60008 ld a,_Flag_MTC
1284 004a a4fe and a,#254
1285 004c c70008 ld _Flag_MTC,a
1286 ; 503 PDDDR &= 0xf2; //PD0,PD2,PD3 floating Input
1288 004f b600 ld a,_PDDDR
1289 0051 a4f2 and a,#242
1290 0053 b700 ld _PDDDR,a
1291 ; 504 PDOR &= 0xf2;
1293 0055 b600 ld a,_PDOR
1294 0057 a4f2 and a,#242
1295 0059 b700 ld _PDOR,a
1296 ; 505 }
1299 005b 81 ret
1359 ; 518 BOOL MTC_StartMotor(void)
1359 ; 519 {
1360 .text: section .text,new
1362 xref.b _MTC_StartMotor$L
1363 0000 _MTC_StartMotor:
1366 ; 520 switch (Status_Start)
1368 0000 c60002 ld a,_Status_Start
1371 0003 270c jreq L314
1372 0005 4a dec a
1373 0006 2603cc0095 jreq L514
1374 000b 4a dec a
1375 000c 2603cc009a jreq L714
1376 0011 L314:
1377 ; 522 default:
1377 ; 523 case INIT_START:
1377 ; 524 MTC_InitPeripheral(); // reset the peripheral when restarting
1379 0011 cd0000 call _MTC_InitPeripheral
1381 ; 526 BemfCounter = 0; // Counts Bemf before autoswitched mode
1383 0014 3f04 clr L132_BemfCounter
1384 ; 527 CeventCounter = 0; // Needed to be sure that Bemf regularly occurs
1386 0016 3f05 clr L722_CeventCounter
1387 ; 528 RPICounter = 0; // When we have to wait until one or several R+
1389 0018 3f08 clr L322_RPICounter
1390 ; 529 SoftDemagTime = 0;
1392 001a 3f06 clr L522_SoftDemagTime
1393 001c 3f07 clr L522_SoftDemagTime+1
1394 ; 530 StepIndex = 0; // Alignment step is the first of the table
1396 001e 3f02 clr L532_StepIndex
1397 ; 531 RampIndex = 0; // To get the ramp's first step ratio
1399 0020 3f03 clr L332_RampIndex
1400 ; 532 delay_counter = 0; //counter to manage delay at start_up
1402 0022 3f01 clr L732_delay_counter
1403 ; 533 Flag_it = 0;
1405 0024 4f clr a
1406 0025 c70005 ld L542_Flag_it,a
1407 ; 534 Power_Motor_Status &= Heat_Voltage_Failure; // reset all flags except overtemp & overvoltage
1409 0028 c60007 ld a,_Power_Motor_Status
1410 002b a405 and a,#5
1411 002d c70007 ld _Power_Motor_Status,a
1412 ; 535 Step_Z_Counter = 0;
1414 0030 3f00 clr L142_Step_Z_Counter
1415 ; 536 Step_counter = Z_event_for_PI; //counter use to validate PI after we pass in autoswitch
1417 0032 a60c ld a,#12
1418 0034 c70006 ld L342_Step_counter,a
1419 ; 537 Freq_Motor = 0;
1421 0037 4f clr a
1422 0038 c70000 ld _Freq_Motor,a
1423 003b c70001 ld _Freq_Motor+1,a
1424 ; 538 Set_CurrentTargetSpeed(Start_Freq);
1426 003e a6bc ld a,#188
1427 0040 ae02 ld x,#2
1428 0042 cd0000 call _Set_CurrentTargetSpeed
1430 ; 540 timer_after_start=1000;
1432 0045 ae03 ld x,#3
1433 0047 cf0000 ld _timer_after_start,x
1434 004a a6e8 ld a,#232
1435 004c c70001 ld _timer_after_start+1,a
1436 ; 542 Init_PI();
1438 004f cd0000 call _Init_PI
1440 ; 547 OPAMP_InitOffset(LOW_GAIN); // initialise Opamp Gain and Offset compensation
1442 0052 4f clr a
1443 0053 cd0000 call _OPAMP_InitOffset
1445 ; 552 MIMR = 0;
1447 0056 3f58 clr _MIMR
1448 ; 553 MPRSR = (u8)(mem_MPRSR + Align_Ratio); // MTIM timer prescaler set-up
1450 0058 a698 ld a,#152
1451 005a b757 ld _MPRSR,a
1452 ; 555 MPHST = 0; // All switches OFF
1454 005c 3f5d clr _MPHST
1455 ; 556 MCRB = 0;
1457 005e 3f5b clr _MCRB
1458 ; 558 MWGHT = STARTUP_DELAY; // Delay Coefficient in switched mode
1460 0060 a6ff ld a,#255
1461 0062 b756 ld _MWGHT,a
1462 ; 559 MCOMP = (u8)(Align_MCOMP); // Load Alignment time
1464 0064 a69c ld a,#156
1465 0066 b754 ld _MCOMP,a
1466 ; 561 MDREG = DEMAG_TIME_C[(MPRSR & 0x0f)]; // load demagnetization time according
1468 0068 b657 ld a,_MPRSR
1469 006a a40f and a,#15
1470 006c 97 ld x,a
1471 006d d60015 ld a,(_DEMAG_TIME_C,x)
1472 0070 b755 ld _MDREG,a
1473 ; 568 MTC_EnableDirectAccess();
1475 0072 185a bset _MCRA,#4
1476 ; 569 MTC_EnableOutputs();
1478 0074 1e5a bset _MCRA,#7
1479 ; 571 RefreshBootstrap(); // To be sure high side driver correctly supplied
1481 0076 cd0000 call L352_RefreshBootstrap
1483 ; 573 MTC_EnableClock();
1485 0079 1c5a bset _MCRA,#6
1486 ; 574 MPHST = MCIC + START_POSITION; // Alignment step pattern T1+T4+T6
1488 007b a6a9 ld a,#169
1489 007d b75d ld _MPHST,a
1490 ; 575 MTC_DisableDirectAccess();
1492 007f 195a bres _MCRA,#4
1493 ; 576 Align_Index = 0;
1495 0081 4f clr a
1496 0082 c70003 ld L152_Align_Index,a
1497 ; 577 Status_Start = ALIGN_ON_GOING;
1499 0085 4c inc a
1500 0086 c70002 ld _Status_Start,a
1501 ; 578 AlignState = WAIT_FOR_C;
1503 0089 4f clr a
1504 008a c70001 ld _AlignState,a
1505 ; 580 MISR = 0;//EI_MSK;
1507 008d 3f59 clr _MISR
1508 ; 581 MIMR = EIM_MSK; // enable E interruper
1510 008f a608 ld a,#8
1511 0091 b758 ld _MIMR,a
1512 ; 583 return(FALSE);
1514 0093 4f clr a
1517 0094 81 ret
1518 0095 L514:
1519 ; 586 case ALIGN_ON_GOING:
1519 ; 587 AlignRotor(); // Ramp up the alignment current
1522 0095 cd0000 call L552_AlignRotor
1524 ; 588 return(FALSE);
1526 0098 4f clr a
1529 0099 81 ret
1530 009a L714:
1531 ; 591 case INIT_SWITCHED_MODE:
1531 ; 592 #if (DRIVING_MODE == VOLTAGE_MODE)
1531 ; 593 MCPUL = ramp_MCPUL; // Set duty cycle for ramp up
1531 ; 594 MCPUH = ramp_MCPUH;
1531 ; 595 #else
1531 ; 596 MCPVL = ramp_MCPVL; // set current for ramp up
1534 009a a666 ld a,#102
1535 009c b766 ld _MCPVL,a
1536 ; 597 MCPVH = ramp_MCPVH;
1538 009e a62a ld a,#42
1539 00a0 b765 ld _MCPVH,a
1540 ; 600 MTC_DisableClock(); // force 1st ramp ratio value update into MPRSR
1542 00a2 1d5a bres _MCRA,#6
1543 ; 601 MPRSR = (u8)((MPRSR & 0xf0) + RAMP[RampIndex].Ratio); // MTIM timer prescaler set-up
1545 00a4 b657 ld a,_MPRSR
1546 00a6 a4f0 and a,#240
1547 00a8 be03 ld x,L332_RampIndex
1548 00aa 58 sll x
1549 00ab db0035 add a,(_RAMP,x)
1550 00ae b757 ld _MPRSR,a
1551 ; 603 MTC_EnableClock();
1553 00b0 1c5a bset _MCRA,#6
1554 ; 605 StepIndex = 1; // Point to next step configuration
1556 00b2 a601 ld a,#1
1557 00b4 b702 ld L532_StepIndex,a
1558 ; 606 RampIndex = 1; // Alignment completed, prepare the second step of the ramp
1560 00b6 b703 ld L332_RampIndex,a
1561 ; 607 UpdateRatio(); // Prepare updation of MTIM prescaler on next C event
1563 00b8 b657 ld a,_MPRSR
1564 00ba a40f and a,#15
1565 00bc b7ff ld _MTC_StartMotor$L-1,a
1566 00be be03 ld x,L332_RampIndex
1567 00c0 58 sll x
1568 00c1 d60035 ld a,(_RAMP,x)
1569 00c4 b1ff cp a,_MTC_StartMotor$L-1
1570 00c6 2607 jrne L22
1571 00c8 3f59 clr _MISR
1572 00ca b659 ld a,_MISR
1573 00cc 5f clr x
1574 00cd 2006 jra L42
1575 00cf L22:
1576 00cf a620 ld a,#32
1577 00d1 b759 ld _MISR,a
1578 00d3 b659 ld a,_MISR
1579 00d5 L42:
1580 ; 609 MPHST = PHASE_CONFIG[StepIndex]; // Preload active phase on next C event
1582 00d5 be02 ld x,L532_StepIndex
1583 00d7 d60003 ld a,(_PHASE_CONFIG,x)
1584 00da b75d ld _MPHST,a
1585 ; 611 MCRB = (u8)((ZC_DEMAG_PWM[StepIndex] & Reset_H_SDM_MASK) + SDM_MSK); // Expected Bemf edge, Demag type and PWM behaviour
1587 00dc d60009 ld a,(_ZC_DEMAG_PWM,x)
1588 00df a44f and a,#79
1589 00e1 ab10 add a,#16
1590 00e3 b75b ld _MCRB,a
1591 ; 615 StepIndex++; // This is to load the next step config
1593 00e5 3c02 inc L532_StepIndex
1594 ; 620 MIMR = ((u8)CIM_MSK + DIM_MSK + EIM_MSK); // enable C & D & E interrupt to start commutation mechanism and motor
1596 00e7 a60b ld a,#11
1597 00e9 b758 ld _MIMR,a
1598 ; 623 Status_Start = INIT_START;
1600 00eb 4f clr a
1601 00ec c70002 ld _Status_Start,a
1602 ; 624 BrakeState = BRAKE_START;
1604 00ef c70000 ld _BrakeState,a
1605 ; 625 return(TRUE);
1607 00f2 4c inc a
1610 00f3 81 ret
1611 ; 628 return(FALSE);
1645 ; 640 void MTC_StopMotor(void)
1645 ; 641 {
1646 .text: section .text,new
1647 0000 _MTC_StopMotor:
1650 ; 642 MIMR = 0; // Mask all MTC related interrupts
1652 0000 3f58 clr _MIMR
1653 ; 643 MCRA &= (u8)(~SWA_MSK); // Disable Autoswitched in previously enabled
1655 0002 155a bres _MCRA,#2
1656 ; 649 MCPVL = 0; // Set PWM V to 0%
1658 0004 3f66 clr _MCPVL
1659 ; 650 MCPVH = 0;
1661 0006 3f65 clr _MCPVH
1662 ; 652 MTC_EnableDirectAccess();
1664 0008 185a bset _MCRA,#4
1665 ; 653 MPHST = 0; // Switch off all drivers
1667 000a 3f5d clr _MPHST
1668 ; 654 MTC_DisableDirectAccess();
1670 000c 195a bres _MCRA,#4
1671 ; 655 MTC_DisableClock();
1673 000e 1d5a bres _MCRA,#6
1674 ; 656 MotorStatus &= FAULT_MSK;
1676 0010 b609 ld a,_MotorStatus
1677 0012 a4f0 and a,#240
1678 0014 b709 ld _MotorStatus,a
1679 ; 657 Status_Start = INIT_START;
1681 0016 4f clr a
1682 0017 c70002 ld _Status_Start,a
1683 ; 658 BrakeState = BRAKE_START;
1685 001a c70000 ld _BrakeState,a
1686 ; 659 Freq_Motor = 0;
1688 001d c70000 ld _Freq_Motor,a
1689 0020 c70001 ld _Freq_Motor+1,a
1690 ; 660 }
1693 0023 81 ret
1721 ; 675 void MTC_U_CL_SO_IT(void)
1721 ; 676 {
1722 .text: section .text,new
1723 0000 _MTC_U_CL_SO_IT:
1727 ; 677 if (MISR & PUI_MSK)
1729 0000 0f5904 btjf _MISR,#7,L554
1730 ; 679 MISR = ((u8)~(PUI_MSK));
1732 0003 a67f ld a,#127
1733 0005 b759 ld _MISR,a
1734 0007 L554:
1735 ; 681 if (MISR & CLI_MSK)
1737 0007 095913 btjf _MISR,#4,L754
1738 ; 683 MIMR &= ((u8)~(CLIM_MSK)); // disable CL int
1740 000a 1958 bres _MIMR,#4
1741 ; 684 MISR = ((u8)~(CLI_MSK));
1743 000c a6ef ld a,#239
1744 000e b759 ld _MISR,a
1745 ; 685 SetBit(Power_Motor_Status,OverCurrent);
1747 0010 c60007 ld a,_Power_Motor_Status
1748 0013 aa02 or a,#2
1749 0015 c70007 ld _Power_Motor_Status,a
1750 ; 686 timer_CL_10ms = 30; // 300 ms temporisation
1752 0018 a61e ld a,#30
1753 001a c70000 ld _timer_CL_10ms,a
1754 001d L754:
1755 ; 689 SET_MTC_PAGE(1);
1757 001d 1e5f bset _MCFR,#7
1758 ; 690 if (MCONF & SOI_MSK)
1760 001f 075302 btjf _MCONF,#3,L164
1761 ; 692 MCONF &= ((u8)~(SOI_MSK));
1763 0022 1753 bres _MCONF,#3
1764 0024 L164:
1765 ; 694 SET_MTC_PAGE(0);
1767 0024 1f5f bres _MCFR,#7
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -