1

I am trying to run Kiss FFT (Kiss FFT github) on an MSP430FR6989 Launchpad. For now, I'm just trying to get the kiss_fftr test shown here to work. I am running into an issue with kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem). My input is (16, 0, NULL, NULL). The function reaches this point in kiss_fftr.c and then returns NULL due to the !st if statement.

if (lenmem == NULL) {
    st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded);
} else {
    if (*lenmem >= memneeded)
        st = (kiss_fftr_cfg) mem;
    *lenmem = memneeded;
}
if (!st)
{
    return NULL;
}

Malloc sets st to NULL, so it failed to allocate the memory. I am sure that there is enough memory available in my MCU. My memory allocation in CCS is 35% RAM (736/2048), 3% FRAM1 (1896/48000) and 28% FRAM2 (23144/81912).

Does anyone have advice on how to fix this, or what I should learn to fix this? I don't want to chase down the wrong rabbit hole if memory allocation is not the issue.

What I've tried: When I try running the test code given in the stack overflow link and sending the output array over UART, I get no output. I checked to see if kiss_fft_alloc is working correctly by making an if statement (st == NULL) that would throw a KISS_FFT_ERROR. The error threw at the point mentioned above, but I cannot figure out how to "fix" malloc failing to allocate memory.

  • Not familiar with the MSP430, but from KISS FFT's code the allocation macro is made to support optimization by using SIMD instructions. I suspect those instructions might not be supported on that MCU. You could try to undefine `USE_SIMD` in KISS FFT. – SleuthEye Jul 02 '21 at 00:12
  • Thank you for the help. I found that the MSP430 does not support SIMD instructions, but I cannot find where USE_SIMD is defined in KISS FFT. I can only find ifdef statements for USE_SIMD in line 38 and 47 of kfc.c, line 50 of kiss_fft.h, and line 18 of kiss_fftr.c. I cannot find a define of USE_SIMD, so I am not sure how to prevent KISS FFT from trying to use SIMD if SIMD is only mentioned in ifdef statements. Is there a way to specifically set KISS FFT to not use SIMD? – ALackOfNumbers Jul 07 '21 at 08:00
  • If `USE_SIMD` isn't defined then `KISS_FFT_MALLOC` should map to a standard `malloc` call. I'd suggest to try to see if you can reproduce the issue without KISS FFT in the picture while trying to allocate a block of memory of similar size. – SleuthEye Jul 08 '21 at 02:41
  • I tried malloc with an input of 16, the same as my kiss_fftr_alloc function call, and it worked fine. I want to try malloc using memneeded instead of 16 in order to get an accurate test. I do not know how to get the value of memneeded besides using a UART, so I am working on setting up my UART functions to send size_t variables. – ALackOfNumbers Jul 08 '21 at 10:12

0 Answers0