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:静态内联函数在 CLA 中执行不好

Guru**** 2595805 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1074098/tms320f28379d-static-inline-function-is-not-executed-well-in-the-cla

部件号:TMS320F28379D

尊敬的 TI:

我正在使用 CLA 执行此静态内联函数:

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;
    }
    
}

CLA 任务中的呼叫功能如下:

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

监视表达式如下:

问题是,即使使用相同的代码来移动 Pol_S,某些向量也不会移动?

Poly_R 缓冲区不应为空,因为 R_Input 是 IDC_CLA 10.11,我们在 watch 表达式中看到,Enable_CLA 是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];

这项功能似乎没有得到遵守或正确执行吗?  

你有什么想法吗?

提前感谢您,

S.Tarik

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,S. Tarik,

    您能否在禁用优化的情况下逐步了解代码? 这可能有助于发现问题。

    谢谢,

    阿什维尼

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,Ashwini,

    这就是我们已经应用了 O2,因为我们正在使用内联函数。

    此代码已在 C2000中执行,并且在相同的优化级别下工作。

    S.Tarik

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好,

    如果我理解正确,那么在 C28上编译和执行的相同代码在 O2上可以正常工作。 但是,CLA 在优化 O2方面没有达到预期效果。 代码是否在 CLA 上运行而未进行优化? 您可以更改 CLA 文件级别的优化,而不是整个程序来尝试此操作。

    只要看一下代码 ,我就不会看到任何明显的问题。 尝试的其他方法是对 unroll pragma 进行注释,以查看它是否会对 CLA 产生影响。

    谢谢,
    阿什维尼