Tool/software: Code Composer Studio
Hi, I came across a problem, could you please help me?
I'm currently using 28069 and using CLA to calculate the RMS value of the data read from ADC. The code is shown below
__interrupt void Cla1Task3 ( void )
{
v_ac = 3.3*AC_VOLTAGE_GAIN*(AdcResult.ADCRESULT2-AC_VOLTAGE_BIAS)/4095;
rms_v_ac_sum += v_ac*v_ac;
rms_count++;
if(rms_count >= COUNT_FOR_RMS_CALC){
rms_v_ac = __sqrt(rms_v_ac_sum/rms_count);
rms_count = 0;
rms_v_ac_sum = 0;
}
}
At first, everything worked fine, until I modified a data from CPU,which is shown below. In this code, I calculated the phase and modified the "input_state" accordingly.
interrupt void pwm_int()
{
PLL();
if(theta>phase1 && prev_theta<phase1){
EALLOW;
GpioDataRegs.GPADAT.bit.GPIO23 = 1;
EDIS;
if(!protect_flag){
input_state = POS;
action_at_pos1();
}
}
prev_theta = theta;
EPwm1Regs.ETCLR.bit.INT = 1;
// Acknowledge this interrupt to receive more interrupts from group 3
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
I
I found that the CLA fails to calculate the RMS value correctly and I found this problem is associated with "input_state" and input_state is defined as below
#pragma DATA_SECTION(input_state,"Cla1DataRam1"); unsigned char input_state;
if I change its data_section to "CpuToCla1MsgRAM", the CLA works fine again. So I guess maybe CPU modifying the data existing in this data section causes the problem but I don't know why, can you help me please?
the CLA initialization code is shown below
void initCLA(){
EALLOW;
Cla1Regs.MVECT1 = (Uint16) ((Uint32)&Cla1Task1 - (Uint32)&Cla1Prog_Start);
Cla1Regs.MVECT2 = (Uint16) ((Uint32)&Cla1Task2 - (Uint32)&Cla1Prog_Start);
Cla1Regs.MVECT3 = (Uint16) ((Uint32)&Cla1Task3 - (Uint32)&Cla1Prog_Start);
Cla1Regs.MVECT4 = (Uint16) ((Uint32)&Cla1Task4 - (Uint32)&Cla1Prog_Start);
Cla1Regs.MVECT5 = (Uint16) ((Uint32)&Cla1Task5 - (Uint32)&Cla1Prog_Start);
Cla1Regs.MVECT6 = (Uint16) ((Uint32)&Cla1Task6 - (Uint32)&Cla1Prog_Start);
Cla1Regs.MPISRCSEL1.bit.PERINT1SEL = CLA_INT1_ADCINT1;
Cla1Regs.MPISRCSEL1.bit.PERINT2SEL = CLA_INT2_ADCINT2;
Cla1Regs.MPISRCSEL1.bit.PERINT3SEL = CLA_INT3_ADCINT3;
Cla1Regs.MPISRCSEL1.bit.PERINT4SEL = CLA_INT4_ADCINT4;
memcpy(&Cla1funcsRunStart, &Cla1funcsLoadStart, (Uint32)&Cla1funcsLoadSize);
Cla1Regs.MMEMCFG.bit.PROGE = 1;
Cla1Regs.MCTL.bit.IACKE = 1;
Cla1Regs.MIER.all = (M_INT1 | M_INT2 | M_INT3 | M_INT4 | M_INT5 | M_INT6);
EALLOW;
Cla1Regs.MMEMCFG.all = CLA_PROG_ENABLE|CLARAM0_ENABLE|CLARAM1_ENABLE|CLARAM2_ENABLE|CLA_RAM1CPUE;
Cla1Regs.MCTL.bit.IACKE = 1;
EDIS;
}
Best Regards