?? mtc.ls
字號:
2192 0197 c60004 ld a,_Rising_bemf
2193 019a b756 ld _MWGHT,a
2195 019c 206a jra L105
2196 019e L506:
2197 ; 851 else MWGHT = Falling_bemf;
2199 019e c60005 ld a,_Falling_bemf
2200 01a1 b756 ld _MWGHT,a
2201 01a3 2063 jra L105
2202 01a5 L575:
2203 ; 858 if (MotorStatus & LAST_FORCED_SWITCH)// End of switched mode without Z
2205 01a5 050912 btjf _MotorStatus,#2,L316
2206 ; 864 MCOMP = U8_MAX; // Wait for Z event (no possibility to have C event)
2208 01a8 a6ff ld a,#255
2209 01aa b754 ld _MCOMP,a
2210 ; 866 MotorStatus &= ((u8)(~LAST_FORCED_SWITCH));
2212 01ac 1509 bres _MotorStatus,#2
2213 ; 867 MotorStatus |= FIRST_AUTO_SWITCH;
2215 01ae 1209 bset _MotorStatus,#1
2216 ; 868 MWGHT = TRANSITION_DELAY; //set to 255/256 on first autoswitch step
2218 01b0 b756 ld _MWGHT,a
2219 ; 869 MCRA |= SWA_MSK; // Enable Autoswitched mode and compute delay on MZPRV
2221 01b2 145a bset _MCRA,#2
2222 ; 870 MIMR = ((u8)(RIM_MSK + EIM_MSK + CIM_MSK + ZIM_MSK + DIM_MSK + CLIM_MSK));//...relevant int
2224 01b4 a63f ld a,#63
2225 01b6 b758 ld _MIMR,a
2227 01b8 204e jra L105
2228 01ba L316:
2229 ; 875 MCOMP = RAMP[RampIndex].StepTime;
2231 01ba be03 ld x,L332_RampIndex
2232 01bc 58 sll x
2233 01bd d60036 ld a,(_RAMP+1,x)
2234 01c0 b754 ld _MCOMP,a
2235 ; 879 RampIndex++; // Next step on the acceleration ramp
2237 01c2 3c03 inc L332_RampIndex
2238 ; 880 UpdateRatio(); // Prepare updation of MTIM prescaler on next C event
2240 01c4 b657 ld a,_MPRSR
2241 01c6 a40f and a,#15
2242 01c8 96 ld x,s
2243 01c9 d70101 ld (OFST-1,x),a
2244 01cc be03 ld x,L332_RampIndex
2245 01ce 58 sll x
2246 01cf d60035 ld a,(_RAMP,x)
2247 01d2 96 ld x,s
2248 01d3 d10101 cp a,(OFST-1,x)
2249 01d6 2604 jrne L45
2250 01d8 3f59 clr _MISR
2251 01da 2004 jra L65
2252 01dc L45:
2253 01dc a620 ld a,#32
2254 01de b759 ld _MISR,a
2255 01e0 L65:
2256 01e0 b659 ld a,_MISR
2257 01e2 5f clr x
2258 ; 883 if (RampIndex >= (RAMP_SIZE-1)) // If Ramp is finished without success
2260 01e3 b603 ld a,L332_RampIndex
2261 01e5 a13f cp a,#63
2262 01e7 2506 jrult L716
2263 ; 885 MTC_DisableOutputs();
2265 01e9 1f5a bres _MCRA,#7
2266 ; 886 MTC_DisableClock();
2268 01eb 1d5a bres _MCRA,#6
2269 ; 887 MotorStatus |= START_UP_FAILED;
2271 01ed 1c09 bset _MotorStatus,#6
2272 01ef L716:
2273 ; 891 if (RampIndex == bemf_blank) // Z event masking window is finished
2275 01ef a104 cp a,#4
2276 01f1 2602 jrne L126
2277 ; 893 SetBit(MIMR,ZIM); // Enable Z event interrupts
2279 01f3 1458 bset _MIMR,#2
2280 01f5 L126:
2281 ; 897 if ((BemfCounter != 0) // If there was a Z event...
2281 ; 898 && (BemfCounter == (u8)(CeventCounter+1))) // ... since last C
2283 01f5 3d04 tnz L132_BemfCounter
2284 01f7 270b jreq L326
2286 01f9 b605 ld a,L722_CeventCounter
2287 01fb 4c inc a
2288 01fc b104 cp a,L132_BemfCounter
2289 01fe 2604 jrne L326
2290 ; 900 CeventCounter++;
2292 0200 3c05 inc L722_CeventCounter
2294 0202 2004 jra L105
2295 0204 L326:
2296 ; 904 CeventCounter = 0;
2298 0204 3f05 clr L722_CeventCounter
2299 ; 905 BemfCounter = 0;
2301 0206 3f04 clr L132_BemfCounter
2302 0208 L105:
2303 ; 913 if(MISR & DI_MSK)
2305 0208 035904 btjf _MISR,#1,L726
2306 ; 917 MISR = ((u8)~(DI_MSK));
2308 020b a6fd ld a,#253
2309 020d b759 ld _MISR,a
2310 020f L726:
2311 ; 945 }
2314 020f 84 pop a
2315 0210 84 pop a
2316 0211 84 pop a
2317 0212 b700 ld c_y,a
2318 0214 84 pop a
2319 0215 b701 ld c_y+1,a
2320 0217 9085 pop y
2321 0219 80 iret
2364 ; 966 void MTC_R_Z_IT(void)
2364 ; 967 {
2365 .text: section .text,new
2366 0000 _MTC_R_Z_IT:
2368 0000 9089 push y
2369 0002 b601 ld a,c_x+1
2370 0004 88 push a
2371 0005 b600 ld a,c_x
2372 0007 88 push a
2373 0008 b601 ld a,c_y+1
2374 000a 88 push a
2375 000b b600 ld a,c_y
2376 000d 88 push a
2379 ; 969 if (MISR & ZI_MSK)
2381 000e 045903cc00d0 btjf _MISR,#2,L146
2382 ; 971 MISR = ((u8)~ZI_MSK); // Reset Z mask
2384 0014 a6fb ld a,#251
2385 0016 b759 ld _MISR,a
2386 ; 973 if (MotorStatus & AUTO_SWITCH)
2388 0018 000903cc00b7 btjf _MotorStatus,#0,L346
2389 ; 975 if ( (!ValBit(Flag_MTC,SWITCH_TO_VOLTAGE_PWMON)) && (Get_CurrentTargetSpeed() >= Freq_Switch_Mode) )
2391 001e c60008 ld a,_Flag_MTC
2392 0021 a501 bcp a,#1
2393 0023 2632 jrne L546
2395 0025 cd0000 call _Get_CurrentTargetSpeed
2397 0028 a040 sub a,#64
2398 002a 9f ld a,x
2399 002b a206 sbc a,#6
2400 002d 2528 jrult L546
2401 ; 977 SetBit(Flag_MTC,SWITCH_TO_VOLTAGE_PWMON);
2403 002f c60008 ld a,_Flag_MTC
2404 0032 aa01 or a,#1
2405 0034 c70008 ld _Flag_MTC,a
2406 ; 986 SET_MTC_PAGE(1);
2408 0037 1e5f bset _MCFR,#7
2409 ; 987 MCONF = mem_MCONF_Ontime;
2411 0039 a622 ld a,#34
2412 003b b753 ld _MCONF,a
2413 ; 988 SET_MTC_PAGE(0);
2415 003d 1f5f bres _MCFR,#7
2416 ; 989 MCRC = mem_MCRC_Ontime;
2418 003f a64f ld a,#79
2419 0041 b75c ld _MCRC,a
2420 ; 990 PDDDR |= 0x0d; //PD0,PD2,PD3 push pull output
2422 0043 b600 ld a,_PDDDR
2423 0045 aa0d or a,#13
2424 0047 b700 ld _PDDDR,a
2425 ; 991 PDOR |= 0x0d;
2427 0049 b600 ld a,_PDOR
2428 004b aa0d or a,#13
2429 004d b700 ld _PDOR,a
2430 ; 992 PDDR &= 0xf2; //PD0,PD2,PD3 = 0
2432 004f b600 ld a,_PDDR
2433 0051 a4f2 and a,#242
2434 0053 b700 ld _PDDR,a
2436 0055 2031 jra L746
2437 0057 L546:
2438 ; 997 else if ( (ValBit(Flag_MTC,SWITCH_TO_VOLTAGE_PWMON)) && (Get_CurrentTargetSpeed() < Freq_Switch_Mode) )
2440 0057 c60008 ld a,_Flag_MTC
2441 005a a501 bcp a,#1
2442 005c 272a jreq L746
2444 005e cd0000 call _Get_CurrentTargetSpeed
2446 0061 a040 sub a,#64
2447 0063 9f ld a,x
2448 0064 a206 sbc a,#6
2449 0066 2420 jruge L746
2450 ; 999 ClrBit(Flag_MTC,SWITCH_TO_VOLTAGE_PWMON);
2452 0068 c60008 ld a,_Flag_MTC
2453 006b a4fe and a,#254
2454 006d c70008 ld _Flag_MTC,a
2455 ; 1006 SET_MTC_PAGE(1);
2457 0070 1e5f bset _MCFR,#7
2458 ; 1007 MCONF = mem_MCONF;
2460 0072 a602 ld a,#2
2461 0074 b753 ld _MCONF,a
2462 ; 1008 SET_MTC_PAGE(0);
2464 0076 1f5f bres _MCFR,#7
2465 ; 1009 MCRC = mem_MCRC;
2467 0078 a643 ld a,#67
2468 007a b75c ld _MCRC,a
2469 ; 1010 PDDDR &= 0xf2; //PD0,PD2,PD3 floating Input
2471 007c b600 ld a,_PDDDR
2472 007e a4f2 and a,#242
2473 0080 b700 ld _PDDDR,a
2474 ; 1011 PDOR &= 0xf2;
2476 0082 b600 ld a,_PDOR
2477 0084 a4f2 and a,#242
2478 0086 b700 ld _PDOR,a
2479 0088 L746:
2480 ; 1017 if (MZREG>=0x5) // check MZREG value to keep good accuracy
2482 0088 b653 ld a,_MZREG
2483 008a a105 cp a,#5
2484 008c 251b jrult L356
2485 ; 1019 Step_Z[Step_Z_Counter].Ratio = (u8)(MPRSR & 0x0f); // update Z steptime buffer for PI regulation
2487 008e b657 ld a,_MPRSR
2488 0090 a40f and a,#15
2489 0092 be00 ld x,L142_Step_Z_Counter
2490 0094 58 sll x
2491 0095 d70000 ld (_Step_Z,x),a
2492 ; 1020 Step_Z[Step_Z_Counter].StepTime = MZREG; // & motor frequency computation
2494 0098 b653 ld a,_MZREG
2495 009a d70001 ld (_Step_Z+1,x),a
2496 ; 1022 if (Step_Z_Counter >= STEP_Z_BUFFER_SIZE-1) Step_Z_Counter = 0;
2498 009d b600 ld a,L142_Step_Z_Counter
2499 009f a105 cp a,#5
2500 00a1 2504 jrult L556
2503 00a3 3f00 clr L142_Step_Z_Counter
2505 00a5 2002 jra L356
2506 00a7 L556:
2507 ; 1023 else Step_Z_Counter++;
2509 00a7 3c00 inc L142_Step_Z_Counter
2510 00a9 L356:
2511 ; 1026 if (Step_counter != 0) Step_counter --;
2513 00a9 c60006 ld a,L342_Step_counter
2514 00ac 2722 jreq L146
2517 00ae c60006 ld a,L342_Step_counter
2518 00b1 4a dec a
2519 00b2 c70006 ld L342_Step_counter,a
2520 00b5 2019 jra L146
2521 00b7 L346:
2522 ; 1030 BemfCounter++;
2524 00b7 3c04 inc L132_BemfCounter
2525 ; 1031 if (BemfCounter == bemf_valid) //Transition switched->autoswitched
2527 00b9 b604 ld a,L132_BemfCounter
2528 00bb a102 cp a,#2
2529 00bd 2611 jrne L146
2530 ; 1033 if (MZREG <= (U8_MAX/2)) // No overflow when multiply
2532 00bf b653 ld a,_MZREG
2533 00c1 a180 cp a,#128
2534 00c3 2405 jruge L766
2535 ; 1036 MCOMP = (u8)(MZREG * 2);
2537 00c5 b653 ld a,_MZREG
2538 00c7 48 sll a
2540 00c8 2002 jra L176
2541 00ca L766:
2542 ; 1038 else MCOMP = U8_MAX-1; // Not correct: step not centered
2544 00ca a6fe ld a,#254
2545 00cc L176:
2546 00cc b754 ld _MCOMP,a
2547 ; 1039 MotorStatus |= LAST_FORCED_SWITCH; // Last switched mode step
2549 00ce 1409 bset _MotorStatus,#2
2550 00d0 L146:
2551 ; 1046 if (MISR & RPI_MSK)
2553 00d0 0d5910 btjf _MISR,#6,L376
2554 ; 1048 MISR = ((u8)~(RMI_MSK + RPI_MSK));
2556 00d3 a69f ld a,#159
2557 00d5 b759 ld _MISR,a
2558 ; 1060 if (RPICounter !=0)
2560 00d7 3d08 tnz L322_RPICounter
2561 00d9 2708 jreq L376
2562 ; 1062 RPICounter --;
2564 00db 3a08 dec L322_RPICounter
2565 ; 1063 if (RPICounter == 0) MDREG = (u8) SoftDemagTime;
2567 00dd 2604 jrne L376
2570 00df b607 ld a,L522_SoftDemagTime+1
2571 00e1 b755 ld _MDREG,a
2572 00e3 L376:
2573 ; 1070 if (MISR & RMI_MSK)
2575 00e3 0b590c btjf _MISR,#5,L107
2576 ; 1072 MISR = ((u8)~(RMI_MSK + RPI_MSK));
2578 00e6 a69f ld a,#159
2579 00e8 b759 ld _MISR,a
2580 ; 1073 SetBit(Flag_it,RM_EVT);
2582 00ea c60005 ld a,L542_Flag_it
2583 00ed aa04 or a,#4
2584 00ef c70005 ld L542_Flag_it,a
2585 00f2 L107:
2586 ; 1075 }
2589 00f2 84 pop a
2590 00f3 b700 ld c_y,a
2591 00f5 84 pop a
2592 00f6 b701 ld c_y+1,a
2593 00f8 84 pop a
2594 00f9 b700 ld c_x,a
2595 00fb 84 pop a
2596 00fc b701 ld c_x+1,a
2597 00fe 9085 pop y
2598 0100 80 iret
2623 ; 1094 void MCES_SE_IT(void)
2623 ; 1095 {
2624 .text: section .text,new
2625 0000 _MCES_SE_IT:
2627 0000 9089 push y
2628 0002 b601 ld a,c_x+1
2629 0004 88 push a
2630 0005 b600 ld a,c_x
2631 0007 88 push a
2632 0008 b601 ld a,c_y+1
2
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -