该项目是公司新开发的无刷项目,用的是dsp28035芯片,主要控制部分是在cla运行,在debug条件下调试运行正常,拔掉debug后单片机就运行部正常了,但是主cpu中的ADC 采样和can io都控制正常,就是cla部分运算输出pwm不正常了!!请高手解答下!!下面是我的CMD文件和cla部分初始化!以及map表!
void CLA_C_Init()
{
// This code assumes the CLA clock is already enabled in
// the call to DevInit();
//
// EALLOW: is needed to write to EALLOW protected registers
// EDIS: is needed to disable write to EALLOW protected registers
//
// The symbols used in this calculation are defined in the CLA
// assembly code and in the CLAShared.h header file
EALLOW;
Cla1Regs.MVECT1 = ((Uint16)Cla1Task1 – (Uint16)&Cla1Prog_Start);
Cla1Regs.MVECT2 = ((Uint16)Cla1Task2 – (Uint16)&Cla1Prog_Start);
Cla1Regs.MVECT3 = ((Uint16)Cla1Task3 – (Uint16)&Cla1Prog_Start);
Cla1Regs.MVECT4 = ((Uint16)Cla1Task4 – (Uint16)&Cla1Prog_Start);
Cla1Regs.MVECT5 = ((Uint16)Cla1Task5 – (Uint16)&Cla1Prog_Start);
Cla1Regs.MVECT6 = ((Uint16)Cla1Task6 – (Uint16)&Cla1Prog_Start);
Cla1Regs.MVECT7 = ((Uint16)Cla1Task7 – (Uint16)&Cla1Prog_Start);
Cla1Regs.MVECT8 = ((Uint16)Cla1Task8 – (Uint16)&Cla1Prog_Start);
// Copy the CLA program code from its load address to the CLA program memory
// Once done, assign the program memory to the CLA
//
// Make sure there are at least two SYSCLKOUT cycles between assigning
// the memory to the CLA and when an interrupt comes in
// Call this function even if Load and Run address is the same!
MemCopy(&Cla1funcsLoadStart, &Cla1funcsLoadEnd, &Cla1funcsRunStart);
asm(" RPT #3 || NOP");
Cla1Regs.MMEMCFG.bit.PROGE = 1; // Configure the RAM as CLA program memory
Cla1Regs.MMEMCFG.bit.RAM0E = 1; // configure RAM L1, F28035 as CLA Data memory 0
Cla1Regs.MMEMCFG.bit.RAM1E = 1; // Configure RAM L2, F28035 as CLA data memory 1
// Enable the IACK instruction to start a task
// Enable the CLA interrupt 8 and interrupt 2
asm(" RPT #3 || NOP");
Cla1Regs.MCTL.bit.IACKE = 1;
Cla1Regs.MIER.all = M_INT8;
// No need to wait, the task will finish by the time
// we configure the ePWM and ADC modules
Cla1ForceTask8();
EDIS;
}
void main(void)
{
DeviceInit(); // Device Life support & GPIO
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
InitFlash(); // Call the flash wrapper init function
EALLOW;
PieVectTable.TINT0 = &cpu_timer0_isr;
PieVectTable.TINT1 = &cpu_timer1_isr;
PieVectTable.TINT2 = &cpu_timer2_isr;
EDIS;
InitCpuTimers(); // For this example, only initialize the Cpu Timers
// Configure CPU-Timer 0 to interrupt every 500 milliseconds:
// 60MHz CPU Freq, 50 millisecond Period (in uSeconds)
ConfigCpuTimer(&CpuTimer0, 60, 2000);
ConfigCpuTimer(&CpuTimer1, 60, 1000000);
ConfigCpuTimer(&CpuTimer2, 60, 1000000);
CpuTimer0Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0
CpuTimer1Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0
CpuTimer2Regs.TCR.all = 0x4000; // Use write-only instruction to set TSS bit = 0
VTimer0[0] = 0;
VTimer1[0] = 0;
VTimer2[0] = 0;
SigCom_CanGpioInit();
SigCom_CanInit();
CLA_C_Init();
QEP_INIT_CNF();
DRV8301_SPI_Init(&SpibRegs);
// Configure PWM for the Inverter, pass period and dead band
PWM_3phInv_CNF(1,2,3,3000,100)
// for profiling
// PWM_1ch_CNF(4,18740,0,0);
//PWM_1ch_CNF(5,18740,0,0);
InitEPwm5Example();
ChSel[0] = 4; // A4 – 电池电压,
ChSel[1] = 2; // A2 – 母线电流,
ChSel[2] = 10; // B2 – 继电器后端电压
ChSel[3] = 6; // A7 -A相电流
ChSel[4] = 14; // A7 -B相电流
ChSel[5] = 3; // A7 -C相电流
// Select Trigger Event
TrigSel[0]= ADCTRIG_EPWM1_SOCA;
TrigSel[1]= ADCTRIG_EPWM1_SOCA;
TrigSel[2]= ADCTRIG_EPWM1_SOCA;
TrigSel[3]= ADCTRIG_EPWM1_SOCA;
TrigSel[4]= ADCTRIG_EPWM1_SOCA;
TrigSel[5]= ADCTRIG_EPWM1_SOCA;
ADC_SOC_CNF(ChSel,TrigSel,ACQPS,1,2); // use auto clr ADC int flag mode
// Set up Event Trigger with CNT_zero enable for Time-base of EPWM1 SOC
EPwm1Regs.ETSEL.bit.SOCAEN = 1; // Enable SOCA
EPwm1Regs.ETSEL.bit.SOCASEL = 2;//ET_CTR_ZERO; // Enable CNT_zero event for SOCA
EPwm1Regs.ETPS.bit.SOCAPRD = ET_1ST; // Generate SOCA on the 1st event
EPwm1Regs.ETCLR.bit.SOCA = 1; // Clear SOCA flag
ELECTANG_CLA_INIT_MACRO(elect_angle)
// Commands from the C28x to the CLA
// These variable are in the CPUtoCLAMsgRAM
while(AdcResult.ADCRESULT2<=700)
{}
DSP28x_usDelay(20000);
EPwm5Regs.CMPB = 87; // Set Compare B value
GpioDataRegs.GPBSET.bit.GPIO39 = 0;
DSP28x_usDelay(50000); //delay to allow DRV830x supplies to ramp up
//write to DRV8301 control register 1, returns status register 1
DRV8301_cfg();
DRV8301_stat_reg1.all = DRV8301_SPI_Write(&SpibRegs,CNTRL_REG_1_ADDR,DRV8301_cntrl_reg1.all);
DRV8301_stat_reg1.all = DRV8301_SPI_Write(&SpibRegs,CNTRL_REG_2_ADDR,DRV8301_cntrl_reg2.all);
lsw=0;
/*初始化角度*/
elect_angle.InHall=(GpioDataRegs.GPBDAT.bit.GPIO40<<2)|(GpioDataRegs.GPBDAT.bit.GPIO41<<1)|(GpioDataRegs.GPBDAT.bit.GPIO42);
Elect_AngEst(elect_angle)
ELECTANG_CLA_MACRO(elect_angle)
Pid_iq_kp=(1);
Pid_iq_ki=(0.0025);
Pid_id_kp=(1);
Pid_id_ki=(0.0025);
Pid_speed_kp=(1.5);
Pid_speed_ki=(0.005);
SpeedRef=0.0;
VqTesting=0.00;
VdTesting=0.0;
IqRef=0.00;
IdRef=0.0;
EnableFlag=1;
EALLOW;
Cla1Regs.MPISRCSEL1.bit.PERINT1SEL = 0 ; // 0=ADCINT1 1=none 2=EPWM1INT
Cla1Regs.MIER.all = M_INT1;
IER |= M_INT1;
IER |= M_INT13;
IER |= M_INT14;
// Enable TINT0 in the PIE: Group 1 interrupt 7
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
asm(" RPT #3 || NOP");
EDIS;
Cla1ForceTask1andWait();
}