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.

CCS/MSP430FR6047: DSP LEA command

Part Number: MSP430FR6047


Tool/software: Code Composer Studio

Hello LEA expert:

What does the LEACMD__POLYNOMIAL command and associated structure MSP_LEA_POLY_PARAMS mean?

Can you give an example of what the polynomial coefficient vector and the polynomial coefficient order represent respectively?

Can you give me an example of this command?

  • Hello LEA expert:

    software-dl.ti.com/.../structMSP__LEA__POLY__PARAMS.html

    The above URL is where the command is located.

  • Hello,

    An example of the operation of the function is

    y =scaleFactor*(p4x4 + p3x3 + p2x2 + p1x1 + p0)  where coeff = [ppppp4] and order = 4 is the polynomial order and x is the input & y is stored in output

    Srinivas

  • Hello Srinivas Lingam,

    The coeff is defined as a uint16_t, not an array.

    How can I convert [P0 P1 P2 P3 P4] to a uint16_t.

  • Hello,

    It is cast internally as a uint16_t*.

    You will notice the same with the declaration for the output. Even though it is declared as uint16_t, it is internally used as a uint16_t*. I think it is cast internally inside the DSPLIB accordingly. You can see similar declaration with all the other functions.

    Srinivas

  • Hello Srinivas Lingam,

    On FR6047, I modify the contents of matrix_ex1_add_q15.c in DSPLib_1_30_00_02\examples\Matrix as follows

    Why the content of result is 20005 instead of 28693?

    I don't know what's wrong with my code. Please help me, thank you!

    // p4 = 20004 * 2^-15 = 0.610473633

    // p3 = 20003 * 2^-15 = 0.610443115

    // p2 = 20002 * 2^-15 = 0.610412598

    // p1 = 20001 * 2^-15 = 0.61038208

    // p0 = 20000 * 2^-15 = 0.610351563

    // scaleFactor = 20006 * 2^-15 = 0.610534668

    // order = 4

    // x = 20005* 2^-15 = 0.61050415

    /* Input x */
    DSPLIB_DATA(inputA,4)
    _q15 inputA;

    /* Input coeff */
    DSPLIB_DATA(inputB,4)
    _q15 inputB[5];

    /* Result y */
    DSPLIB_DATA(result,4)
    _q15 result;

    void polynomial_q15(const _q15 *srcA, const _q15 *srcB, _q15 *dst)
    {
        MSP_LEA_POLY_PARAMS *leaParams;

        /* Initialize LEA if it is not enabled. */
        if (!(LEAPMCTL & LEACMDEN)) {
            msp_lea_init();
        }
            
        /* Allocate MSP_LEA_POLY_PARAMS structure. */
        leaParams = (MSP_LEA_POLY_PARAMS *)msp_lea_allocMemory(sizeof(MSP_LEA_POLY_PARAMS)/sizeof(uint32_t));

        /* Set MSP_LEA_POLY_PARAMS structure. */
        
        
        leaParams->output = MSP_LEA_CONVERT_ADDRESS(dst);
        leaParams->coeff = MSP_LEA_CONVERT_ADDRESS(srcB);
        leaParams->order = 4;
        leaParams->scaleFactor = 20006; // 20006 * 2^-15

        /* Load source arguments to LEA. */
        LEAPMS0 = MSP_LEA_CONVERT_ADDRESS(srcA);
        LEAPMS1 = MSP_LEA_CONVERT_ADDRESS(leaParams);

        /* Invoke the LEACMD__POLYNOMIAL command. */
        msp_lea_invokeCommand(LEACMD__POLYNOMIAL);

        /* Free MSP_LEA_POLY_PARAMS structure. */
        msp_lea_freeMemory(sizeof(MSP_LEA_POLY_PARAMS)/sizeof(uint32_t));

        /* Free lock for LEA module and return status. */
        msp_lea_freeLock();
        return;
    }

    void main(void)
    {
        /* Disable WDT. */
        WDTCTL = WDTPW + WDTHOLD;

    #ifdef __MSP430_HAS_PMM__
        /* Disable GPIO power-on default high-impedance mode for FRAM devices */
        PM5CTL0 &= ~LOCKLPM5;
    #endif

        inputA = 20005; // 20005 * 2^-15
        inputB[0] = 20000; // 20000 * 2^-15
        inputB[1] = 20001; // 20001 * 2^-15
        inputB[2] = 20002; // 20002 * 2^-15
        inputB[3] = 20003; // 20003 * 2^-15
        inputB[4] = 20004; // 20004 * 2^-15
        polynomial_q15(&inputA, inputB, &result);
        
        /* End of program. */
        __no_operation();
    }

  • Hello Srinivas Lingam,

    On FR6047, I didn't get the right result.

  • Hello,

    I checked with our SW team and their recommendation is to use only those LEA commands that are mentioned in http://www.ti.com/lit/pdf/SLAA720 or http://www.ti.com/lit/pdf/SLAA698 . The LEACMD__POLYNOMIAL is not included in any of those lists supported by LEA. Sorry for the confusion.

    Srinivas

**Attention** This is a public forum