diff --git a/Projects/epwm_test_biss_c_cpu1/src/Peripherals/pwm_init.c b/Projects/epwm_test_biss_c_cpu1/src/Peripherals/pwm_init.c index 7beae58..6123c0a 100644 --- a/Projects/epwm_test_biss_c_cpu1/src/Peripherals/pwm_init.c +++ b/Projects/epwm_test_biss_c_cpu1/src/Peripherals/pwm_init.c @@ -117,20 +117,23 @@ void PWMGpioInit(void)//��� � ������������ � GpioCtrlRegs.GPACSEL2.bit.GPIO8 = 2;//to cpu2 GpioCtrlRegs.GPACSEL2.bit.GPIO9 = 2; - GpioCtrlRegs.GPAPUD.bit.GPIO6 = 1; // Disable pull-up on GPIO6 (EPWM4A) - GpioCtrlRegs.GPAPUD.bit.GPIO7 = 1; // Disable pull-up on GPIO7 (EPWM4B) - GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1; // Configure GPIO6 as EPWM4A - GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 1; // Configure GPIO7 as EPWM4B - GpioCtrlRegs.GPACSEL1.bit.GPIO6 = 2;//to cpu2 - GpioCtrlRegs.GPACSEL1.bit.GPIO7 = 2; + +#ifdef REF0 GpioCtrlRegs.GPAPUD.bit.GPIO12 = 1; // Disable pull-up on GPIO12 (EPWM7A) GpioCtrlRegs.GPAPUD.bit.GPIO13 = 1; // Disable pull-up on GPIO13 (EPWM7B) GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 1; // Configure GPIO12 as EPWM7A GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 1; // Configure GPIO13 as EPWM7B GpioCtrlRegs.GPACSEL2.bit.GPIO12 = 2;//to cpu2 GpioCtrlRegs.GPACSEL2.bit.GPIO13 = 2; - +#else + GpioCtrlRegs.GPAPUD.bit.GPIO6 = 1; // Disable pull-up on GPIO6 (EPWM4A) + GpioCtrlRegs.GPAPUD.bit.GPIO7 = 1; // Disable pull-up on GPIO7 (EPWM4B) + GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1; // Configure GPIO6 as EPWM4A + GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 1; // Configure GPIO7 as EPWM4B + GpioCtrlRegs.GPACSEL1.bit.GPIO6 = 2;//to cpu2 + GpioCtrlRegs.GPACSEL1.bit.GPIO7 = 2; +#endif // GpioCtrlRegs.GPAPUD.bit.GPIO14 = 1; // Disable pull-up on GPIO14 (EPWM8A) // GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 1; // Configure GPIO14 as EPWM8A // GpioCtrlRegs.GPACSEL2.bit.GPIO14 = 2;//to cpu2 diff --git a/Projects/epwm_test_biss_c_cpu2/Start_rfm.pmp b/Projects/epwm_test_biss_c_cpu2/Start_rfm.pmp index a1cf863..0e6c8a4 100644 Binary files a/Projects/epwm_test_biss_c_cpu2/Start_rfm.pmp and b/Projects/epwm_test_biss_c_cpu2/Start_rfm.pmp differ diff --git a/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.c b/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.c index 76b6548..4e6d216 100644 --- a/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.c +++ b/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.c @@ -55,6 +55,32 @@ void PWM_ABC_StartOut(void) EDIS; } +void PWM_ABC_Start(uint16_t Num) +{ + EALLOW; + + if(Num&0x01) EPwmRegs[PWM_A]->TZCTL.bit.TZA = 3; + else EPwmRegs[PWM_A]->TZCTL.bit.TZA = 2; + + if(Num&0x02) EPwmRegs[PWM_A]->TZCTL.bit.TZB = 3; + else EPwmRegs[PWM_A]->TZCTL.bit.TZB = 2; + + if(Num&0x04)EPwmRegs[PWM_B]->TZCTL.bit.TZA = 3; + else EPwmRegs[PWM_B]->TZCTL.bit.TZA = 2; + + if(Num&0x08)EPwmRegs[PWM_B]->TZCTL.bit.TZB = 3; + else EPwmRegs[PWM_B]->TZCTL.bit.TZB = 2; + + if(Num&0x10)EPwmRegs[PWM_C]->TZCTL.bit.TZA = 3; + else EPwmRegs[PWM_C]->TZCTL.bit.TZA = 2; + + if(Num&0x20)EPwmRegs[PWM_C]->TZCTL.bit.TZB = 3; + else EPwmRegs[PWM_C]->TZCTL.bit.TZB = 2; + + EDIS; +} + + void PWMAllInit(void) { // diff --git a/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.h b/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.h index 3e339ba..c299823 100644 --- a/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.h +++ b/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_init.h @@ -65,7 +65,7 @@ void PWMInitInterruptEn(void); void PWMAllInit(void); void PWM_ABC_StopAllClose(void); void PWM_ABC_StartOut(void); - +void PWM_ABC_Start(uint16_t Num); void InitEPwm1Example(void); void InitEPwm2Example(void); diff --git a/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_interrupts.c b/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_interrupts.c index 7a4a774..742a166 100644 --- a/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_interrupts.c +++ b/Projects/epwm_test_biss_c_cpu2/src/Peripherals/pwm_interrupts.c @@ -103,10 +103,10 @@ __interrupt void epwm1_isr(void) EPwm1Regs.ETCLR.bit.INT = 1; TimerBaseTimeoutInc(); MainTimerBaseTimeoutInc(); -#ifdef TEMPER_GPIO_20 - eqepTest(); -#else +#ifdef REF0 temperatureTest(); +#else + eqepTest(); #endif // diff --git a/Projects/epwm_test_biss_c_cpu2/src/vector.c b/Projects/epwm_test_biss_c_cpu2/src/vector.c index 1c3f00d..ecd2e45 100644 --- a/Projects/epwm_test_biss_c_cpu2/src/vector.c +++ b/Projects/epwm_test_biss_c_cpu2/src/vector.c @@ -96,6 +96,8 @@ void vectorFault(void) XintRegs.XINT2CR.bit.ENABLE = 1; } +uint16_t Num = 0; + void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t sdfmUdc) { @@ -112,6 +114,7 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t if(VoltProcImit) UdcVolt = VoltProcImit; else UdcVolt = (float)UdcFiltered*VdcFactor/BIT_MAX; + if(UdcVolt < 15) Mode = OffMode; Step = Step + Nstep; CurrLoop.piId.Ref = 0; @@ -141,6 +144,9 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t if(StepS > (1<<(StepShift-1))) CurrLoop.piId.Ref = 0; else CurrLoop.piId.Ref = CurrentRegTuneAmpl; break; + case TestPWNMode: + PWM_ABC_Start(Num); + break; default: Mode = OffMode; PWM_ABC_StopAllClose(); diff --git a/Projects/epwm_test_biss_c_cpu2/src/vector.h b/Projects/epwm_test_biss_c_cpu2/src/vector.h index 1dfe43e..aed2a94 100644 --- a/Projects/epwm_test_biss_c_cpu2/src/vector.h +++ b/Projects/epwm_test_biss_c_cpu2/src/vector.h @@ -80,6 +80,7 @@ typedef enum StepMode, // StayMode, CurrentRegTune, + TestPWNMode, VectorModeU, VectorModeI }TMode;