This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with arm_cfft_f32()

Note: This was originally posted on 27th August 2013 at http://forums.arm.com

Hello,

I'm new in the field of ARM and I need some help. I try to make a FFT on a Cortex-M4 with fpu. I tried two examples given with the CMSIS library, an old one which uses arm_cfft_radix4_f32() and a new one with arm_cfft_f32(). The two examples compile well. The old code with arm_cfft_radix4_f32() works quite good. That function is deprecated so I would like to use arm_cfft_f32() but I don't get the right data at the end.

The program makes a FFT of a given signal and should detect the peak in magnitude at refIndex = 213. It's ok with the deprecated function arm_cfft_radix4_f32() but not with arm_cfft_f32(). I get refIndex = 861. I tried to change the 'doBitReverse' value from 1 to 0 but nothing changed I have exactly the same result at the output of arm_cfft_f32().

I didn't find the same issue on the web. Is there a known problem with arm_cfft_f32() ? Could someone explain me what I'm doing wrong ?

Thanks,
Pierre.


  • Note: This was originally posted on 27th August 2013 at http://forums.arm.com

    I ran into similar issue when play with this example in latest CMSIS. After I defined some macros in compiler options, I finally got the correct index 213. I can't recall exactly what I did, but the macros might be "-DARM_MATH_CM4 -D__FPU_PRESENT -D__USE_CMSIS".
  • Note: This was originally posted on 27th August 2013 at http://forums.arm.com

    Hi,

    May I ask what compilers are being used? I just recompiled the cortex M4lf library (with Keil) and the fft example (which I zipped up and attached) and got 213.  I looked at your attachments and I don't notice anything different that should matter.  I can't attach the .lib file to this forum because it's larger than 2.3MB.  If you'd like, I can email you the lib file I just made if you message me your email address. 

    Dan
  • Note: This was originally posted on 28th August 2013 at http://forums.arm.com

    Thank you for the answers.

    TerryGuo, I tried the different define macros but it doesn't change anything.

    dwwhite, I'm using Atmel Studio with GCC. The library I use was compiled by Atmel and is included in the AtmelStudio installer. I suspect that there is a problem with it. I tried yesterday to recompile the library for GCC but I didn't find how to do. I have some batch scripts to compile for GCC with Keil but it fails.
    I feel that the bitreverse operation is not performed (same result when activated or not, the cycle counter is only five counts higher when enabled).
    I don't know if it is important but I use the fpu with -mfloat-abi=hard flag. I tried also without fpu (-mfloat-abi=soft) but I get the same result.
    Is the library you compiled compatible with GCC ?
  • Note: This was originally posted on 29th August 2013 at http://forums.arm.com

    Ok so I think I found the solution. The problem is in the file arm_bitreversal2.S in the define section relative to GCC compiler.
    It seems that a dot is missing. Line 57 should be #define CODESECT .section .text
    When I add the dot and recompile the library I get the right refIndex.

    Hope this will help other people.

    Pierre.
  • I discovered this problem yesterday as well. There are a couple other solutions that may be easier than recompiling the library. The biggest problem with recompiling it is that you must then maintain it. When a new version comes out you can't just use it. You must recompile it as well, unless the bug gets fixed in the next release.

    1. You can fix the error in arm_bitreversal2.S as described in your post and include that file as part of your project. As long as it gets linked in prior to the library, the version inside the library gets ignored.

    2. An even less intrusive method is to add the section text to the linker script. My addition is highlighted in red below.

    ...

      /* The program code and other data goes into FLASH */

      .text :

      {

        . = ALIGN(4);

        *(.text)          /* .text sections (code) */

        *(.text*)         /* .text* sections (code) */

        *(text)           /* workaround for CMSIS library bug */

        *(.rodata)        /* .rodata sections (constants, strings, etc.) */

        *(.rodata*)       /* .rodata* sections (constants, strings, etc.) */

    ...

    I believe this is the best workaround until the bug is fixed in the CMSIS distribution. Is ARM aware of the problem?

    - Greg

  • I just downloaded the CMSIS libraries from the ST website for using them on a STM32 controller.

    The bug described above is still in there. It took me quite some time to find and finally fix it with the help of this thread.

    Maybe someone knows how and where to file a bug report?

  • Hi frsc,

    I think ST just needs to offer the more up-to-date versions of CMSIS.  This should be fixed in the version offered by ARM.  I forget which version specifically that this got patched, but it has been fixed. 

    CMSIS - Cortex Microcontroller Software Interface Standard - ARM

  • Hi, I'm in trouble with the CMSIS DSP library (on STM32F429) regarding bitreversal function and solved it the workaround described here. Hope this helps.

    Regards

    Ibrahim

  • Hello Ibrahim,

    Can you tell me the version # at the top of the arm_bitreversal.c file you are using?

    Thanks,

    Dan

  • Hi Daniel,

    It is "$Revision:  V1.4.1" supplied by ST.

    Regards,

    Ibrahim

  • Hello Ibrahim,

    I have passed on your information to the appropriate people at ARM.  In the mean time, you are using a bit older version of CMSIS.  (3 versions old).

    You can download the newest one here:

    http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php

    Also, when I looked at your website, you mention you're using the Cortex M4 with fpu, but the library file you're including is “libarm_cortexM4l_math.a”,  there should be a version “libarm_cortexM4lf_math.a” available to you that is for Cortex M4's with an FPU.  You should notice dramatic performance increases if you're using floating-point functions.

    Hopefully the newest version of CMSIS doesn't have the same missing function issue.  Likely it was just a mistake when compiling it.  Please do let us know if you run into the same problem on the newer version though.

    Cheers,

    Dan

  • Hi Dan,

    Thanks for your interest. Yes, the CMSIS version I'm using is a bit older, because this is the DSP library for SM32F4 supplied by ST. It can be downloaded from ST website. I'll try the new version of CMSIS DSP library and let you know the results.

    Regarding floating point library “libarm_cortexM4lf_math.a”, I've already used for FFT functions, and it is obvious that the performance increases.

    Best regards,

    Ibrahim

  • Hi Dan,

    I've tried the latest CMSIS DSP library "libarm_cortexM4lf_math.a" (Date 12. March 2014, Revision V1.4.4), and everything works fine.

    Thanks.

    Regards,
    Ibrahim

  • Hi Ibrahim & Dan,

    It is already planned to embed the new CMSIS DSP Library V1.4.4 in the next STM32F4 Standard Peripheral Library release.

    Please note that the DSP library will be also available in the next release of STM32CubeF4 package.

    Best Regards,

    Amel

  • Hello

    by defining the following expression in the options for target->Asm->Misc Controls of keil uvision, problem will be solved.

    --cpreproc