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.

EVM430-FR6047: FFT (via DSP Library API ) via LEA with 256 samples instead of 128 does not fit into existing memory

Part Number: EVM430-FR6047
Other Parts Discussed in Thread: MSP430FR6047

Hello,

I followed the DSP Library example 'transform_ex1_fft_fixed_q15' to implement the use of the fast fourier transformation in my code which is supposed to take measurements and calculate the FFT (with the goal of getting the envelope by Hilbert transformation).

So far everything works fine, but only with a sample size of 128. After flashing it says: 'MSP430: Flash/FRAM usage is 40180 bytes. RAM usage is 4958 bytes.'

But with a sample size of 256 the following error occurs: "../lnk_msp430fr6047.cmd", line 257: error #10099-D: program will not fit into available memory. run placement with alignment fails for section ".leaRAM" size 0xea0 . Available memory ranges:   LEARAM       size: 0xec8       unused: 0xec8       max hole: 0xec8

But shouldn't there be plenty of memory left? The MSP430-FR6047 has 8 kB of RAM with 4 kB being shared between LEA and CPU. Am I overlooking something obvious?

The relevant code snippets would be:

Global:

#define FFTsamples 256

DSPLIB_DATA(input, MSP_ALIGN_FFT_Q15(FFTsamples)) _q15 input[FFTsamples];

In main flow:

// Fill input array with ADC Waveform
uint16_t* pUPSCap16 = (uint16_t*) (USS_getUPSPtr(&gUssSWConfig));
uint16_t c = 0;
while(c < FFTsamples) {
input[c] = *pUPSCap16;
pUPSCap16++;
c++;
}

// FFT
msp_fft_q15_params fftParams;
fftParams.length = FFTsamples;
fftParams.bitReverse = true;
msp_fft_fixed_q15(&fftParams, input);

Another question: I was wondering how, with a FFT sample size of 128 and for example only 160 available ADC samples, this code was capable of generating 128 valid FFT values. Doesn't the FFT of a real vector result in a vector of the same size, but mirrored, so only half of it is supposed to be usable? Is there some kind of interpolation involved or anything?

Best regards

Daniel

  • Hi Daniel,

    Yes, the LEA RAM size is 4KB. You can see the definition in cmd file. Actually, the LEA need reserve some memory for stack. The size of LEA RAM can be used for data is 0xec8.

    I think you can change the FFTsamples to 128 and compile the code to see the map file. In the map file, you can figure out what variables that occupy

    the LEA RAM memory.

    For your second questions, l'm not an expert of FFT algorithm, but I will consult our expert of FFT and com back to you later.

    B.R.

    Winter Yu

  • Hi Winter,

    thank you very much for your support. With the help of the 'Memory Allocation' tool I figured out that LEA RAM is indeed a bit short (56 bytes to be exact; but I would like to have more memory freed anyway).

    Now the main culprit is noted as:

    .leaRAM:init ( USS_userConfig.obj) 1568 Bytes
    .leaRAM:uninit ( USS_userConfig.obj) 1568 Bytes

    First of all: What is up with init and uninit both taking up the exact same space and what exactly is the uninit part for?

    I see the problem is that I want to run both your algorithm as well as mine to compare the two and the config structs of yours already take up too much space. So now I am wondering how to solve the issue.

    There has to be opportunity to free some Memory from LEA RAM but I am not familiar with memory management. I tried to doctor around on the structs as well as the linker map file, but to no success. I thought for example that I could put theese structs into normal RAM. After all I am not reliant on the demo GUI or configurations being persistent across power-offs or anything like that.

    Any suggestion would be very much appreciated.


    Best regards
    Daniel
  • Hello,

    still wondering about the memory issue. Any comment would be helpful.

    Greetings

    Daniel

  • Hi Daniel,

    Could you provide your project? I would like to check your project on my side.

    B.R

    Winter

  • Hi Winter,

    Sure. How can I do that? I cannot find your email adress or anything.


    Best regards
    Daniel
  • Hi Daniel,

    When click reply, there will be "Insert Code, Attach Files and more..." link. Click it and enter a new reply page with "attach file" function. Please see below pictures.

    B.R

    Winter

  • Hey Winter,

    thank you for the information. The function in this c file is simply to be called instead of USSLibGUIApp_Engine() in the USS_Water_Demo.

    Best regards

    Daniel

    #include "hal.h"
    #include "DSPLib.h"
    
    
    
    #define FFTsamples     128
    DSPLIB_DATA(input, MSP_ALIGN_FFT_Q15(FFTsamples)) _q15 input[FFTsamples];
    
    
    
    
    
    void mainLoop(void) {
    
        WDTCTL = WDTPW + WDTHOLD;           //Disable watch dog timer
    
        hal_uart_Init();
    
        USS_configureUltrasonicMeasurement(&gUssSWConfig);
        USS_initAlgorithms(&gUssSWConfig);
    
        USS_Algorithms_Results_fixed_point algResFixed;
        USS_Algorithms_Results alg_results_float;
    
    
    
    // Measure ----------------------------------------------------------------------------------------------
    
        while(1) {
    
            USS_startUltrasonicMeasurement(&gUssSWConfig, USS_capture_power_mode_low_power_mode_0);
    
    
    
    // TI Algorithm -----------------------------------------------------------------------------------------
    
            USS_runAlgorithmsFixedPoint(&gUssSWConfig, &algResFixed);
            USS_getResultsInFloat(&algResFixed, &alg_results_float);
    
    
    
    //         FFT Waveform ----------------------------------------------------------------------------------------- 20.06.18
    
            // Fill input array with ADC Waveform
            uint16_t* pUPSCap16 = (uint16_t*) (USS_getUPSPtr(&gUssSWConfig));
            uint16_t a = 0;
            while(a < FFTsamples) {
                input[a] = *pUPSCap16;
                pUPSCap16++;
                a++;
            }
    
            // FFT
            msp_fft_q15_params fftParams;
            fftParams.length = FFTsamples;
            fftParams.bitReverse = true;
            msp_fft_fixed_q15(&fftParams, input);
    
    
    
            __delay_cycles(1600000);                                  // 200 ms
    
        }
    
    }
    
    
    

  • Hi Daniel,

    I can't know the USSSWLib version you used. Actually, we already adopt Hilbert transformation to get the envelope in our algorithm in USSSWLib version after <USSSWLib  02_10_00_04>. And this algorithm also use LEA. In the newest <USSSWLib  02_10_00_07>, you can choose Lobe tracking or Hilbert Transformation by configuration. So you can compare the performance of two algorithm. Please see the release note for more new features information about USSSWLib.

    B.R

    Winter Yu

  • Hi Winter,

    thank you for your reply. I am aware of those features since I am already using USSSWLib 02_10_00_07. But actually I want to run both your algorithm as well as mine and the problem is that yours already takes up almost all of the limited LEA-RAM so I cannot use the LEA for my own algorithm. This is about memory management which I clearly don't fully understand yet.

    Sorry for the trouble.

    Best regards

    Daniel

  • Hi Daniel,

    The definitions of LEA memory used by USSLib are as below. You can find this in USS_userConfig.c and USS_userConfig.h.

    There are two options for you to meet your need.

    1. Decrease the "USS_SW_LIB_APP_MAX_CAPTURE_SIZE" from 372 to a small value. But too few capture samples may cause inaccurate result.

    2. Replace USS_runAlgorithmsFixedPoint() with your own algorithm function. Then you can re-use the LEA  memory space defined as above. The ADC capture results were stored above LEA variable. But you can't evaluate two algorithms at the same time. 

    B.R

    Winter Yu

  • Hi Winter,

    thank you very much. That helped me alot.

    Best regards

    Daniel

**Attention** This is a public forum