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.

MSP430FR6007: LEA usage issue

Part Number: MSP430FR6007

Hi team,

The customer has the following 2 questions when testing LEA:

1. The customer uses the result obtained by adc and directly multiplies by LEA, and the result is incorrect: (The complete code is here)

void main(void)
{
    msp_status status;
    msp_mpy_iq31_params mpyParams;
    msp_fft_iq31_params fftParams;
    
    // ----ADC Raw data ----------
    _q15 test[SAMPLES] = {22, 23, 17, 12, 15, 15, 17, 27, 24, 17, 17, 22, 18, 24, 24, 19, 18, 23, 21, 16, 16, 16, 14, 16, 24, 21, 13, 18, 17, 0, 10, 68, 79, -16, -95, -12, 170, 163, -95, -235, 20, 333, 204, -241, -355, 77, 475, 244, -338, -452, 114, 598, 282, -437, -547, 145, 688, 325, -475, -624, 114, 747, 385, -510, -691, 112, 817, 445, -531, -748, 101, 855, 470, -539, -782, 79, 868, 500, -541, -813, 58, 885, 522, -545, -831, 60, 896, 533, -527, -808, 53, 845, 477, -496, -682, 104, 676, 292, -376, -414, 74, 366, 198, -85, -153, -53, 52, 121, 136, 31, -152, -177, 70, 318, 211, -184, -374, -38, 431, 386, -174, -513, -134, 485, 475, -180, -567, -136, 497, 468, -162, -503, -144, 381, 400, -57, -377, -171, 271, 369, 14, -307, -194, 176, 310, 71, -210, -173, 106, 249, 88, -144, -138, 68, 192, 81, -91, -108, 36, 135, 72, -42, -61, 22, 96, 70, -11, -42, 9, 69, 56, -4, -25, 11, 49, 46, 7, -15, 13, 49, 41, 16, 6, 12, 26, 26, 8, -4, 10, 33, 35, 17, 11, 23, 23, 23, 20, 11, 11, 20, 31, 24, 16, 22, 24, 23, 24, 14, 12, 16, 22, 25, 22, 18, 17, 25, 26, 20, 16, 16, 20, 17, 21, 22, 14, 10, 18, 24, 19, 15, 17, 16, 22, 37, 28, 17, 12, 16, 28, 28, 9, 3, 19, 30, 20, 12, 14, 20, 26, 29, 22, 6, 14, 30, 40, 20};
    uint16_t i =0 ;

    /* Disable WDT */
    WDTCTL = WDTPW + WDTHOLD;

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

    /* Initialize input signal and Hamming window */
//    initSignal();
//    initHamming();
    //--------The ADC raw value is assigned to input here .
    for(i = 0; i < SAMPLES;i++){
        input[i] = test[i];
        window[i] = 2;
    }
    /* Multiply input signal by generated Hamming window */
    mpyParams.length = SAMPLES;
    //--------First multiply the original ADC value by 2, and the result here is not right 
    status = msp_mpy_iq31(&mpyParams, input, window, input);
    msp_checkStatus(status);
    
   //--------------Because the previous calculation is incorrect, does the FFT have any meaning here? 
    /* Initialize the fft parameter structure. */
    fftParams.length = SAMPLES;
    fftParams.bitReverse = 1;
    fftParams.twiddleTable = msp_cmplx_twiddle_table_256_q15;

    /* Perform real FFT with no scaling */
    msp_benchmarkStart(MSP_BENCHMARK_BASE, 64);
    status = msp_fft_iq31(&fftParams, input);
    cycleCount = msp_benchmarkStop(MSP_BENCHMARK_BASE);
    msp_checkStatus(status);
    
    /* End of program. */
    __no_operation();
}

2. How to multiply the result of the ADC acquisition int integer data LEA, if it's needed to convert to use? This conversion is very time consuming if using an operational conversion. Is it possible to provide relevant application cases for reference?

Could you help resolve this case? Thanks!

Best Regards,

Cherry

  • Hello Cherry,

    The DSPLib function for multiply is really supposed to be utilized for multiplying two different vectors. If you are just doing a multiply by 2 to all of your ADC results, it would be faster just to do a left shift by one bit.

    I also see you are mixing the different data types. You are utilizing iQ31 commands, but define your test vector as Q15 format. Your formats would need to be the same to have the correct results. 

**Attention** This is a public forum