📄 mtc.ls
字号:
3928 ; 882 void MTC_U_CL_SO_IT(void)
3928 ; 883 {
3929 switch .text
3930 0433 _MTC_U_CL_SO_IT:
3934 ; 885 push Y
3937 0433 9089 push Y
3939 ; 886 ;********************* Integrate frequency into phase **************************
3942 ;********************* Integrate frequency into phase **************************
3944 ; 887 btjf _MTCStatus,#0,CalcPhase
3947 0435 01100a btjf _MTCStatus,#0,CalcPhase
3949 ; 888 ld A,_SineFreqBuf+1
3952 0438 b613 ld A,_SineFreqBuf+1
3954 ; 889 ld _SineFreq+1,A
3957 043a b715 ld _SineFreq+1,A
3959 ; 890 ld A,_SineFreqBuf
3962 043c b612 ld A,_SineFreqBuf
3964 ; 891 ld _SineFreq,A
3967 043e b714 ld _SineFreq,A
3969 ; 892 bres _MTCStatus,#0
3972 0440 1110 bres _MTCStatus,#0
3974 ; 894 CalcPhase:
3977 0442 CalcPhase:
3979 ; 895 ld A,_Phase+1
3982 0442 b60f ld A,_Phase+1
3984 ; 896 add A,_SineFreq+1
3987 0444 bb15 add A,_SineFreq+1
3989 ; 897 ld _Phase+1,A
3992 0446 b70f ld _Phase+1,A
3994 ; 898 ld A,_Phase
3997 0448 b60e ld A,_Phase
3999 ; 899 adc A,_SineFreq
4002 044a b914 adc A,_SineFreq
4004 ; 900 ld _Phase,A ; 16-bit accumulation of FreqCmd into Phase
4007 044c b70e ld _Phase,A
4009 ; 902 ;********************* PHASE U duty cycle processing ***************************
4012 ;********************* PHASE U duty cycle processing ***************************
4014 ; 903 ld Y,A ; Load LUT pointer in Y
4017 044e 9097 ld Y,A
4019 ; 904 ld A,(_SINE3RDHARM,Y) ; Get entry from table
4022 0450 90d60000 ld A,(_SINE3RDHARM,Y)
4024 ; 905 ld X,_SineMag ; Scale According to SineMag
4027 0454 be16 ld X,_SineMag
4029 ; 906 mul X,A ; 16-bit Result in X:A
4032 0456 42 mul X,A
4034 ; 907 btjt _Phase,#7,nextU ; Phase represents offset in LUT
4037 0457 0e0e05 btjt _Phase,#7,nextU
4039 ; 908 ; jmp if entry is positive, first half of table
4042 ; jmp if entry is positive, first half of table
4044 ; 909 cpl X ; Otherwise negate result
4047 045a 53 cpl X
4049 ; 910 neg A
4052 045b 40 neg A
4054 ; 911 jrne nextU
4057 045c 2601 jrne nextU
4059 ; 912 inc X ; Increase MSB if 2_s complement of A is 100
4062 045e 5c inc X
4064 ; 913 nextU:
4067 045f nextU:
4069 ; 918 sra X
4072 045f 57 sra X
4074 ; 919 rrc A
4077 0460 46 rrc A
4079 ; 920 sra X
4082 0461 57 sra X
4084 ; 921 rrc A
4087 0462 46 rrc A
4089 ; 922 sra X
4092 0463 57 sra X
4094 ; 923 rrc A ; match 10 bit pwm scaling
4097 0464 46 rrc A
4099 ; 925 ld _MCPUL,A ; Load LSB of PWM generator
4102 0465 b768 ld _MCPUL,A
4104 ; 926 ld A,X
4107 0467 9f ld A,X
4109 ; 927 add A,#_OFFSET ; add in zero offset to MSB
4112 0468 ab0a add A,#_OFFSET
4114 ; 928 ld _MCPUH,A ; Load MSB of PWM generator
4117 046a b767 ld _MCPUH,A
4119 ; 930 ;********************* PHASE V duty cycle processing ***************************
4122 ;********************* PHASE V duty cycle processing ***************************
4124 ; 931 ld A,Y ; Get LUT pointer
4127 046c 909f ld A,Y
4129 ; 932 add A,_PhaseShift ; Calc Phase V angle: advance or retard +/-Phaseshift degrees
4132 046e bb11 add A,_PhaseShift
4134 ; 933 ld Y,A ; Y is now index for V
4137 0470 9097 ld Y,A
4139 ; 934 ld A,(_SINE3RDHARM,Y) ; Get entry from table
4142 0472 90d60000 ld A,(_SINE3RDHARM,Y)
4144 ; 935 ld X,_SineMag ; Scale According to SineMag
4147 0476 be16 ld X,_SineMag
4149 ; 936 mul X,A ; 16-bit Result in X:A
4152 0478 42 mul X,A
4154 ; 938 tnz Y ; Test sign of LUT pointer
4157 0479 905d tnz Y
4159 ; 939 jrmi nextV ; Jmp if entry is negative, first half of table
4162 047b 2b05 jrmi nextV
4164 ; 940 cpl X ; Otherwise negate result
4167 047d 53 cpl X
4169 ; 941 neg A
4172 047e 40 neg A
4174 ; 942 jrne nextV
4177 047f 2601 jrne nextV
4179 ; 943 inc X ; Increase MSB if 2_s complement of A is 100
4182 0481 5c inc X
4184 ; 944 nextV:
4187 0482 nextV:
4189 ; 949 sra X
4192 0482 57 sra X
4194 ; 950 rrc A
4197 0483 46 rrc A
4199 ; 951 sra X
4202 0484 57 sra X
4204 ; 952 rrc A
4207 0485 46 rrc A
4209 ; 953 sra X
4212 0486 57 sra X
4214 ; 954 rrc A ; match 10 bit pwm scaling
4217 0487 46 rrc A
4219 ; 956 ld _MCPVL,A ; Load LSB of PWM generator
4222 0488 b766 ld _MCPVL,A
4224 ; 957 ld A,X
4227 048a 9f ld A,X
4229 ; 958 add A,#_OFFSET ; add in zero offset to MSB
4232 048b ab0a add A,#_OFFSET
4234 ; 959 ld _MCPVH,A ; Load MSB of PWM generator
4237 048d b765 ld _MCPVH,A
4239 ; 961 ;********************* PHASE W duty cycle processing ***************************
4242 ;********************* PHASE W duty cycle processing ***************************
4244 ; 962 ld A,_Phase ; Get LUT pointer
4247 048f b60e ld A,_Phase
4249 ; 963 add A,_PhaseShift
4252 0491 bb11 add A,_PhaseShift
4254 ; 964 add A,_PhaseShift ; Calc Phase W angle: advance or retard 2x(+/-Phaseshift) degrees
4257 0493 bb11 add A,_PhaseShift
4259 ; 965 ld Y,A ; Y is now index for V
4262 0495 9097 ld Y,A
4264 ; 966 ld A,(_SINE3RDHARM,Y) ; Get entry from table
4267 0497 90d60000 ld A,(_SINE3RDHARM,Y)
4269 ; 967 ld X,_SineMag ; Scale According to SineMag
4272 049b be16 ld X,_SineMag
4274 ; 968 mul X,A ; 16-bit Result in X:A
4277 049d 42 mul X,A
4279 ; 970 tnz Y ; Test sign of LUT pointer
4282 049e 905d tnz Y
4284 ; 971 jrmi nextW ; Jmp if entry is negative, first half of table
4287 04a0 2b05 jrmi nextW
4289 ; 972 cpl X ; Otherwise negate result
4292 04a2 53 cpl X
4294 ; 973 neg A
4297 04a3 40 neg A
4299 ; 974 jrne nextW
4302 04a4 2601 jrne nextW
4304 ; 975 inc X ; Increase MSB if 2_s complement of A is 100
4307 04a6 5c inc X
4309 ; 976 nextW:
4312 04a7 nextW:
4314 ; 981 sra X
4317 04a7 57 sra X
4319 ; 982 rrc A
4322 04a8 46 rrc A
4324 ; 983 sra X
4327 04a9 57 sra X
4329 ; 984 rrc A
4332 04aa 46 rrc A
4334 ; 985 sra X
4337 04ab 57 sra X
4339 ; 986 rrc A ; match 10 bit pwm scaling
4342 04ac 46 rrc A
4344 ; 988 ld _MCPWL,A ; Load LSB of PWM generator
4347 04ad b764 ld _MCPWL,A
4349 ; 989 ld A,X
4352 04af 9f ld A,X
4354 ; 990 add A,#_OFFSET ; add in zero offset to MSB
4357 04b0 ab0a add A,#_OFFSET
4359 ; 991 ld _MCPWH,A ; Load MSB of PWM generator
4362 04b2 b763 ld _MCPWH,A
4364 ; 993 pop Y
4367 04b4 9085 pop Y
4369 ; 994 EndOfUInt:
4372 04b6 a67f ld a,#127
4373 04b8 EndOfUInt:
4375 ; 996 MISR = ((u8)~MISR_PUI_OR);
4377 04b8 b759 ld _MISR,a
4378 ; 997 }
4381 04ba 80 iret
4439 ; 1019 void MTC_C_D_IT(void)
4439 ; 1020 {
4440 switch .text
4441 04bb _MTC_C_D_IT:
4443 00000103 OFST: set 259
4444 04bb 88 push a
4445 04bc 88 push a
4446 04bd 88 push a
4449 ; 1021 if ( MTCStatus & INIT_ROLLING_AVRG )
4451 04be 0d1053 btjf _MTCStatus,#6,L5202
4452 ; 1025 BufMzreg = MZREG; // Bufferize the values in case
4454 04c1 96 ld x,s
4455 04c2 b653 ld a,_MZREG
4456 04c4 d70102 ld (OFST-1,x),a
4457 ; 1026 BufMprsr = MPRSR; // ... a tacho capture occurs
4459 04c7 b657 ld a,_MPRSR
4460 04c9 d70103 ld (OFST+0,x),a
4461 ; 1027 BufMzprv = MZPRV; // ... during tacho FIFO initialization
4463 04cc b652 ld a,_MZPRV
4464 04ce d70101 ld (OFST-2,x),a
4465 ; 1028 SpeedFIFO_Index = (PSpeedMeas_s)SensorPeriod;
4467 04d1 ae02 ld x,#high(_SensorPeriod)
4468 04d3 bf00 ld _SpeedFIFO_Index,x
4469 04d5 a602 ld a,#low(_SensorPeriod)
4471 04d7 2023 jra L3302
4472 04d9 L7202:
4473 ; 1031 SpeedFIFO_Index->Capture.b_form.high = BufMzreg;
4475 04d9 96 ld x,s
4476 04da d60102 ld a,(OFST-1,x)
4477 04dd 92c700 ld [_SpeedFIFO_Index.w],a
4478 ; 1032 SpeedFIFO_Index->Capture.b_form.low = BufMzprv;
4480 04e0 d60101 ld a,(OFST-2,x)
4481 04e3 ae01 ld x,#1
4482 04e5 92d700 ld ([_SpeedFIFO_Index.w],x),a
4483 ; 1033 SpeedFIFO_Index->Prsc_Reg = BufMprsr;
4485 04e8 96 ld x,s
4486 04e9 d60103 ld a,(OFST+0,x)
4487 04ec ae02 ld x,#2
4488 04ee 92d700 ld ([_SpeedFIFO_Index.w],x),a
4489 ; 1034 SpeedFIFO_Index++;
4491 04f1 be00 ld x,_SpeedFIFO_Index
4492 04f3 b601 ld a,_SpeedFIFO_Index+1
4493 04f5 ab03 add a,#3
4494 04f7 2401 jrnc L421
4495 04f9 5c inc x
4496 04fa L421:
4497 04fa bf00 ld _SpeedFIFO_Index,x
4498 04fc L3302:
4499 04fc b701 ld _SpeedFIFO_Index+1,a
4500 ; 1029 while ( SpeedFIFO_Index < &SensorPeriod[SPEED_FIFO_SIZE] )
4502 04fe a60e ld a,#_SensorPeriod+12
4503 0500 99 scf
4504 0501 b201 sbc a,_SpeedFIFO_Index+1
4505 0503 4f clr a
4506 0504 b200 sbc a,_SpeedFIFO_Index
4507 0506 24d1 jruge L7202
4508 ; 1036 SpeedFIFO_Index = (PSpeedMeas_s)SensorPeriod;
4510 0508 ae02 ld x,#high(_SensorPeriod)
4511 050a bf00 ld _SpeedFIFO_Index,x
4512 050c a602 ld a,#low(_SensorPeriod)
4513 050e b701 ld _SpeedFIFO_Index+1,a
4514 ; 1037 MTCStatus &= (u8)(~INIT_ROLLING_AVRG);
4516 0510 1d10 bres _MTCStatus,#6
4518 0512 2043 jra L7302
4519 0514 L5202:
4520 ; 1041 SpeedFIFO_Index->Capture.b_form.high = MZREG;
4522 0514 b653 ld a,_MZREG
4523 0516 92c700 ld [_SpeedFIFO_Index.w],a
4524 ; 1042 SpeedFIFO_Index->Capture.b_form.low = MZPRV;
4526 0519 ae01 ld x,#1
4527 051b b652 ld a,_MZPRV
4528 051d 92d700 ld ([_SpeedFIFO_Index.w],x),a
4529 ; 1043 if (MTCStatus & RATIO_DEC)
4531 0520 0b1006 btjf _MTCStatus,#5,L1402
4532 ; 1045 SpeedFIFO_Index->Prsc_Reg = (u8)(MPRSR + 1);
4534 0523 b657 ld a,_MPRSR
4535 0525 4c inc a
4536 0526 5c inc x
4538 0527 200c jra L3402
4539 0529 L1402:
4540 ; 1049 if (MTCStatus & RATIO_INC)
4542 0529 091006 btjf _MTCStatus,#4,L5402
4543 ; 1051 SpeedFIFO_Index->Prsc_Reg = (u8)(MPRSR - 1);
4545 052c b657 ld a,_MPRSR
4546 052e 4a dec a
4547 052f 5c inc x
4549 0530 2003 jra L3402
4550 0532 L5402:
4551 ; 1055 SpeedFIFO_Index->Prsc_Reg = MPRSR;
4553 0532 5c inc x
4554 0533 b657 ld a,_MPRSR
4555 0535 L3402:
4556 0535 92d700 ld ([_SpeedFIFO_Index.w],x),a
4557 ; 1058 if (SpeedFIFO_Index < &SensorPeriod[SPEED_FIFO_SIZE-1])
4559 0538 a60b ld a,#_SensorPeriod+9
4560 053a 99 scf
4561 053b b201 sbc a,_SpeedFIFO_Index+1
4562 053d 4f clr a
4563 053e b200
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -