This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28379D: Static inline function is not executed well in the CLA

Part Number: TMS320F28379D


Dear TI,

I am using the CLA to execute this static inline function:

static inline void RST_Regulor(float R_Input, float S_Input, float T_Input,
                               uint16_t RST_Enable, float oldActu, float *Output)
{
    uint16_t i;
    /*******************************************
     *             Compute T polynome          *
     *******************************************/
     /* Shift the delay line to the right by 1 */
    for(i = SIZE_OF_T-1; i > 0; i--)
    {
        /* Shift */
        Poly_T[i] = Poly_T[i-1];

        /* Multiplication and Addition*/
        T  += coef_t[i] * Poly_T[i];
    }
    /* Get adc physical input into start of the delay line */
    /* note the adc input is simulated in software */
    if (RST_Enable == 1u)
    {
        Poly_T[0] = T_Input; //reference
    }
    else
    {
        Poly_T[0] = R_Input; //measured
    }
    
    /*Add the first param */
    T  += coef_t[0] * Poly_T[0];

    /*******************************************
     *             Compute R polynome          *
     *******************************************/
    /* Shift the delay line to the right by 1 */
    #pragma UNROLL(SIZE_OF_R-1)
    for(i = SIZE_OF_R-1; i > 0; i--)
    {
        /* Shift */
        Poly_R[i] = Poly_R[i-1];

        /*Multiplication and Addition*/
        R   += coef_r[i] * Poly_R[i];
    }
    /* Get adc physical input into start of the delay line */
    /* note the adc input is simulated in software */
    Poly_R[0] = R_Input;
    R  += coef_r[0] * Poly_R[0];

    /*******************************************
     *             Compute S polynome          *
     *******************************************/
     //Shift the delay line to the right by 1
    #pragma UNROLL(SIZE_OF_S-1)
    for(i = SIZE_OF_S-1; i > 0; i--)
    {
        /* Shift */
        Poly_S[i] = Poly_S[i-1];

        /* Multiplication and Addition*/
        S   += coef_s[i] * Poly_S[i];
    }
    /* Get adc physical input into start of the delay line */
    /* note the adc input is simulated in software */
    Poly_S[0] = oldActu;
    S  += coef_s[0] * Poly_S[0];

    /**** Result*****/
    if(RST_Enable == 1u)
    {
        /* Regulation output if enable*/
        *Output = (T - R - S) * INVERS_S0;
    }
    else
    {
        /* Old value if RST regulation is not enabled */
        *Output = oldActu;
    }
    
}

The Call function in the CLA task is the following:

    /* RST regulation */
    RST_Regulor(IDC_CLA,                    //R
                CLA_StaActu,                //S
                Ref_CLA,                    //T
                Enable_CLA,                 //Enable
                CLA_StaActu,                //Old actuation
                &DutyCycleMan);             //RST output regulation

The watch expression is the following:

The problem is, some vectors are not shifted even if the same code is used to shift the Poly_S?

The Poly_R buffer should not be null because the R_Input is the IDC_CLA 10.11 and we see this in the watch expression, Enable_CLA is 1?

    #pragma UNROLL(SIZE_OF_R-1)
    for(i = SIZE_OF_R-1; i > 0; i--)
    {
        /* Shift */
        Poly_R[i] = Poly_R[i-1];

        /*Multiplication and Addition*/
        R   += coef_r[i] * Poly_R[i];
    }
    /* Get adc physical input into start of the delay line */
    /* note the adc input is simulated in software */
    Poly_R[0] = R_Input;
    R  += coef_r[0] * Poly_R[0];

Does it seem that the function is not complied with or executed correctly? 

Do you have any idea how this could happen, please?

Thank you in advance,

S.Tarik

  • Hi S. Tarik,

    Can you step through the code with optimization disabled? That might help reveal the issue.

    Thanks,

    Ashwini

  • Hi Ashwini,

    This thing is we already applied O2 because we are using an inline function.

    This code is already executed in the C2000 and it works with the same optimization level.

    S.Tarik

  • Hi,

    If I understand correctly, the same code compiled and executed on C28 works correctly at O2. But the CLA is not working as expected with O2 optimization. Does the code work on CLA without optimization? You can change the optimization at the CLA file level instead of the entire program to try this out.

    Just by looking at the code  I don't see any obvious issues. Other possibilities to try is to comment out the UNROLL pragma to see if that is making a difference on CLA.

    Thanks,
    Ashwini