FAQ

FAQ

How to use the DSP function in the NuMicro® M4 series for spectrum analysis?  Issue Date:2017-02-02

  • For detailed example samples, refer to the following link: http://www.nuvoton.com/hq/resource-download.jsp?tp_GUID=EC0120160922110158
  • Enable the DSP function:
1. In Keil, select Target Options, switch to the C/C ++ window and then enter ARM_MATH_CM4 = 1 in the Define text field.

 

2. In the Library section, add arm_cortexM4lf_math.lib at \Library\CMSIS\Lib\ARM.
 

3.  Include arm_math.h to the main function. After that, the DSP library can be called in the main function.
 

  • First, the even-numbers in the data format to be calculated are real numbers and the odd-numbers are imaginary numbers, e.g. 1+0.5i, 2+4i, 3+2i=>testinput={1, 0.5, 2, 4, 3, 2}, FFTsize=3.
  • Then, call the function arm_cfft_radix4_init_f32(&S, fftSize, ifftFlag, doBitReverse) to do the initial settings for Fast Fourier operation, including the number of operations, the need for fast Fourier or inverse fast Fourier transform.
  • Call the function arm_cfft_radix4_f32(&S, testinput) for fast Fourier transform operations, and the results are stored in the array testinput, where the results are complex.
  • Take the absolute value of the complex number to get the frequency intensity, and output the results to Output. Since the result is left-right symmetry, the amount of computation is fftSize/2, arm_cmplx_mag_f32(testinput, Output, fftSize/2).
  • Get the frequency intensity as y-axis data, and then calculate the x-axis for each frequency mode as

The calculation results are shown as follows. The strongest frequency of the signal can be about 1 kHz.

 

Products: Microcontrollers ,Arm Cortex-M4 MCUs ,M451 Base Series ,M451M Series ,M452 USB Series ,M453 CAN Series ,M4TK Touch Key Series ,NUC442/472 Series ,NUC505 Series
Applications:
Function: Peripherals,ARM,DSP,FPU,Connectivity,I2C