добавлен режим потранзисторного шима

This commit is contained in:
seklyuts 2024-07-24 16:02:51 +03:00
parent 01ff374787
commit c58809798f
7 changed files with 47 additions and 11 deletions

View File

@ -117,20 +117,23 @@ void PWMGpioInit(void)//<2F><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
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

View File

@ -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)
{
//

View File

@ -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);

View File

@ -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
//

View File

@ -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();

View File

@ -80,6 +80,7 @@ typedef enum
StepMode, //
StayMode,
CurrentRegTune,
TestPWNMode,
VectorModeU,
VectorModeI
}TMode;