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 使用问题

Part Number: MSP430FR6007

Hi ,

我这里有个客户正在使用MSP430FR6007做水表主控。现在客户测试LEA遇到如下问题,请帮忙协助分析。

1. 客户用adc采集的结果,直接用LEA做乘法的时候计算,结果不正确。完整的代码如附件,请协助分析。DSPLib20211103-Test.zip

void main(void)
{
    msp_status status;
    msp_mpy_iq31_params mpyParams;
    msp_fft_iq31_params fftParams;
    
    // ----ADC原始数据----------
    _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();
    //--------这里将ADC原始值付给input.
    for(i = 0; i < SAMPLES;i++){
        input[i] = test[i];
        window[i] = 2;
    }
    /* Multiply input signal by generated Hamming window */
    mpyParams.length = SAMPLES;
    //--------首先将原始ADC值乘以2,这里不知道为什么得到的结果不对????
    status = msp_mpy_iq31(&mpyParams, input, window, input);
    msp_checkStatus(status);
    
   //--------------因为上步计算结果不正确,这里的FFT就没有任何意义????
    /* 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.如何将ADC采集的结果int 整型数据LEA乘法运算,是否要进行转换才能使用?这个转换如果使用运算转换非常耗时。贵司是否有相关应用案例可以参考。