Переделана инициализация смещений токов в SDFM, убраны большие массивы
This commit is contained in:
parent
6d0905983f
commit
fa206d1d68
@ -99,12 +99,12 @@ SECTIONS
|
|||||||
MSGRAM_CM_TO_CPU : > CMTOCPURAM, type=NOINIT
|
MSGRAM_CM_TO_CPU : > CMTOCPURAM, type=NOINIT
|
||||||
|
|
||||||
/* The following section definition are for SDFM examples */
|
/* The following section definition are for SDFM examples */
|
||||||
Filter_RegsFile : > RAMGS0
|
// Filter_RegsFile : > RAMGS0
|
||||||
Filter1_RegsFile : > RAMGS1, fill=0x1111
|
// Filter1_RegsFile : > RAMGS1, fill=0x1111
|
||||||
Filter2_RegsFile : > RAMGS2, fill=0x2222
|
// Filter2_RegsFile : > RAMGS2, fill=0x2222
|
||||||
Filter3_RegsFile : > RAMGS3, fill=0x3333
|
// Filter3_RegsFile : > RAMGS3, fill=0x3333
|
||||||
Filter4_RegsFile : > RAMGS4, fill=0x4444
|
// Filter4_RegsFile : > RAMGS4, fill=0x4444
|
||||||
Difference_RegsFile : >RAMGS5, fill=0x3333
|
// Difference_RegsFile : >RAMGS5, fill=0x3333
|
||||||
|
|
||||||
#if defined(__TI_EABI__)
|
#if defined(__TI_EABI__)
|
||||||
.TI.ramfunc : {} LOAD = FLASH3,
|
.TI.ramfunc : {} LOAD = FLASH3,
|
||||||
|
|||||||
@ -32,25 +32,25 @@
|
|||||||
|
|
||||||
//uint16_t gPWM_number = 1; // ePWM 1 for synchronizing SDFM1 filters
|
//uint16_t gPWM_number = 1; // ePWM 1 for synchronizing SDFM1 filters
|
||||||
|
|
||||||
int16_t Filter0_Result[MAX_SAMPLES];
|
//int16_t Filter0_Result[MAX_SAMPLES];
|
||||||
int16_t Filter1_Result[MAX_SAMPLES];
|
//int16_t Filter1_Result[MAX_SAMPLES];
|
||||||
int16_t Filter2_Result[MAX_SAMPLES];
|
//int16_t Filter2_Result[MAX_SAMPLES];
|
||||||
int16_t Filter3_Result[MAX_SAMPLES];
|
//int16_t Filter3_Result[MAX_SAMPLES];
|
||||||
int16_t Filter4_Result[MAX_SAMPLES];
|
//int16_t Filter4_Result[MAX_SAMPLES];
|
||||||
int16_t Filter5_Result[MAX_SAMPLES];
|
//int16_t Filter5_Result[MAX_SAMPLES];
|
||||||
int16_t Filter6_Result[MAX_SAMPLES];
|
//int16_t Filter6_Result[MAX_SAMPLES];
|
||||||
int16_t Filter7_Result[MAX_SAMPLES];
|
//int16_t Filter7_Result[MAX_SAMPLES];
|
||||||
|
//
|
||||||
#pragma DATA_SECTION(Filter0_Result,"Filter1_RegsFile");
|
//#pragma DATA_SECTION(Filter0_Result,"Filter1_RegsFile");
|
||||||
#pragma DATA_SECTION(Filter1_Result,"Filter2_RegsFile");
|
//#pragma DATA_SECTION(Filter1_Result,"Filter2_RegsFile");
|
||||||
#pragma DATA_SECTION(Filter2_Result,"Filter3_RegsFile");
|
//#pragma DATA_SECTION(Filter2_Result,"Filter3_RegsFile");
|
||||||
#pragma DATA_SECTION(Filter3_Result,"Filter4_RegsFile");
|
//#pragma DATA_SECTION(Filter3_Result,"Filter4_RegsFile");
|
||||||
#pragma DATA_SECTION(Filter4_Result,"Filter1_RegsFile");
|
//#pragma DATA_SECTION(Filter4_Result,"Filter1_RegsFile");
|
||||||
#pragma DATA_SECTION(Filter5_Result,"Filter2_RegsFile");
|
//#pragma DATA_SECTION(Filter5_Result,"Filter2_RegsFile");
|
||||||
#pragma DATA_SECTION(Filter6_Result,"Filter3_RegsFile");
|
//#pragma DATA_SECTION(Filter6_Result,"Filter3_RegsFile");
|
||||||
#pragma DATA_SECTION(Filter7_Result,"Filter4_RegsFile");
|
//#pragma DATA_SECTION(Filter7_Result,"Filter4_RegsFile");
|
||||||
|
//
|
||||||
int16_t * FilterResult[8] = {Filter0_Result, Filter1_Result, Filter2_Result, Filter3_Result, Filter4_Result, Filter5_Result, Filter6_Result, Filter7_Result};
|
//int16_t * FilterResult[8] = {Filter0_Result, Filter1_Result, Filter2_Result, Filter3_Result, Filter4_Result, Filter5_Result, Filter6_Result, Filter7_Result};
|
||||||
|
|
||||||
union SDCPARM1_REG * SDCPARM_Reg_arr[8] = {
|
union SDCPARM1_REG * SDCPARM_Reg_arr[8] = {
|
||||||
(union SDCPARM1_REG *)(&Sdfm1Regs.SDCPARM1),
|
(union SDCPARM1_REG *)(&Sdfm1Regs.SDCPARM1),
|
||||||
@ -174,19 +174,19 @@ void SdfmInitEnable(void)
|
|||||||
EDIS;
|
EDIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdfmInitInterruptEn(void)
|
//void SdfmInitInterruptEn(void)
|
||||||
{
|
//{
|
||||||
EALLOW;
|
// EALLOW;
|
||||||
PieVectTable.SDFM1_INT = &Sdfm1_ISR;
|
// PieVectTable.SDFM1_INT = &Sdfm1_ISR;
|
||||||
PieVectTable.SDFM2_INT = &Sdfm2_ISR;
|
// PieVectTable.SDFM2_INT = &Sdfm2_ISR;
|
||||||
IER |= M_INT5;
|
// IER |= M_INT5;
|
||||||
Sdfm_clearFlagRegister(SDFM1,0xFFFFFFFF);
|
// Sdfm_clearFlagRegister(SDFM1,0xFFFFFFFF);
|
||||||
Sdfm_clearFlagRegister(SDFM2,0xFFFFFFFF);
|
// Sdfm_clearFlagRegister(SDFM2,0xFFFFFFFF);
|
||||||
PieCtrlRegs.PIEIER5.bit.INTx9 = 1; // SDFM1 interrupt enabled
|
// PieCtrlRegs.PIEIER5.bit.INTx9 = 1; // SDFM1 interrupt enabled
|
||||||
PieCtrlRegs.PIEIER5.bit.INTx10 = 1; // SDFM2 interrupt enabled
|
// PieCtrlRegs.PIEIER5.bit.INTx10 = 1; // SDFM2 interrupt enabled
|
||||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
// PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
||||||
EDIS;
|
// EDIS;
|
||||||
}
|
//}
|
||||||
|
|
||||||
void SdfmTypeInit(void)
|
void SdfmTypeInit(void)
|
||||||
{
|
{
|
||||||
@ -315,41 +315,41 @@ void SdfmInit(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void sdfmGetResult(uint16_t N)
|
//void sdfmGetResult(uint16_t N)
|
||||||
{
|
//{
|
||||||
uint16_t i = 0;
|
// uint16_t i = 0;
|
||||||
int32_t OffsetCount = 0;
|
// int32_t OffsetCount = 0;
|
||||||
|
//
|
||||||
// Gpio4out(1);
|
//// Gpio4out(1);
|
||||||
|
//
|
||||||
FilterResult[N][loopCounter[N]] = *SdfmReadData[N];
|
// FilterResult[N][loopCounter[N]] = *SdfmReadData[N];
|
||||||
sdfmAdc[N] = FilterResult[N][loopCounter[N]] - sdfmOffset[N];
|
// sdfmAdc[N] = FilterResult[N][loopCounter[N]] - sdfmOffset[N];
|
||||||
if(N != 5) {
|
// if(N != 5) {
|
||||||
if(loopCounter[N] < MAX_SAMPLES) loopCounter[N]++;
|
// if(loopCounter[N] < MAX_SAMPLES) loopCounter[N]++;
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
loopCounter[N] = 0;
|
// loopCounter[N] = 0;
|
||||||
if(!initDone[N])
|
// if(!initDone[N])
|
||||||
{
|
// {
|
||||||
for(i = 0; i <= (MAX_SAMPLES-1); i++) OffsetCount += FilterResult[N][i];
|
// for(i = 0; i <= (MAX_SAMPLES-1); i++) OffsetCount += FilterResult[N][i];
|
||||||
sdfmOffset[N] = OffsetCount>>FILTER_BIT;
|
// sdfmOffset[N] = OffsetCount>>FILTER_BIT;
|
||||||
initDone[N] = 0xFF;
|
// initDone[N] = 0xFF;
|
||||||
}
|
// }
|
||||||
else if(initDone[N] != 0xFF) initDone[N]--;
|
// else if(initDone[N] != 0xFF) initDone[N]--;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
EALLOW;
|
// EALLOW;
|
||||||
SDCPARM_Reg_arr[N]->bit.MFIE = 1;
|
// SDCPARM_Reg_arr[N]->bit.MFIE = 1;
|
||||||
SDDFPARM_Reg_arr[N]->bit.AE = 0;
|
// SDDFPARM_Reg_arr[N]->bit.AE = 0;
|
||||||
EDIS;
|
// EDIS;
|
||||||
sdfmAdcErr[N] = 0;
|
// sdfmAdcErr[N] = 0;
|
||||||
|
//
|
||||||
// Gpio4out(0);
|
//// Gpio4out(0);
|
||||||
|
//
|
||||||
// if(N == SDFM_IA) Gpio54out(0);
|
//// if(N == SDFM_IA) Gpio54out(0);
|
||||||
// if(N == SDFM_IB) Gpio55out(0);
|
//// if(N == SDFM_IB) Gpio55out(0);
|
||||||
// if(N == SDFM_IC) Gpio56out(0);
|
//// if(N == SDFM_IC) Gpio56out(0);
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
void sdfmErr(uint16_t N)
|
void sdfmErr(uint16_t N)
|
||||||
@ -365,56 +365,56 @@ void sdfmErr(uint16_t N)
|
|||||||
// Sdfm1_ISR - SDFM 1 ISR
|
// Sdfm1_ISR - SDFM 1 ISR
|
||||||
//
|
//
|
||||||
|
|
||||||
void sdfm_check_all_current_measurements_was_done(void)
|
//void sdfm_check_all_current_measurements_was_done(void)
|
||||||
{
|
//{
|
||||||
if((sdfmIndex & SDFM_ALL_CURRENTS) == SDFM_ALL_CURRENTS)
|
// if((sdfmIndex & SDFM_ALL_CURRENTS) == SDFM_ALL_CURRENTS)
|
||||||
{
|
// {
|
||||||
sdfmIndex = 0;
|
// sdfmIndex = 0;
|
||||||
if(!AllInitDone)
|
// if(!AllInitDone)
|
||||||
{
|
// {
|
||||||
if((initDone[SDFM_IA] == 0xFF)&&(initDone[SDFM_IB] == 0xFF)&&(initDone[SDFM_IC] == 0xFF)) AllInitDone = 1;
|
// if((initDone[SDFM_IA] == 0xFF)&&(initDone[SDFM_IB] == 0xFF)&&(initDone[SDFM_IC] == 0xFF)) AllInitDone = 1;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
vectorControl(sdfmAdc[SDFM_IA],sdfmAdc[SDFM_IB],sdfmAdc[SDFM_IC],sdfmAdc[SDFM_U_DC]);
|
// vectorControl(sdfmAdc[SDFM_IA],sdfmAdc[SDFM_IB],sdfmAdc[SDFM_IC],sdfmAdc[SDFM_U_DC]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
__interrupt void Sdfm1_ISR(void)
|
//__interrupt void Sdfm1_ISR(void)
|
||||||
{
|
//{
|
||||||
uint16_t i;
|
//uint16_t i;
|
||||||
uint32_t IntFlags;
|
//uint32_t IntFlags;
|
||||||
|
//
|
||||||
IntFlags = Sdfm_readFlagRegister(SDFM1);
|
// IntFlags = Sdfm_readFlagRegister(SDFM1);
|
||||||
sdfmIndex |= (IntFlags & 0xF000)>>12;
|
// sdfmIndex |= (IntFlags & 0xF000)>>12;
|
||||||
|
//
|
||||||
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x1000 << i)) sdfmGetResult(i);
|
// for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x1000 << i)) sdfmGetResult(i);
|
||||||
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x100 << i)) sdfmErr(i);
|
// for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x100 << i)) sdfmErr(i);
|
||||||
|
//
|
||||||
Sdfm_clearFlagRegister(SDFM1,IntFlags);
|
// Sdfm_clearFlagRegister(SDFM1,IntFlags);
|
||||||
sdfm_check_all_current_measurements_was_done();
|
// sdfm_check_all_current_measurements_was_done();
|
||||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
// PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
__interrupt void Sdfm2_ISR(void)
|
//__interrupt void Sdfm2_ISR(void)
|
||||||
{
|
//{
|
||||||
uint16_t i;
|
//uint16_t i;
|
||||||
uint32_t IntFlags;
|
//uint32_t IntFlags;
|
||||||
|
//
|
||||||
IntFlags = Sdfm_readFlagRegister(SDFM2);
|
// IntFlags = Sdfm_readFlagRegister(SDFM2);
|
||||||
sdfmIndex |= (IntFlags & 0xF000)>>8;
|
// sdfmIndex |= (IntFlags & 0xF000)>>8;
|
||||||
|
//
|
||||||
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x1000 << i)) sdfmGetResult(i+4);
|
// for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x1000 << i)) sdfmGetResult(i+4);
|
||||||
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x100 << i)) sdfmErr(i+4);
|
// for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x100 << i)) sdfmErr(i+4);
|
||||||
|
//
|
||||||
Sdfm_clearFlagRegister(SDFM2,IntFlags);
|
// Sdfm_clearFlagRegister(SDFM2,IntFlags);
|
||||||
sdfm_check_all_current_measurements_was_done();
|
// sdfm_check_all_current_measurements_was_done();
|
||||||
PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
// PieCtrlRegs.PIEACK.all = PIEACK_GROUP5;
|
||||||
}
|
//}
|
||||||
|
|
||||||
void sdfm_start_conversion_current(void)
|
void sdfm_start_conversion_current(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -69,7 +69,7 @@ void InitPerif(void)
|
|||||||
|
|
||||||
EALLOW;
|
EALLOW;
|
||||||
// ClkCfgRegs.CLKSEM.bit.SEM = 0xA5A50002;
|
// ClkCfgRegs.CLKSEM.bit.SEM = 0xA5A50002;
|
||||||
ClkCfgRegs.LOSPCP.bit.LSPCLKDIV = 2;
|
ClkCfgRegs.LOSPCP.bit.LSPCLKDIV = 1;//LSPCLK = SYSPLL/LSPCLKDIV
|
||||||
EDIS;
|
EDIS;
|
||||||
|
|
||||||
InitSysCtrl();
|
InitSysCtrl();
|
||||||
|
|||||||
@ -62,7 +62,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE.2084039298" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE.2084039298" name="Pre-define NAME (--define, -D)" superClass="com.ti.ccstudio.buildDefinitions.C2000_22.6.compilerID.DEFINE" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
|
<listOptionValue builtIn="false" value="${COM_TI_C2000WARE_SOFTWARE_PACKAGE_SYMBOLS}"/>
|
||||||
<listOptionValue builtIn="false" value="NFREEMASTER"/>
|
<listOptionValue builtIn="false" value="FREEMASTER"/>
|
||||||
<listOptionValue builtIn="false" value="NRS485"/>
|
<listOptionValue builtIn="false" value="NRS485"/>
|
||||||
<listOptionValue builtIn="false" value="REF1"/>
|
<listOptionValue builtIn="false" value="REF1"/>
|
||||||
<listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/>
|
<listOptionValue builtIn="false" value="USE_25MHZ_XTAL"/>
|
||||||
|
|||||||
@ -100,10 +100,10 @@ SECTIONS
|
|||||||
|
|
||||||
/* The following section definition are for SDFM examples */
|
/* The following section definition are for SDFM examples */
|
||||||
// Filter_RegsFile : > RAMGS10
|
// Filter_RegsFile : > RAMGS10
|
||||||
Filter1_RegsFile : > RAMLS1
|
// Filter1_RegsFile : > RAMLS1
|
||||||
Filter2_RegsFile : > RAMLS2
|
// Filter2_RegsFile : > RAMLS2
|
||||||
Filter3_RegsFile : > RAMLS3
|
// Filter3_RegsFile : > RAMLS3
|
||||||
Filter4_RegsFile : > RAMLS4
|
// Filter4_RegsFile : > RAMLS4
|
||||||
|
|
||||||
Filter6_RegsFile : > RAMLS6
|
Filter6_RegsFile : > RAMLS6
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -17,6 +17,9 @@
|
|||||||
#define EPWM_DB_mkS 4.0 //mkS
|
#define EPWM_DB_mkS 4.0 //mkS
|
||||||
#define FREQUENCY_FAN 1000.0 //Hz
|
#define FREQUENCY_FAN 1000.0 //Hz
|
||||||
|
|
||||||
|
#define START_INIT_CURRENT_TIME_MS 1000 //mS
|
||||||
|
#define START_INIT_CURRENT_TIME START_INIT_CURRENT_TIME_MS*10 //
|
||||||
|
|
||||||
|
|
||||||
#define PERIOD_FAN (SYS_PWM_FREQUENCY/2.0/FREQUENCY_FAN)
|
#define PERIOD_FAN (SYS_PWM_FREQUENCY/2.0/FREQUENCY_FAN)
|
||||||
|
|
||||||
|
|||||||
@ -14,13 +14,13 @@
|
|||||||
#include "vector.h"
|
#include "vector.h"
|
||||||
#include "sdfm.h"
|
#include "sdfm.h"
|
||||||
#include "adc_init.h"
|
#include "adc_init.h"
|
||||||
#include <pwm_init.h>
|
|
||||||
#include "biss.h"
|
#include "biss.h"
|
||||||
#include "eqep.h"
|
#include "eqep.h"
|
||||||
#include "temperature.h"
|
#include "temperature.h"
|
||||||
#include "rele.h"
|
#include "rele.h"
|
||||||
#include "pwm_interrupts.h"
|
#include "pwm_interrupts.h"
|
||||||
#include "SyncPWMFonRun.h"
|
#include "SyncPWMFonRun.h"
|
||||||
|
#include "pwm_init.h"
|
||||||
|
|
||||||
volatile uint16_t AutoChange = 0;
|
volatile uint16_t AutoChange = 0;
|
||||||
volatile uint16_t PWM_out = 2500;
|
volatile uint16_t PWM_out = 2500;
|
||||||
@ -49,6 +49,10 @@ uint16_t PWM_Chop = 0;
|
|||||||
uint16_t PWM_SDFM_delay = SDFM_DELAY;
|
uint16_t PWM_SDFM_delay = SDFM_DELAY;
|
||||||
uint16_t Timing_PWM[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
uint16_t Timing_PWM[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
|
uint32_t counterStartInitCurrents = START_INIT_CURRENT_TIME;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void pwm_set_volt_3F(float phaseA, float phaseB, float phaseC, float Udc, uint16_t Mode)
|
void pwm_set_volt_3F(float phaseA, float phaseB, float phaseC, float Udc, uint16_t Mode)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -164,16 +168,22 @@ __interrupt void epwm2_isr(void)
|
|||||||
|
|
||||||
if(PwmFlagStartCurrentMeashure) /// Не были отработаны измерения тока в сигма-дельта и не было запущено векторное управление
|
if(PwmFlagStartCurrentMeashure) /// Не были отработаны измерения тока в сигма-дельта и не было запущено векторное управление
|
||||||
{
|
{
|
||||||
|
PWM_ABC_StopAllClose();
|
||||||
|
vectorFault();
|
||||||
|
|
||||||
|
if(counterStartInitCurrents == 0) sdfmStartInitCurrents();
|
||||||
|
else counterStartInitCurrents--;
|
||||||
|
|
||||||
PwmFlagStartCurrentMeashure = 0;
|
PwmFlagStartCurrentMeashure = 0;
|
||||||
SynchPWMFonRunEnableSet();
|
SynchPWMFonRunEnableSet();
|
||||||
AdcStartSet();
|
AdcStartSet();
|
||||||
BissStartSet();
|
BissStartSet();
|
||||||
PWM_ABC_StopAllClose();
|
|
||||||
PWM_motor.UA = PERIOD_DIV2;
|
PWM_motor.UA = PERIOD_DIV2;
|
||||||
PWM_motor.UB = PERIOD_DIV2;
|
PWM_motor.UB = PERIOD_DIV2;
|
||||||
PWM_motor.UC = PERIOD_DIV2;
|
PWM_motor.UC = PERIOD_DIV2;
|
||||||
vectorFault();
|
|
||||||
EPwmRegs[PWM_FAN]->CMPA.bit.CMPA = PERIOD_MOTOR - PWM_Vent;
|
// EPwmRegs[PWM_FAN]->CMPA.bit.CMPA = PERIOD_MOTOR - PWM_Vent;
|
||||||
// EPwmRegs[3]->CMPB.bit.CMPB = PERIOD_MOTOR - PWM_Chop;
|
// EPwmRegs[3]->CMPB.bit.CMPB = PERIOD_MOTOR - PWM_Chop;
|
||||||
Test_ADC_PWM_Synch1++;
|
Test_ADC_PWM_Synch1++;
|
||||||
if(TestStopSync == 2) TestStopSync = 3;
|
if(TestStopSync == 2) TestStopSync = 3;
|
||||||
|
|||||||
@ -33,25 +33,27 @@
|
|||||||
|
|
||||||
//uint16_t gPWM_number = 1; // ePWM 1 for synchronizing SDFM1 filters
|
//uint16_t gPWM_number = 1; // ePWM 1 for synchronizing SDFM1 filters
|
||||||
|
|
||||||
int16_t Filter0_Result[MAX_SAMPLES];
|
//int16_t Filter0_Result[MAX_SAMPLES];
|
||||||
int16_t Filter1_Result[MAX_SAMPLES];
|
//int16_t Filter1_Result[MAX_SAMPLES];
|
||||||
int16_t Filter2_Result[MAX_SAMPLES];
|
//int16_t Filter2_Result[MAX_SAMPLES];
|
||||||
int16_t Filter3_Result[MAX_SAMPLES];
|
//int16_t Filter3_Result[MAX_SAMPLES];
|
||||||
int16_t Filter4_Result[MAX_SAMPLES];
|
//int16_t Filter4_Result[MAX_SAMPLES];
|
||||||
int16_t Filter5_Result[MAX_SAMPLES];
|
//int16_t Filter5_Result[MAX_SAMPLES];
|
||||||
int16_t Filter6_Result[MAX_SAMPLES];
|
//int16_t Filter6_Result[MAX_SAMPLES];
|
||||||
int16_t Filter7_Result[MAX_SAMPLES];
|
//int16_t Filter7_Result[MAX_SAMPLES];
|
||||||
|
//
|
||||||
|
//#pragma DATA_SECTION(Filter0_Result,"Filter1_RegsFile");
|
||||||
|
//#pragma DATA_SECTION(Filter1_Result,"Filter2_RegsFile");
|
||||||
|
//#pragma DATA_SECTION(Filter2_Result,"Filter3_RegsFile");
|
||||||
|
//#pragma DATA_SECTION(Filter3_Result,"Filter4_RegsFile");
|
||||||
|
//#pragma DATA_SECTION(Filter4_Result,"Filter1_RegsFile");
|
||||||
|
//#pragma DATA_SECTION(Filter5_Result,"Filter2_RegsFile");
|
||||||
|
//#pragma DATA_SECTION(Filter6_Result,"Filter3_RegsFile");
|
||||||
|
//#pragma DATA_SECTION(Filter7_Result,"Filter4_RegsFile");
|
||||||
|
|
||||||
#pragma DATA_SECTION(Filter0_Result,"Filter1_RegsFile");
|
int16_t FilterResult[8] = {0,0,0,0,0,0,0,0};
|
||||||
#pragma DATA_SECTION(Filter1_Result,"Filter2_RegsFile");
|
int32_t OffsetCount[8] = {0,0,0,0,0,0,0,0};
|
||||||
#pragma DATA_SECTION(Filter2_Result,"Filter3_RegsFile");
|
int16_t NeedToBeInit[8] = {0,0,0,0,0,0,0,0};
|
||||||
#pragma DATA_SECTION(Filter3_Result,"Filter4_RegsFile");
|
|
||||||
#pragma DATA_SECTION(Filter4_Result,"Filter1_RegsFile");
|
|
||||||
#pragma DATA_SECTION(Filter5_Result,"Filter2_RegsFile");
|
|
||||||
#pragma DATA_SECTION(Filter6_Result,"Filter3_RegsFile");
|
|
||||||
#pragma DATA_SECTION(Filter7_Result,"Filter4_RegsFile");
|
|
||||||
|
|
||||||
int16_t * FilterResult[8] = {Filter0_Result, Filter1_Result, Filter2_Result, Filter3_Result, Filter4_Result, Filter5_Result, Filter6_Result, Filter7_Result};
|
|
||||||
|
|
||||||
union SDCPARM1_REG * SDCPARM_Reg_arr[8] = {
|
union SDCPARM1_REG * SDCPARM_Reg_arr[8] = {
|
||||||
(union SDCPARM1_REG *)(&Sdfm1Regs.SDCPARM1),
|
(union SDCPARM1_REG *)(&Sdfm1Regs.SDCPARM1),
|
||||||
@ -205,7 +207,7 @@ void SdfmInitInterruptEn(void)
|
|||||||
|
|
||||||
void SdfmInit(void)
|
void SdfmInit(void)
|
||||||
{
|
{
|
||||||
uint16_t HLT, LLT, Max, Min;
|
uint16_t HLT, LLT;
|
||||||
//
|
//
|
||||||
// Configure SDFM type to 0
|
// Configure SDFM type to 0
|
||||||
//
|
//
|
||||||
@ -324,20 +326,33 @@ void SdfmInit(void)
|
|||||||
Sdfm2Regs.SDDFPARM4.bit.FEN = 1;
|
Sdfm2Regs.SDDFPARM4.bit.FEN = 1;
|
||||||
EDIS;
|
EDIS;
|
||||||
|
|
||||||
Max = (BIT_MAX>>1)+IMAX_A_KZ*DIV_FACTOR_CURRENT_MOTOR/2/20;
|
// sdfmInitPwmFlt(SDFM_U_DC, 0, 0x4200);
|
||||||
Min = (BIT_MAX>>1)-IMAX_A_KZ*DIV_FACTOR_CURRENT_MOTOR/2/20;
|
}
|
||||||
|
|
||||||
|
void sdfmInitCurrentFault(void)
|
||||||
|
{
|
||||||
|
uint16_t Max, Min;
|
||||||
|
|
||||||
|
Max = (BIT_MAX>>1)+IMAX_A_KZ*DIV_FACTOR_CURRENT_MOTOR/2;
|
||||||
|
Min = (BIT_MAX>>1)-IMAX_A_KZ*DIV_FACTOR_CURRENT_MOTOR/2;
|
||||||
|
|
||||||
sdfmInitPwmFlt(SDFM_IA, Min, Max);
|
sdfmInitPwmFlt(SDFM_IA, Min, Max);
|
||||||
sdfmInitPwmFlt(SDFM_IB, Min, Max);
|
sdfmInitPwmFlt(SDFM_IB, Min, Max);
|
||||||
sdfmInitPwmFlt(SDFM_IC, Min, Max);
|
sdfmInitPwmFlt(SDFM_IC, Min, Max);
|
||||||
|
|
||||||
sdfmInitPwmFlt(SDFM_U_DC, 0, 0x4200);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void sdfmStartInitCurrents(void)
|
||||||
|
{
|
||||||
|
NeedToBeInit[SDFM_IA] = 1;
|
||||||
|
NeedToBeInit[SDFM_IB] = 1;
|
||||||
|
NeedToBeInit[SDFM_IC] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define CEVT_interrupt_enable 0;
|
#define CEVT_interrupt_enable 0;
|
||||||
|
|
||||||
|
|
||||||
void sdfmInitPwmFlt(uint16_t N, uint16_t LowFLT, uint16_t HightFlt)
|
void sdfmInitPwmFlt(uint16_t N, uint16_t LowFLT, uint16_t HightFlt)
|
||||||
{
|
{
|
||||||
EALLOW;
|
EALLOW;
|
||||||
@ -448,24 +463,30 @@ void sdfmInitPwmFlt(uint16_t N, uint16_t LowFLT, uint16_t HightFlt)
|
|||||||
void sdfmGetResult(uint16_t N)
|
void sdfmGetResult(uint16_t N)
|
||||||
{
|
{
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
int32_t OffsetCount = 0;
|
|
||||||
|
|
||||||
FilterResult[N][loopCounter[N]] = *SdfmReadData[N];
|
|
||||||
sdfmAdc[N] = FilterResult[N][loopCounter[N]] - sdfmOffset[N];
|
FilterResult[N] = *SdfmReadData[N];
|
||||||
|
sdfmAdc[N] = FilterResult[N] - sdfmOffset[N];
|
||||||
sdfmFiltr[N] = *SdfmReadFiltr[N];
|
sdfmFiltr[N] = *SdfmReadFiltr[N];
|
||||||
if((N != SDFM_U_DC)&(N != SDFM_BRAKE)) {
|
|
||||||
if(loopCounter[N] < MAX_SAMPLES) loopCounter[N]++;
|
if(NeedToBeInit[N])
|
||||||
|
{
|
||||||
|
if(loopCounter[N] < MAX_SAMPLES)
|
||||||
|
{
|
||||||
|
OffsetCount[N] += FilterResult[N];
|
||||||
|
loopCounter[N]++;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loopCounter[N] = 0;
|
loopCounter[N] = 0;
|
||||||
if(!initDone[N])
|
sdfmOffset[N] = OffsetCount[N]>>FILTER_BIT;
|
||||||
|
initDone[N] = 0xFF;
|
||||||
|
NeedToBeInit[N] = 0;
|
||||||
|
if( (initDone[SDFM_IA] == 0xFF) && (initDone[SDFM_IB] == 0xFF) && (initDone[SDFM_IC] == 0xFF))
|
||||||
{
|
{
|
||||||
for(i = 0; i <= (MAX_SAMPLES-1); i++) OffsetCount += FilterResult[N][i];
|
sdfmInitCurrentFault();
|
||||||
sdfmOffset[N] = OffsetCount>>FILTER_BIT;
|
AllInitDone = 1;
|
||||||
initDone[N] = 0xFF;
|
|
||||||
if( (initDone[SDFM_IA] == 0xFF) && (initDone[SDFM_IB] == 0xFF) && (initDone[SDFM_IC] == 0xFF)) AllInitDone = 1;
|
|
||||||
}
|
}
|
||||||
else if(initDone[N] != 0xFF) initDone[N]--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EALLOW;
|
EALLOW;
|
||||||
@ -517,8 +538,8 @@ uint16_t sdfmOverCurrentCounter = 0;
|
|||||||
|
|
||||||
void sdfmOverCurrent(void)
|
void sdfmOverCurrent(void)
|
||||||
{
|
{
|
||||||
// PWM_ABC_StopAllClose();
|
PWM_ABC_StopAllClose();
|
||||||
// vectorFault();
|
vectorFault();
|
||||||
sdfmOverCurrentCounter++;
|
sdfmOverCurrentCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -552,6 +573,7 @@ uint32_t IntFlags;
|
|||||||
|
|
||||||
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x1000 << i)) sdfmGetResult(i+4);
|
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x1000 << i)) sdfmGetResult(i+4);
|
||||||
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x100 << i)) sdfmErr(i+4);
|
for(i = 0; i < 4; i++) if((uint16_t)IntFlags & (0x100 << i)) sdfmErr(i+4);
|
||||||
|
if( (((uint16_t)IntFlags)&0xFF) != 0 ) sdfmOverCurrent();
|
||||||
|
|
||||||
Sdfm_clearFlagRegister(SDFM2,IntFlags);
|
Sdfm_clearFlagRegister(SDFM2,IntFlags);
|
||||||
sdfm_check_all_current_measurements_was_done();
|
sdfm_check_all_current_measurements_was_done();
|
||||||
|
|||||||
@ -77,6 +77,6 @@ int16_t sdfm_get(int16_t N);
|
|||||||
void SdfmTypeInit(void);
|
void SdfmTypeInit(void);
|
||||||
void sdfm_start_conversion_brake(void);
|
void sdfm_start_conversion_brake(void);
|
||||||
void sdfmInitPwmFlt(uint16_t N, uint16_t LowFLT, uint16_t HightFlt);
|
void sdfmInitPwmFlt(uint16_t N, uint16_t LowFLT, uint16_t HightFlt);
|
||||||
|
void sdfmStartInitCurrents(void);
|
||||||
|
|
||||||
#endif /* SRC_SDFM_H_ */
|
#endif /* SRC_SDFM_H_ */
|
||||||
|
|||||||
@ -30,7 +30,7 @@ __interrupt void spic_tx_isr(void);
|
|||||||
uint16_t rxBuff[BISS_C_BITS];
|
uint16_t rxBuff[BISS_C_BITS];
|
||||||
uint16_t indexRxBuff = 0;
|
uint16_t indexRxBuff = 0;
|
||||||
|
|
||||||
|
#define LSPCLK 100000000
|
||||||
|
|
||||||
void SpiAInit(void)
|
void SpiAInit(void)
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ void SpiAInit(void)
|
|||||||
// Set the baud rate using a 1 MHz SPICLK
|
// Set the baud rate using a 1 MHz SPICLK
|
||||||
// BRR = (LSPCLK / SPICLK) - 1
|
// BRR = (LSPCLK / SPICLK) - 1
|
||||||
//
|
//
|
||||||
SpiaRegs.SPIBRR.bit.SPI_BIT_RATE = ((50000000 / 1000000) - 1);
|
SpiaRegs.SPIBRR.bit.SPI_BIT_RATE = ((LSPCLK / 1000000) - 1);
|
||||||
|
|
||||||
// Set FREE bit
|
// Set FREE bit
|
||||||
// Halting on a breakpoint will not halt the SPI
|
// Halting on a breakpoint will not halt the SPI
|
||||||
@ -237,7 +237,7 @@ void SpiBInit(void)
|
|||||||
// Set the baud rate using a 1 MHz SPICLK
|
// Set the baud rate using a 1 MHz SPICLK
|
||||||
// BRR = (LSPCLK / SPICLK) - 1
|
// BRR = (LSPCLK / SPICLK) - 1
|
||||||
//
|
//
|
||||||
SpibRegs.SPIBRR.bit.SPI_BIT_RATE = ((50000000 / 1000000) - 1);
|
SpibRegs.SPIBRR.bit.SPI_BIT_RATE = ((LSPCLK / 1000000) - 1);
|
||||||
|
|
||||||
// Set FREE bit
|
// Set FREE bit
|
||||||
// Halting on a breakpoint will not halt the SPI
|
// Halting on a breakpoint will not halt the SPI
|
||||||
@ -401,7 +401,7 @@ void SpiCInit(void)
|
|||||||
// Set the baud rate using a 1 MHz SPICLK
|
// Set the baud rate using a 1 MHz SPICLK
|
||||||
// BRR = (LSPCLK / SPICLK) - 1
|
// BRR = (LSPCLK / SPICLK) - 1
|
||||||
//
|
//
|
||||||
SpicRegs.SPIBRR.bit.SPI_BIT_RATE = ((50000000 / 1000000) - 1);
|
SpicRegs.SPIBRR.bit.SPI_BIT_RATE = ((LSPCLK / 1000000) - 1);
|
||||||
|
|
||||||
// Set FREE bit
|
// Set FREE bit
|
||||||
// Halting on a breakpoint will not halt the SPI
|
// Halting on a breakpoint will not halt the SPI
|
||||||
|
|||||||
@ -9,10 +9,9 @@
|
|||||||
#include "frm_uart.h"
|
#include "frm_uart.h"
|
||||||
#include "SyncPWMFonRun.h"
|
#include "SyncPWMFonRun.h"
|
||||||
|
|
||||||
#define LSPCLK_HZ 50000000.0
|
#define LSPCLK_HZ 100000000.0
|
||||||
#define BAUD 57600.0
|
#define BAUD 38400.0
|
||||||
//#define BAUD 4000000.0
|
#define BRR LSPCLK_HZ/(BAUD*8)
|
||||||
#define BRR LSPCLK_HZ/(BAUD*8) + 1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -94,6 +94,7 @@ void InitPerif(void)
|
|||||||
FRMUartInit();
|
FRMUartInit();
|
||||||
#else
|
#else
|
||||||
UartInit();
|
UartInit();
|
||||||
|
UartInterruptInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ADCConfigure();
|
ADCConfigure();
|
||||||
|
|||||||
@ -9,12 +9,35 @@
|
|||||||
#include "f28x_project.h"
|
#include "f28x_project.h"
|
||||||
#include "uart_4Mbit.h"
|
#include "uart_4Mbit.h"
|
||||||
|
|
||||||
#define LSPCLK_HZ 50000000.0
|
#define LSPCLK_HZ 100000000.0
|
||||||
#define BAUD 4000000.0
|
#define BAUD 4000000.0
|
||||||
#define BRR LSPCLK_HZ/(BAUD*8) + 1
|
#define BRR LSPCLK_HZ/(BAUD*8)
|
||||||
|
|
||||||
|
//uint16_t AdcaResult0_[4096];
|
||||||
|
//uint16_t AdcaResult1_[4096];
|
||||||
|
|
||||||
|
//#pragma DATA_SECTION(AdcaResult0_,"ADC_RegsFile0");
|
||||||
|
//#pragma DATA_SECTION(AdcaResult1_,"ADC_RegsFile1");
|
||||||
|
|
||||||
|
uint16_t N = 0;
|
||||||
|
|
||||||
|
|
||||||
|
__interrupt void Uart_ISR(void)
|
||||||
|
{
|
||||||
|
// if(N < 4096) {AdcaResult0_[N] = SciaRegs.SCIRXBUF.all; N++;}
|
||||||
|
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UartInterruptInit(void)
|
||||||
|
{
|
||||||
|
EALLOW;
|
||||||
|
PieVectTable.SCIA_RX_INT = &Uart_ISR;
|
||||||
|
IER |= M_INT9;
|
||||||
|
PieCtrlRegs.PIEIER9.bit.INTx1 = 1;
|
||||||
|
PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;
|
||||||
|
EDIS;
|
||||||
|
SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void UartInit(void)
|
void UartInit(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -10,5 +10,6 @@
|
|||||||
|
|
||||||
void UartInit(void);
|
void UartInit(void);
|
||||||
void UartErrorReset(void);
|
void UartErrorReset(void);
|
||||||
|
void UartInterruptInit(void);
|
||||||
|
|
||||||
#endif /* SRC_UART_4MBIT_H_ */
|
#endif /* SRC_UART_4MBIT_H_ */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user