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.

  • Resolved

CCS/MSP-EXP430FR5994: BOOSTXL-AUIDIO EXAMPLE FFT

Part Number: MSP-EXP430FR5994

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.

  • In reply to Marcos Llorente:

    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

  • In reply to 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.

  • In reply to Marcos Llorente:

    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

  • In reply to Marcos Llorente:

    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

  • In reply to 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.

  • In reply to Marcos Llorente:

    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

  • In reply to 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.

  • In reply to Marcos Llorente:

    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

  • In reply to Caleb Overbay:

    Hi Caleb.

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

    Best regards,
    Marcos.
  • In reply to Marcos Llorente:

    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

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.