температура читается

This commit is contained in:
seklyuts 2024-06-07 09:46:14 +03:00
parent 43ccea0c82
commit 2e1b449c88
4 changed files with 27 additions and 16 deletions

View File

@ -39,7 +39,7 @@ typedef struct
volatile strPWMABC PWM_motor = {PERIOD_2, PERIOD_2, PERIOD_2};
int16_t A_proc,B_proc,C_proc;
uint16_t PWM_Vent = PERIOD_MOTOR;
uint16_t PWM_Vent = PERIOD_FAN;
uint16_t PWM_Chop = 0;
void pwm_set_volt_3F(float phaseA, float phaseB, float phaseC, float Udc)
@ -76,7 +76,7 @@ void pwm_set_volt_3F(float phaseA, float phaseB, float phaseC, float Udc)
EPwmRegs[PWM_B]->CMPA.bit.CMPA = PERIOD_MOTOR - PWM_motor.UB;
EPwmRegs[PWM_C]->CMPA.bit.CMPA = PERIOD_MOTOR - PWM_motor.UC;
EPwmRegs[3]->CMPA.bit.CMPA = PERIOD_MOTOR - PWM_Vent;
EPwmRegs[3]->CMPA.bit.CMPA = PERIOD_FAN - PWM_Vent;
EPwmRegs[3]->CMPB.bit.CMPB = PERIOD_MOTOR - PWM_Chop;
}

View File

@ -41,6 +41,11 @@ uint16_t temperature_calc(uint16_t Imp)
void temperatureTest(void)
{
if(TemperatureInitDone)
{
PieCtrlRegs.PIEIER5.bit.INTx9 = 0;
PieCtrlRegs.PIEIER5.bit.INTx10 = 0;
XintRegs.XINT2CR.bit.ENABLE = 1;
temperatureTic[0] = TemperatureImpCount;
if(temperatureTic[0] != 0)
{
@ -50,12 +55,19 @@ void temperatureTest(void)
if(temperatureTic[2] > Temperature_TimeMax)
{
if(TemperatureInitDone) Temperature = ((temperatureTic[0]-1)>>4) - 50;
else TemperatureInitDone = 1;
if(TemperatureInitDone == 2) Temperature = ((temperatureTic[0]-1)>>4) - 50;
else TemperatureInitDone = 2;
temperatureTic[1] = TemperatureImpCount = 0;
}
}
}
else
{
XintRegs.XINT2CR.bit.ENABLE = 0;
temperatureTic[1] = TemperatureImpCount = 0;
PieCtrlRegs.PIEIER5.bit.INTx9 = 1; // SDFM1 interrupt enabled
PieCtrlRegs.PIEIER5.bit.INTx10 = 1; // SDFM2 interrupt enabled
}
}
@ -71,7 +83,7 @@ void temperatureInit(void)
EDIS;
XintRegs.XINT2CR.bit.POLARITY = 0;
XintRegs.XINT2CR.bit.ENABLE = 1;
XintRegs.XINT2CR.bit.ENABLE = 0;
}

View File

@ -110,7 +110,6 @@ void vectorControl(int16_t CurrentA, int16_t CurrentB, int16_t CurrentC, int16_t
CurrLoop.piId.Ref = 0;
if(Mode) {XintRegs.XINT2CR.bit.ENABLE = 0; temperature_deInit();}
else {XintRegs.XINT2CR.bit.ENABLE = 1;}
switch(Mode)
{