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/MSP-EXP430FR5994: BOOSTXL-AUIDIO EXAMPLE FFT

Part Number: MSP-EXP430FR5994
Other Parts Discussed in Thread: MSP430FR5994, MSP430WARE

Tool/software: Code Composer Studio

Hi everyone.

I have been playing with the msp430fr5994 for 2 months. I'm still learning C so sorry if my questions are obvious.

First of all i'm very confussed with the adc data. The values are (for expample) between -31472 and 22992. I can´t undestand it if the adc is 12 bits.

The second one is about the variable status wich is the return from de fft function. I can't si it on the watch window, why?

The last one is about the LEA memory. In the .map appears the length, and for the LEARAM is 0x00000ec8, 3784 bytes, why is not 4096? what is LEASTACK? if the real memory available is less than 4kb, which is the maximum fft possible?

Thank you.

Marcos.

  • Hi Marcos, 

    Marcos Llorente said:
    First of all i'm very confussed with the adc data. The values are (for expample) between -31472 and 22992. I can´t undestand it if the adc is 12 bits.

    It's important to note that in this example, the ADC is setup to store the results in two's complement format.  This is done at approximately line 127 in the audio_collect.c file. So theoretically, when the ADC input voltage is -Vref the result is 0x8000 which is the two's complement representation of -32768. Similarly when the ADC input voltage is +Vref, the result is 0x7FF0 which is +32752. So when you consider that an audio signal is a sinusoidal wave, you will see voltage at the ADC input that periodically dips "negative" and then goes back to positive. You can learn more about two's complement representation of numbers here: 

    Marcos Llorente said:
    The second one is about the variable status wich is the return from de fft function. I can't si it on the watch window, why?

    The compiler is most likely optimizing the code in a way that the "status" variable is not used or defined anymore. If you turn off optimizations completely, you'll be able to view this variable in the Expressions window. 

    Marcos Llorente said:
    The last one is about the LEA memory. In the .map appears the length, and for the LEARAM is 0x00000ec8, 3784 bytes, why is not 4096? what is LEASTACK?

    LEA RAM is 4KB in length. When viewing the .map file you've already noticed that some memory is allocated to the LEA stack. In reality the LEA module is a CPU that is independent of the MSP430 CPU. It performs operations and requires the use of a stack just like the MSP430 CPU to be able to call functions and return successfully. You can read more on the purpose of a stack in computing here: 

    Marcos Llorente said:
    if the real memory available is less than 4kb, which is the maximum fft possible?

    This is determined by the ability to align data to the appropriate borders within the LEA memory. For example, the msp_fixed_fft_q15 function requires the input data to be aligned to a 2*(input data length) boundary. This means that a 512 point FFT must be aligned to a memory boundary that is a multiple of 1024. Similarly, the largest FFT supported by LEA is a 2048 point FFT because it must be aligned to a memory boundary that is a multiple of 4096. Anything larger than this does not have a valid memory boundary within LEA RAM. For example a 4096 point FFT would need to be aligned to a memory location that's a multiple of 8192 but there is no memory location in LEA RAM (0x2C00-0x3BFF) that fits this requirement.

    Fortunately, this isn't something you need to do by hand. TI provides  predefined macros with DSPLIB that will perform the data alignment for you and let you know whether the data will fit into LEA RAM at compile time. You can learn more about data alignment, considerations when using LEA, and other functions supported by LEA in the DSPLIB User's Guide

    Hope this helps and let me know if you have any follow-up questions. 

    Best regards, 
    Caleb Overbay

  • Thanks for the reply.


    I still have doubts about fft. to run the msp_fixed_fft_q15 function requires the input data to be aligned to a 2*(input data length) boundary. So If I choose a 2048 point fft I need 4096 bytes and LEA RAM haven't got that because of the LEASTACK. Therefore, the maximum size will be 1024 point for fft using msp_fixed_fft_q15 function .

    To check it I downloaded the transform_ex1_fft_fixed_q15 example to modify it and try different sizes. Unfortunately the example didn't work. When I try to debug the code and suspend the debug, the code is always at the same line:

    case MSP_LEA_INCORRECT_REVISION:
    /* LEA incorrect revision, loop forever. */
    while(true) __no_operation();

    Why? I haven't modified the code.

    I also tried changing the bootxl-audio example code, #define VECTOR_SIZE inside FFT.h , to try a bigger fft. The result is status=MSP_LEA_OUT_OF_RANGE.

    Could you check if transform_ex1_fft_fixed_q15 example is ok?

    I would be very grateful if you could provide a code that works with a msp_fixed_fft_q15 using 1024 points.


    Best regards.
    Marcos.
  • Hi Marcos, 

    Marcos Llorente said:
    So If I choose a 2048 point fft I need 4096 bytes and LEA RAM haven't got that because of the LEASTACK. Therefore, the maximum size will be 1024 point for fft using msp_fixed_fft_q15 function

    I think you're confusing data alignment with amount of memory required. Aligning data to a 4096 boundary does not mean the data has to consume 4096 bytes. it only means that the starting address of that data must be evenly divisible by 4096. 

    Marcos Llorente said:
    case MSP_LEA_INCORRECT_REVISION:
    /* LEA incorrect revision, loop forever. */
    while(true) __no_operation();

    This seems like you may have an outdated version of DPSLIB or DRIVERLIB. Can you ensure you've downloaded and installed that latest CCS and MSP430Ware versions?

    Best regards, 
    Caleb Overbay

  • Hi.

    I have checked the versions and I have the lastest ones. Also I have tried the code in CCS Cloud with the same result.

    Could you check it?

    Best regards.

    Marcos.

  • Hi Marcos,

    You probably have rev. A silicon which requires you to add a predefined symbol to the compiler options. Under compiler options, select the predefined symbols and add the following to the list of predefined names:

    MSP_LEA_REVISION=0

    By default DSPLib will set MSP_LEA_REVISION=1 which is for rev. B silicon when MSP_LEA_REVISION is not explicitly defined in the compiler options. The source code must be built for the correct revision in order to provide workarounds for LEA functions that have changed between revisions. If the LEA version does not match what the library is built against you may get unexpected results which is why the code returns the MSP_LEA_INCORRECT_REVISION status and traps execution.

    The LEA section of the DSPLib Users Guide has more information and sample code to check the revision (link).

    Regards,

    Brent

  • Thank you for the attention.

    I have solve the problem, I don't know exactly how, but it's solved. Now I'm able to debug and analyze what msp_fft_fixed_q15 returns. I have found that the status variable is MSP_SIZE_ERROR when it is supoused to be MSP_SUCCESS. Why? How is the fft result affected?

    I am very grateful for your help.

    Marcos.
  • Hi Marcos,

    The error you're receiving means you have passed an incorrect size to the msp_fft_fixed_q15 function. Did you make any changes to the example project? It might be helpful if you posted your code using the syntax highlighter so I can double check if there are any bugs.

    Best regards,
    Caleb Overbay
  • This is the original code

    //******************************************************************************
    // Real FFT with fixed scaling.
    //
    // Brent Peterson, Jeremy Friesenhahn
    // Texas Instruments Inc.
    // April 2016
    //******************************************************************************
    #include "msp430.h"
    #include <math.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include "DSPLib.h"
    /* Input signal parameters */
    #define FS                  8192
    #define SAMPLES             256
    #define SIGNAL_FREQUENCY1   200
    #define SIGNAL_AMPLITUDE1   0.6
    #define SIGNAL_FREQUENCY2   2100
    #define SIGNAL_AMPLITUDE2   0.15
    /* Hamming window parameters */
    #define HAMMING_ALPHA       0.53836
    #define HAMMING_BETA        0.46164
    /* Constants */
    #define PI                  3.1415926536
    /* Generated Hamming window function */
    DSPLIB_DATA(window,4)
    _q15 window[SAMPLES];
    /* Input signal and FFT result */
    DSPLIB_DATA(input,MSP_ALIGN_FFT_Q15(SAMPLES))
    _q15 input[SAMPLES];
    /* Temporary data array for processing */
    DSPLIB_DATA(temp,4)
    _q15 temp[3*SAMPLES/2];
    /* Benchmark cycle counts */
    volatile uint32_t cycleCount;
    /* Function prototypes */
    extern void initSignal(void);
    extern void initHamming(void);
    void main(void)
    {
        msp_status status;
        msp_mpy_q15_params mpyParams;
        msp_fft_q15_params fftParams;
        /* Disable WDT */
        WDTCTL = WDTPW + WDTHOLD;
        
        /* Initialize input signal and Hamming window */
        initSignal();
        initHamming();
        /* Multiply input signal by generated Hamming window */
        mpyParams.length = SAMPLES;
        status = msp_mpy_q15(&mpyParams, input, window, input);
        msp_checkStatus(status);
        /* Initialize the fft parameter structure. */
        fftParams.length = SAMPLES;
        fftParams.bitReverse = true;
        fftParams.twiddleTable = msp_cmplx_twiddle_table_256_q15;
        /* Perform real FFT with fixed scaling */
        msp_benchmarkStart(MSP_BENCHMARK_BASE, 16);
        status = msp_fft_fixed_q15(&fftParams, input);
        cycleCount = msp_benchmarkStop(MSP_BENCHMARK_BASE);
        msp_checkStatus(status);
    
        /* End of program. */
        __no_operation();
    }
    void initSignal(void)
    {
        msp_status status;
        msp_add_q15_params addParams;
        msp_sinusoid_q15_params sinParams;
        /* Generate Q15 input signal 1 */
        sinParams.length = SAMPLES;
        sinParams.amplitude = _Q15(SIGNAL_AMPLITUDE1);
        sinParams.cosOmega = _Q15(cosf(2*PI*SIGNAL_FREQUENCY1/FS));
        sinParams.sinOmega = _Q15(sinf(2*PI*SIGNAL_FREQUENCY1/FS));
        status = msp_sinusoid_q15(&sinParams, input);
        msp_checkStatus(status);
        /* Generate Q15 input signal 2 to temporary array */
        sinParams.length = SAMPLES;
        sinParams.amplitude = _Q15(SIGNAL_AMPLITUDE2);
        sinParams.cosOmega = _Q15(cosf(2*PI*SIGNAL_FREQUENCY2/FS));
        sinParams.sinOmega = _Q15(sinf(2*PI*SIGNAL_FREQUENCY2/FS));
        status = msp_sinusoid_q15(&sinParams, temp);
        msp_checkStatus(status);
        /* Add input signals */
        addParams.length = SAMPLES;
        status = msp_add_q15(&addParams, input, temp, input);
        msp_checkStatus(status);
    }
    void initHamming(void)
    {
        msp_status status;
        msp_sub_q15_params subParams;
        msp_copy_q15_params copyParams;
        msp_fill_q15_params fillParams;
        msp_sinusoid_q15_params sinParams;
        /* Generate sinusoid for cosine function */
        sinParams.length = 3*SAMPLES/2;
        sinParams.amplitude = _Q15(HAMMING_BETA);
        sinParams.cosOmega = _Q15(cosf(2*PI/(SAMPLES-1)));
        sinParams.sinOmega = _Q15(sinf(2*PI/(SAMPLES-1)));
        status = msp_sinusoid_q15(&sinParams, temp);
        msp_checkStatus(status);
        /* Shift sinusoid by pi/2 to create cosine function */
        copyParams.length = SAMPLES;
        status = msp_copy_q15(&copyParams, &temp[SAMPLES/4], &temp[0]);
        msp_checkStatus(status);
        /* Fill temporary array with alpha constant */
        fillParams.length = SAMPLES;
        fillParams.value = _Q15(HAMMING_ALPHA);
        status = msp_fill_q15(&fillParams, window);
        msp_checkStatus(status);
        /* Subtract generated cosine from alpha constant to generate final window */
        subParams.length = SAMPLES;
        status = msp_sub_q15(&subParams, window, temp, window);
        msp_checkStatus(status);
    }

    And the same with some modifications

    #include "msp430.h"
    
    #include <math.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    #include "DSPLib.h"
    
    /* Input signal parameters */
    #define FS                  3000
    #define SAMPLES             1024
    #define SIGNAL_FREQUENCY1   90
    #define SIGNAL_AMPLITUDE1   0.6
    #define SIGNAL_FREQUENCY2   2100
    #define SIGNAL_AMPLITUDE2   0.15
    
    /* Hamming window parameters */
    #define HAMMING_ALPHA       0.53836
    #define HAMMING_BETA        0.46164
    
    /* Constants */
    #define PI                  3.1415926536
    
    ///* Generated Hamming window function */
    //DSPLIB_DATA(window,4)
    //_q15 window[SAMPLES];
    
    /* Input signal and FFT result */
    DSPLIB_DATA(input,MSP_ALIGN_FFT_Q15(SAMPLES))
    _q15 input[SAMPLES];
    
    /* Temporary data array for processing */
    //DSPLIB_DATA(temp,4)
    //_q15 temp[3*SAMPLES/2];
    
    /* Benchmark cycle counts */
    volatile uint32_t cycleCount;
    
    /* Function prototypes */
    extern void initSignal(void);
    extern void initHamming(void);
    
    void main(void)
    {
    
        /* Check that the correct revision is defined. */
        if (msp_lea_getRevision() != MSP_LEA_REVISION) {
            // The defined value of MSP_LEA_REVISION does not match LEA revision.
            __no_operation();
        }
    
        msp_status status;
        msp_mpy_q15_params mpyParams;
        msp_fft_q15_params fftParams;
    
        /* Disable WDT */
        WDTCTL = WDTPW + WDTHOLD;
        
        /* Initialize input signal and Hamming window */
        initSignal();
    //    initHamming();
    
    //    /* Multiply input signal by generated Hamming window */
    //    mpyParams.length = SAMPLES;
    //    status = msp_mpy_q15(&mpyParams, input, window, input);
    //    msp_checkStatus(status);
    
        /* Initialize the fft parameter structure. */
        fftParams.length = SAMPLES;
        fftParams.bitReverse = true;
        fftParams.twiddleTable = msp_cmplx_twiddle_table_256_q15;
    
        /* Perform real FFT with fixed scaling */
        msp_benchmarkStart(MSP_BENCHMARK_BASE, 16);
        status = msp_fft_fixed_q15(&fftParams, input);
        cycleCount = msp_benchmarkStop(MSP_BENCHMARK_BASE);
        msp_checkStatus(status);
        
        // Check status flag.
                           if(status == MSP_SUCCESS)
                           {
                               // ERROR!
                               __no_operation();
                           }
                           else if (status == MSP_SIZE_ERROR)
                           {
                                       // ERROR!
                                       __no_operation();
                                   }
                           else if (status == MSP_SHIFT_SIZE_ERROR)
                                  {
                                              // ERROR!
                                              __no_operation();
                                          }
                           else if (status == MSP_TABLE_SIZE_ERROR)
                                  {
                                              // ERROR!
                                              __no_operation();
                                          }
                           else if (status == MSP_LEA_BUSY)
                                  {
                                              // ERROR!
                                              __no_operation();
                                          }
                           else if (status == MSP_LEA_INVALID_ADDRESS)
                                  {
                                              // ERROR!
                                              __no_operation();
                                          }
                           else if (status == MSP_LEA_OUT_OF_RANGE)
                                  {
                                              // ERROR!
                                              __no_operation();
                                          }
                           else if (status == MSP_LEA_SCALAR_INCONSISTENCY)
                                  {
                                              // ERROR!
                                              __no_operation();
                                          }
                           else if (status == MSP_LEA_COMMAND_OVERFLOW)
                                  {
                                              // ERROR!
                                              __no_operation();
                                          }
                           else if (status == MSP_LEA_INCORRECT_REVISION)
                                         {
                                                     // ERROR!
                                                     __no_operation();
                                                 }
                           else
                           {
                               __no_operation();
                           }
    
        /* End of program. */
        __no_operation();
    }
    
    void initSignal(void)
    {
        msp_status status;
        msp_add_q15_params addParams;
        msp_sinusoid_q15_params sinParams;
    
        /* Generate Q15 input signal 1 */
        sinParams.length = SAMPLES;
        sinParams.amplitude = _Q15(SIGNAL_AMPLITUDE1);
        sinParams.cosOmega = _Q15(cosf(2*PI*SIGNAL_FREQUENCY1/FS));
        sinParams.sinOmega = _Q15(sinf(2*PI*SIGNAL_FREQUENCY1/FS));
        status = msp_sinusoid_q15(&sinParams, input);
        msp_checkStatus(status);
    
    //    /* Generate Q15 input signal 2 to temporary array */
    //    sinParams.length = SAMPLES;
    //    sinParams.amplitude = _Q15(SIGNAL_AMPLITUDE2);
    //    sinParams.cosOmega = _Q15(cosf(2*PI*SIGNAL_FREQUENCY2/FS));
    //    sinParams.sinOmega = _Q15(sinf(2*PI*SIGNAL_FREQUENCY2/FS));
    //    status = msp_sinusoid_q15(&sinParams, temp);
    //    msp_checkStatus(status);
    
    //    /* Add input signals */
    //    addParams.length = SAMPLES;
    //    status = msp_add_q15(&addParams, input, temp, input);
    //    msp_checkStatus(status);
    }
    
    //void initHamming(void)
    //{
    //    msp_status status;
    //    msp_sub_q15_params subParams;
    //    msp_copy_q15_params copyParams;
    //    msp_fill_q15_params fillParams;
    //    msp_sinusoid_q15_params sinParams;
    //
    //    /* Generate sinusoid for cosine function */
    //    sinParams.length = 3*SAMPLES/2;
    //    sinParams.amplitude = _Q15(HAMMING_BETA);
    //    sinParams.cosOmega = _Q15(cosf(2*PI/(SAMPLES-1)));
    //    sinParams.sinOmega = _Q15(sinf(2*PI/(SAMPLES-1)));
    //    status = msp_sinusoid_q15(&sinParams, temp);
    //    msp_checkStatus(status);
    //
    //    /* Shift sinusoid by pi/2 to create cosine function */
    //    copyParams.length = SAMPLES;
    //    status = msp_copy_q15(&copyParams, &temp[SAMPLES/4], &temp[0]);
    //    msp_checkStatus(status);
    //
    //    /* Fill temporary array with alpha constant */
    //    fillParams.length = SAMPLES;
    //    fillParams.value = _Q15(HAMMING_ALPHA);
    //    status = msp_fill_q15(&fillParams, window);
    //    msp_checkStatus(status);
    //
    //    /* Subtract generated cosine from alpha constant to generate final window */
    //    subParams.length = SAMPLES;
    //    status = msp_sub_q15(&subParams, window, temp, window);
    //    msp_checkStatus(status);
    //}

    Both have the same status value.

    Best.

    Marcos.

  • Hi Marcos,

    I tested out both sets of code you provided above and did not observe the issue you are experiencing. Can you provide the DPSLib version, CCS version, and MSP430FR5994 silicon revision you are working on so I can try to reproduce the issue?

    Best regards,
    Caleb Overbay
  • Hi Caleb,

    Versions:

    Code Composer Studio Version: 7.2.0.00013 
    DSPLib_1_20_03_01

    I had rechecked it again, and I noticed that in the window expression the value of status variable is MSP_SUCCESS. In the code posted, there are som ifs to check the status value and the is there status == MSP_SIZE_ERROR is true while status == MSP_SUCCESS is false.

    I don't undestand why.

    Best,

    Marcos Llorente Ortega.

  • Hi Marcos,

    I believe the compiler may be making things "appear" to fail when they are actually working correctly. Since all of the if statements lead to the same code, __no_operation(), the compiler is most likely combining multiple of them. If you turn off optimization in your project settings I would expect the code to behave the way you expect.

    Best regards, 

    Caleb Overbay

  • That was the key, if I turn off all the optimizations works as I expected.

    Finally I also obtained the 1024 points fft.

    One more thing, I don't know if it's the correct forum but, I want to remove the contious from a signal with a capacitor. I know that I should take into acount the impedance of the ADC. I searched the value in the documentation but I couldn't found the value. I'm using the P 3.3 input.

    Thank you.

    Best regards.

    Marcos Llorente Ortega.

  • Hi Macros,

    I'd like to note that the code was still working properly when optimizations were turned on. It was only the if-else statements that were behaving unexpectedly because they were optimized by the compiler.

    Also, I don't understand what you mean when you say "I want to remove the contious from a signal with a capacitor." Can you explain what you're trying to do in more detail?

    Best regards,
    Caleb Overbay
  • Hi Marcos,

    I'm going to be closing this thread due to inactivity. If you have any more questions feel free to post to this thread and it will automatically be re-opened.

    Best regards,
    Caleb Overbay
  • Hi Caleb,

    First of all, Happy New Year!!

    I have 1 last question. I'm using LEA to solve a 1024 points FFT. With your help I solved the problem of  data alignment. Now the  LEA RAM memory has this distribution:

    from 0x00002c00 to 0x00003000 -> empty (1024 bytes)

    from 0x00003000 to 0x00003800  -> My_var_fft

    from 0x00003800   to 0x00003ac8  -> empty (712 bytes)

    Now I want to add a new variable to the LEA RAM. useing this

    #pragma DATA_SECTION(my_var2,".leaRAM")

    _q15 my_var[512];

    And CCS returns errors 10010 and 10099-D 

    I have tried also this:

     DSPLIB_DATA(my_var,MSP_ALIGN_FFT_Q15(512));

    _q15 my_var[512];

    And the same errors appear.

    The errors are about memory problems when my_var fits in the first empty space in the LEA RAM.

    What Should I do to store my_var2 in the LEA RAM?

    Best regards.

    Marcos.

  • Hi Marcos,

    Happy New Year to you too!

    I recommend using the DSPLIB_DATA() macro anytime you are placing a variable in LEA RAM. This way you ensure the proper alignment requirements are met.

    I tried adding your my_var[512] variable to the transform_ex1_fft_fixed_q15.c example code and did not see the error you're encountering. Can you post your updated code for me to try out on my setup?

    Best regards,
    Caleb Overbay
  • I used DSPLIB_DATA(), this is the code.

    #include "msp430.h"
    
    #include <math.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    #include "DSPLib.h"
    
    /* Input signal parameters */
    #define FS                  3000
    #define SAMPLES             1024
    
    
    
     int16_t i,pos;
     int16_t avg,sum;
    
    
    
    DSPLIB_DATA(my_var2,512)
    // #pragma DATA_SECTION(my_var2, ".leaRAM")
     _q15  my_var2[512];
    
    
    /* Input signal and FFT result */
    DSPLIB_DATA(my_var_fft,MSP_ALIGN_FFT_Q15(SAMPLES))
    
    
    _q15 my_var_fft[] = {-27424,-25440,-25424,-25632,-25616,-25552,-25760,-25472,
                    -25616,-25920,-25504,-25920,-25616,-25648,-24848,-24624,
                    -24544,-25424,-25296,-25216,-25504,-25616,-25440,-25312,
                    -25504,-25680,-25616,-25456,-25312,-25376,-25328,-25296,
                    -25584,-25376,-25664,-25424,-25488,-25808,-25600,-25568,
                    -25776,-25568,-25872,-25552,-25920,-25232,-24992,-24400,
                    -24720,-25456,-25440,-25248,-25104,-25664,-25664,-25648,
                    -25440,-25296,-25216,-25520,-25296,-25504,-25072,-25568,
                    -25264,-25552,-25520,-25360,-25680,-25600,-25536,-25856,
                    -25328,-25776,-25536,-25968,-25408,-25824,-25008,-24400,
                    -24688,-25232,-25488,-25328,-25248,-25104,-25488,-25664,
                    -25392,-25312,-25552,-25264,-25520,-25040,-25488,-25072,
                    -25392,-25488,-25104,-25776,-25472,-25456,-25744,-25168,
                    -25696,-25408,-25696,-25648,-25456,-25712,-25408,-24640,
                    -24336,-24944,-25408,-25328,-25328,-25104,-25488,-25520,
                    -25408,-25728,-25280,-25568,-25312,-25440,-25040,-25216,
                    -25536,-25424,-25376,-25520,-25360,-25840,-25424,-25744,
                    -25408,-25552,-25568,-25536,-25648,-25696,-25680,-24864,
                    -24528,-24576,-25264,-25392,-25376,-25136,-25376,-25344,
                    -25584,-25408,-25616,-25296,-25600,-25248,-25168,-25440,
                    -25152,-25328,-25456,-25296,-25552,-25472,-25520,-25680,
                    -25408,-25504,-25760,-25760,-25488,-25488,-25520,-25184,
                    -24736,-24448,-24912,-25408,-25328,-25264,-25360,-25456,
                    -25360,-25680,-25232,-25568,-25488,-25120,-25488,-25280,
                    -25424,-25392,-25328,-25456,-25488,-25360,-25744,-25760,
                    -25424,-25408,-25664,-25696,-25712,-25488,-25552,-25328,
                    -24848,-24528,-24832,-25376,-25168,-25488,-25168,-25360,
                    -25696,-25328,-25440,-25552,-25104,-25648,-25104,-25488,
                    -25344,-25680,-25104,-25664,-25328,-25424,-25584,-25840,
                    -25520,-25568,-25504,-25568,-25920,-25568,-25456,-25680,
                    -25280,-24608,-24800,-24944,-25472,-25424,-25136,-25456,
                    -25424,-25408,-25760,-25424,-25744,-25280,-25568,-25696,
                    -25328,-25280,-25520,-25856,-25440,-25456,-25456,-25664,
                    -25904,-25872,-25296,-25424,-25776,-24816,-25648,-25568,
                    -25648,-25600,-25296,-25504,-26000,-26192,-25536,-25904,
                    -25904,-25760,-26128,-25200,-25616,-26144,-25952,-26160,
                    -25952,-26224,-25584,-26496,-25552,-26064,-26512,-26000,
                    -26352,-25984,-26496,-25664,-24640,-25536,-25136,-25760,
                    -24416,-26064,-25168,-25120,-26240,-25648,-26416,-25488,
                    -25824,-26208,-25456,-25536,-25632,-25984,-25728,-25840,
                    -25936,-25776,-26256,-25872,-25920,-26160,-25888,-26096,
                    -26064,-26000,-26048,-26032,-24992,-25408,-25264,-25296,
                    -25744,-25856,-25696,-25664,-25520,-25872,-26128,-25920,
                    -25712,-26096,-25952,-25536,-25760,-25584,-25872,-25920,
                    -25728,-25760,-25872,-25888,-26352,-25648,-25888,-25728,
                    -26128,-25904,-26288,-25696,-25232,-25200,-25360,-25424,
                    -25440,-25616,-25664,-25728,-25680,-25664,-25840,-25952,
                    -25680,-26000,-25504,-25632,-25440,-25792,-25856,-25744,
                    -25904,-25792,-25552,-26080,-25712,-26384,-25696,-26000,
                    -25984,-26144,-26304,-25856,-24928,-25024,-25440,-25680,
                    -25504,-25520,-25424,-25792,-25840,-25632,-26064,-25600,
                    -25904,-25696,-25728,-25552,-25552,-25904,-25552,-26064,
                    -25776,-25648,-26224,-25648,-26016,-25744,-25824,-25920,
                    -25776,-25920,-26272,-25920,-25168,-24800,-24976,-25552,
                    -25648,-25488,-25328,-25808,-25712,-25776,-25792,-25728,
                    -25552,-25872,-25696,-25536,-25584,-25312,-25904,-25728,
                    -25552,-25808,-25824,-25840,-25872,-25744,-25968,-26112,
                    -25840,-25760,-25904,-25952,-25328,-24848,-24832,-25520,
                    -25744,-25456,-25376,-25616,-25744,-25776,-25856,-25504,
                    -25840,-25680,-25616,-25744,-25408,-25728,-25760,-25728,
                    -25856,-25616,-25792,-26000,-25712,-25520,-26032,-25952,
                    -25952,-25872,-25792,-25872,-25504,-24864,-25024,-25536,
                    -25536,-25504,-25568,-25520,-25744,-25872,-25680,-25808,
                    -25888,-25472,-25856,-25456,-25520,-25712,-25824,-25584,
                    -25792,-25200,-25888,-25936,-25696,-25584,-25680,-25920,
                    -26048,-26032,-25824,-25664,-25360,-24832,-25120,-25552,
                    -25456,-25536,-25504,-25424,-25856,-25616,-25680,-25872,
                    -25456,-25744,-25616,-25600,-25456,-25568,-25472,-25984,
                    -25504,-25568,-25584,-26032,-25888,-25696,-25568,-25872,
                    -25936,-26112,-25840,-25760,-25104,-24880,-25296,-25296,
                    -25584,-25664,-25232,-25712,-25744,-25552,-25840,-25520,
                    -25872,-25568,-25760,-25392,-25728,-25536,-25680,-25856,
                    -25616,-25600,-25568,-25760,-25856,-25936,-25648,-25712,
                    -26048,-25920,-25904,-25872,-24976,-25136,-25184,-25264,
                    -25856,-25408,-25328,-25712,-25488,-25888,-25568,-25840,
                    -25504,-25808,-25392,-25664,-25536,-25504,-25648,-25776,
                    -25696,-25712,-25696,-25696,-25904,-26016,-25792,-25904,
                    -26000,-25904,-26048,-25552,-25296,-25104,-25008,-25648,
                    -25632,-25584,-25744,-25488,-25840,-25488,-26032,-25616,
                    -26080,-25600,-25392,-25696,-25808,-25744,-25552,-25776,
                    -25856,-25792,-25600,-25632,-25984,-25824,-25776,-26224,
                    -25664,-26112,-25920,-25712,-25360,-24864,-25280,-25760,
                    -25408,-25792,-25488,-25808,-25520,-25968,-25520,-25936,
                    -25856,-25520,-25488,-25664,-25728,-25744,-25632,-25440,
                    -25712,-25856,-25648,-25680,-26096,-25680,-26000,-25712,
                    -25968,-25872,-25984,-25936,-25072,-24960,-25360,-25312,
                    -25984,-25232,-25792,-25360,-25776,-25792,-25520,-25728,
                    -25936,-25520,-25520,-25536,-25648,-25792,-25904,-25552,
                    -25696,-25824,-25600,-25936,-25696,-26032,-25568,-26000,
                    -25968,-25856,-26160,-25648,-24944,-25232,-25216,-25664,
                    -25552,-25712,-25376,-25584,-25760,-25792,-25584,-25472,
                    -25728,-25776,-25552,-25552,-25456,-25824,-25888,-25536,
                    -25600,-25600,-26000,-25584,-25968,-25696,-25840,-26000,
                    -25584,-26160,-25904,-25216,-25200,-25056,-25616,-25504,
                    -25520,-25664,-25472,-25456,-25920,-25856,-25664,-25472,
                    -25472,-25712,-25792,-25488,-25424,-25856,-25600,-25680,
                    -25536,-25744,-25648,-26096,-25552,-25744,-25888,-25696,
                    -26048,-26080,-25856,-25344,-24976,-25648,-25616,-25328,
                    -25360,-25648,-25632,-25424,-25744,-25088,-25456,-25792,
                    -25360,-26048,-25296,-25504,-24864,-24560,-25696,-24720,
                    -25872,-25264,-25872,-25104,-25168,-26064,-25088,-25648,
                    -25280,-25632,-26000,-25040,-25488,-25296,-25952,-25360,
                    -25408,-25904,-25408,-25840,-25024,-25872,-25776,-25056,
                    -26032,-25264,-25808,-25536,-24864,-25040,-25008,-25456,
                    -25088,-25344,-25344,-25216,-25456,-25712,-25520,-25408,
                    -25232,-25472,-25584,-25552,-25120,-25328,-25664,-25232,
                    -25456,-25328,-25664,-25456,-25520,-25600,-25248,-25568,
                    -25728,-25504,-25920,-25168,-25312,-24656,-25216,-25136,
                    -25376,-25488,-25280,-25184,-25424,-25520,-25568,-25504,
                    -25328,-25312,-25584,-25280,-25312,-25552,-25456,-25648,
                    -25312,-25504,-25168,-25520,-25632,-25392,-25536,-25744,
                    -25392,-25712,-25552,-25696,-24912,-25136,-24960,-25264,
                    -25296,-25504,-25520,-25216,-25280,-25296,-25600,-25504,
                    -25344,-25344,-25392,-25184,-25456,-25264,-25616,-25280,
                    -25520,-25328,-25360,-25808,-25392,-25536,-25680,-25216,
                    -25728,-25344,-25648,-25648,-24976,-29648,-25168,-25280,
                    -25024,-25360,-25424,-25248,-25296,-25264,-25424,-25440,
                    -25264,-25456,-25312,-25360,-25296,-25472,-25136,-25632,
                    -25552,-25184,-25520,-25296,-25680,-25616,-25456,-25456,
                    -25552,-25536,-25872,-25680,-25120,-24976,-25024,-25280,
                    -25456,-25360,-25248,-25376,-25488,-25264,-25472,-25584,
                    -25264,-25504,-25152,-25376,-25296,-25296,-25568,-25392,
                    -25376,-25616,-25296,-25744,-25264,-25632,-25248,-25584,
                    -25456,-25456,-25664,-25856,-25424,-24832,-24784,-25104,
                    -25520,-25440,-25232,-25296,-25424,-25168,-25536,-25136,
                    -25552,-25248,-25344,-25392,-25168,-25488,-25360,-25312,
                    -25552,-25152,-25632,-25488,-25648,-25360,-25376,-25584,
                    -25648,-25456,-25600,-25712,-25520,-25264,-24880,-24880};
    
    
    
    
    
    /* Benchmark cycle counts */
    volatile uint32_t cycleCount;
    
    
    
    void main(void)
    {
    
        /* Check that the correct revision is defined. */
        if (msp_lea_getRevision() != MSP_LEA_REVISION) {
            // The defined value of MSP_LEA_REVISION does not match LEA revision.
            __no_operation();
        }
    
        msp_status status;
        msp_fft_q15_params fftParams;
    
        /* Disable WDT */
        WDTCTL = WDTPW + WDTHOLD;
        
    
    
        /* Initialize the fft parameter structure. */
        fftParams.length = SAMPLES;
        fftParams.bitReverse = true;
        fftParams.twiddleTable = msp_cmplx_twiddle_table_1024_q15;
    
    
        /* Perform real FFT with fixed scaling */
        msp_benchmarkStart(MSP_BENCHMARK_BASE, 16);
        status = msp_fft_fixed_q15(&fftParams, my_var_fft);
    
    
    
        pos=0;
        // Calculate magnitude for the positive frequency domain
               for(i = 0; i < 1024 ; i=i+2)
               {
                   my_var2[pos]=sqrt(pow(my_var_fft[i],2)+pow(my_var_fft[i+1],2));
                   pos++;
               }
               for(i=0;i<20;i++){
                   my_var2[i]=0;
               }
    
               avg = 0;  
               sum=0;
                for (i = 0; i < 512; i++)
                {
                    sum += my_var2[i];
                }
                avg = (sum)/512; 
    
                for(i=0;i<512;i++){
                    my_var2[i]=my_var2[i]-avg;
                }
    
    
    
        cycleCount = msp_benchmarkStop(MSP_BENCHMARK_BASE);
        msp_checkStatus(status);
    
        /* Add input signals */
        msp_add_q15_params addParams;
        addParams.length = 512;
        status = msp_add_q15(&addParams, my_var2, my_var2, my_var2);
        msp_checkStatus(status);
    
    
    
    }
    

    Best regards,

    Marcos.

  • Hi Marcos,

    Thank you for providing the code. I noticed one bug in the code you posted. DSPLIB_DATA(my_var2,512) should actually be DSPLIB_DATA(my_var2,4). The original is attempting to set it to 512 byte alignment, but since my_var2 is only being used for vector addition, it only requires 4 byte alignment.

    However, even after fixing the bug, I'm able to replicate the issue you're experiencing. Unfortunately, I have not been able to explain this behavior. As you've pointed out, there is enough space to fit the data with the proper alignment in LEA RAM. I've started an internal conversation with our MSP430 Compiler team regarding this. I'll keep you updated on the progress. Thank you for your patience.

    Best regards,
    Caleb Overbay
  • Hi Caleb.

    Any news? I need that space to store more variables.

    Best regards,
    Marcos.
  • Hi Marcos,

    This issue is most likely going to take some time to work out as it appears to be a compiler bug at the moment. In the meantime, it looks like the compiler does properly allocate the variables in LEA RAM if you declare your variables in the following way:

     DSPLIB_DATA(my_var2,4)
     // #pragma DATA_SECTION(my_var2, ".leaRAM")
     _q15  my_var2[512];
    
     /* Input signal and FFT result */
     DSPLIB_DATA(my_var_fft,MSP_ALIGN_FFT_Q15(SAMPLES/2))
     _q15 my_var_fft[SAMPLES];

    I'd like to stress that this is not the typical way to set this up but is instead a temporary workaround until the problem can be solved. 

    Best regards, 
    Caleb Overbay

**Attention** This is a public forum