забыл добавить новые файлы обработки датчиков фолта и температуры
This commit is contained in:
parent
ea87016738
commit
f9017a881d
Binary file not shown.
51
Projects/epwm_test_biss_c_cpu2/src/Peripherals/eqep.c
Normal file
51
Projects/epwm_test_biss_c_cpu2/src/Peripherals/eqep.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* eqep.c
|
||||
*
|
||||
* Created on: 28 мая 2024 г.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
#include "f28x_project.h"
|
||||
#include "temperature.h"
|
||||
|
||||
uint16_t eqepTic[3] = {0,0,0};
|
||||
uint16_t eqip_Max = 160; //16mS
|
||||
uint16_t eqepTemperature = 0;
|
||||
|
||||
|
||||
uint16_t eqep_read_counter(void)
|
||||
{
|
||||
return EQep1Regs.QPOSCNT;
|
||||
}
|
||||
|
||||
|
||||
void eqep_reset_counter(void)
|
||||
{
|
||||
EQep1Regs.QPOSCNT = 0;
|
||||
}
|
||||
|
||||
|
||||
void eqep_init(void)
|
||||
{
|
||||
CpuSysRegs.PCLKCR4.bit.EQEP1 = 1;
|
||||
EQep1Regs.QEPCTL.bit.FREE_SOFT = 1; //Position counter continues to count until the rollover
|
||||
EQep1Regs.QDECCTL.bit.QSRC = 2;
|
||||
EQep1Regs.QPOSMAX = 0xFFFFFFFF;
|
||||
EQep1Regs.QEPCTL.bit.QPEN = 1;//QEP unit timer enable
|
||||
}
|
||||
|
||||
void eqepTest(void)
|
||||
{
|
||||
eqepTic[0] = EQep1Regs.QPOSCNT;
|
||||
if(eqepTic[0] != 0)
|
||||
{
|
||||
if(eqepTic[1] == eqepTic[0]) eqepTic[2]++;
|
||||
else eqepTic[2] = 0;
|
||||
eqepTic[1] = eqepTic[0];
|
||||
|
||||
if(eqepTic[2] > eqip_Max)
|
||||
{
|
||||
eqepTemperature = (((eqepTic[0]>>1)-1)>>4) - 50;
|
||||
eqepTic[1] = EQep1Regs.QPOSCNT = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Projects/epwm_test_biss_c_cpu2/src/Peripherals/eqep.h
Normal file
16
Projects/epwm_test_biss_c_cpu2/src/Peripherals/eqep.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* eqep.h
|
||||
*
|
||||
* Created on: 28 мая 2024 г.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_PERIPHERALS_EQEP_H_
|
||||
#define SRC_PERIPHERALS_EQEP_H_
|
||||
|
||||
uint16_t eqep_read_counter(void);
|
||||
void eqep_reset_counter(void);
|
||||
void eqep_init(void);
|
||||
void eqepTest(void);
|
||||
|
||||
#endif /* SRC_PERIPHERALS_EQEP_H_ */
|
||||
84
Projects/epwm_test_biss_c_cpu2/src/fault.c
Normal file
84
Projects/epwm_test_biss_c_cpu2/src/fault.c
Normal file
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* fault.c
|
||||
*
|
||||
* Created on: 27 мая 2024 г.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
#include "f28x_project.h"
|
||||
#include "i2c_init.h"
|
||||
#include "fault.h"
|
||||
#include "vector.h"
|
||||
#include "pwm_init.h"
|
||||
|
||||
|
||||
|
||||
uint16_t Fault1, Fault2, faultCounter = 0, fault_read = 0;
|
||||
|
||||
__interrupt void fault_isr(void)
|
||||
{
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
|
||||
faultCounter++;
|
||||
fault_read = 1;
|
||||
PWM_ABC_StopAllClose();
|
||||
vectorFault();
|
||||
vectorResCurrLoop();
|
||||
}
|
||||
|
||||
uint16_t fault_read_check(void)
|
||||
{
|
||||
return fault_read;
|
||||
}
|
||||
|
||||
void fault_read_clr(void)
|
||||
{
|
||||
fault_read = 0;
|
||||
}
|
||||
|
||||
void fault_read_ports(void)
|
||||
{
|
||||
uint16_t Fault_Bytes;
|
||||
I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 0, 0, false, &Fault_Bytes);
|
||||
I2CRead(I2C_FAULT_SLAVE_ADDRESS, 1, true, &Fault_Bytes);
|
||||
Fault1 = Fault_Bytes;
|
||||
I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 1, 0, false, &Fault_Bytes);
|
||||
I2CRead(I2C_FAULT_SLAVE_ADDRESS, 1, true, &Fault_Bytes);
|
||||
Fault2 = Fault_Bytes;
|
||||
}
|
||||
|
||||
|
||||
uint16_t Err1, Err2;
|
||||
|
||||
void faultInit(void)
|
||||
{
|
||||
uint16_t Fault_Bytes;
|
||||
uint16_t Conf = 0xFF;
|
||||
Err1 = I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 6, 1, true, &Conf);
|
||||
|
||||
Err2 = I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 7, 1, true, &Conf);
|
||||
|
||||
|
||||
I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 0, 0, false, &Fault_Bytes);
|
||||
I2CRead(I2C_FAULT_SLAVE_ADDRESS, 1, true, &Fault_Bytes);
|
||||
Fault1 = Fault_Bytes;
|
||||
I2CWrite(I2C_FAULT_SLAVE_ADDRESS, 1, 0, false, &Fault_Bytes);
|
||||
I2CRead(I2C_FAULT_SLAVE_ADDRESS, 1, true, &Fault_Bytes);
|
||||
Fault2 = Fault_Bytes;
|
||||
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.XINT1_INT = &fault_isr;
|
||||
|
||||
IER |= M_INT1;
|
||||
PieCtrlRegs.PIEIER1.bit.INTx4 = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
|
||||
EDIS;
|
||||
|
||||
|
||||
XintRegs.XINT1CR.bit.POLARITY = 0;
|
||||
XintRegs.XINT1CR.bit.ENABLE = 1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
19
Projects/epwm_test_biss_c_cpu2/src/fault.h
Normal file
19
Projects/epwm_test_biss_c_cpu2/src/fault.h
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* fault.h
|
||||
*
|
||||
* Created on: 27 мая 2024 г.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_FAULT_H_
|
||||
#define SRC_FAULT_H_
|
||||
|
||||
#define I2C_FAULT_SLAVE_ADDRESS 0x23U
|
||||
#define I2C_OWN_ADDRESS 0x30U
|
||||
|
||||
void faultInit(void);
|
||||
void fault_read_ports(void);
|
||||
void fault_read_clr(void);
|
||||
uint16_t fault_read_check(void);
|
||||
|
||||
#endif /* SRC_FAULT_H_ */
|
||||
57
Projects/epwm_test_biss_c_cpu2/src/temperature.c
Normal file
57
Projects/epwm_test_biss_c_cpu2/src/temperature.c
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* temperature.c
|
||||
*
|
||||
* Created on: 28 мая 2024 г.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#include "f28x_project.h"
|
||||
|
||||
|
||||
uint16_t TemperatureImpCount = 0;
|
||||
uint16_t TemperaturePause = 0;
|
||||
uint16_t TemperatureLine = 0;
|
||||
uint16_t TemperatureMaxPause = 0; //16ms
|
||||
uint16_t Temperature = 0;
|
||||
uint16_t TemperatureInitDone = 0;
|
||||
|
||||
|
||||
|
||||
__interrupt void temperature_isr(void)
|
||||
{
|
||||
TemperatureImpCount++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t temperature_calc(uint16_t Imp)
|
||||
{
|
||||
|
||||
return (Imp-1)/16 - 50;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void temperatureTest(void)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void temperatureInit(void)
|
||||
{
|
||||
EALLOW; // This is needed to write to EALLOW protected registers
|
||||
PieVectTable.XINT2_INT = &temperature_isr;
|
||||
|
||||
IER |= M_INT1;
|
||||
PieCtrlRegs.PIEIER1.bit.INTx5 = 1;
|
||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
|
||||
|
||||
EDIS;
|
||||
|
||||
XintRegs.XINT2CR.bit.POLARITY = 0;
|
||||
XintRegs.XINT2CR.bit.ENABLE = 1;
|
||||
}
|
||||
|
||||
|
||||
14
Projects/epwm_test_biss_c_cpu2/src/temperature.h
Normal file
14
Projects/epwm_test_biss_c_cpu2/src/temperature.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* temperature.h
|
||||
*
|
||||
* Created on: 28 мая 2024 г.
|
||||
* Author: seklyuts
|
||||
*/
|
||||
|
||||
#ifndef SRC_TEMPERATURE_H_
|
||||
#define SRC_TEMPERATURE_H_
|
||||
|
||||
void temperatureTest(void);
|
||||
uint16_t temperature_calc(uint16_t Imp);
|
||||
|
||||
#endif /* SRC_TEMPERATURE_H_ */
|
||||
Loading…
Reference in New Issue
Block a user