This post was last edited by dql2016 on 2023-9-28 23:02
Download the latest DSP library from GitHub: . The latest released version is 5.9.0. Add the dsp library based on the serial port printing example.
Add the group Drivers/DSP on the left side of Keil, add the header file path, add the header file path required by DSP, and add the path Drivers\CMSIS\DSP\Include :
Add static library files, STM32H7 is M7 core, double precision floating point, use little endian format, select library Drivers\CMSIS\DSP\Lib\ARM\arm_cortexM7lfdp_math.lib
Add macro definition ARM_MATH_LOOPUNROLL :
Its function is to process small batches of 4 to speed up execution.
Select armcc6 compiler, turn on FPU, STM32H7 supports double precision floating point, turn on Double Precision:
By adding the header file #include "arm_math.h" in main.c, you can call the functions of the DSP library. This completes the porting of the DSP library.
Add test code:
float32_t pSrcA;
float32_t pSrcB;
float32_t pDst;
q31_t pSrcA1;
q31_t pSrcB1;
q31_t pDst1;
q15_t pSrcA2;
q15_t pSrcB2;
q15_t pDst2;
q7_t pSrcA3;
q7_t pSrcB3;
q7_t pDst3;
/*求和*********************************/
pSrcA = 0.1f;
pSrcB = 0.2f;
arm_add_f32(&pSrcA, &pSrcB, &pDst, 1);
printf("arm_add_f32 = %f\r\n", pDst);
pSrcA1 = 1;
pSrcB1 = 1;
arm_add_q31(&pSrcA1, &pSrcB1, &pDst1, 1);
printf("arm_add_q31 = %d\r\n", pDst1);
pSrcA2 = 2;
pSrcB2 = 2;
arm_add_q15(&pSrcA2, &pSrcB2, &pDst2, 1);
printf("arm_add_q15 = %d\r\n", pDst2);
pSrcA3 = 30;
pSrcB3 = 120;
arm_add_q7(&pSrcA3, &pSrcB3, &pDst3, 1);
printf("arm_add_q7 = %d\r\n", pDst3);
printf("***********************************\r\n");
The print results are as expected:
Later, the FFT calculation test can be carried out on this basis.
|