cancel
Showing results for 
Search instead for 
Did you mean: 

Do a corralation with DSP Library

MMett
Associate III

I have a 32F746GDISCOVERY and would like to test the dsp functionalities with a correlation.

I have the following code:

#include "arm_math.h"
extern void arm_correlate_fast_q31(q31_t * pSrcA, uint32_t srcALen, q31_t * pSrcB, uint32_t srcBLen, q31_t * pDst);
extern void arm_q31_to_float(q31_t * pSrc, float32_t * pDst, uint32_t blockSize);
extern void arm_float_to_q31( float32_t * pSrc, q31_t * pDst, uint32_t blockSize);
 
q31_t in1[32];
q31_t in2[32];
q31_t out1[64];
float out1_f[64];
 
for(int i=0; i<32; i++){
	in1[i] = 0;
	in2[i] = 0;
}
float tempf = 0.00001;
for(int i=12; i<20; i++){
	arm_float_to_q31( &tempf, &in1[i], 1);
	arm_float_to_q31( &tempf, &in2[i], 1);
}
arm_correlate_fast_q31(in1, 32, in2, 32, out1);
arm_q31_to_float(out1,out1_f,64);

I'm putting in two square wave signals and expecting a triangle signal. I look with the debugger, but out1 has only stored zeroes. What am I doing wrong? Do I still have to initialize the DSP core?

1 ACCEPTED SOLUTION

Accepted Solutions
MMett
Associate III

The problem was the resolution of q31 which I had overrated. The Q-31 format has a resolution of 2^(-31) = 4.6566e-10. A multiplication of two numbers of size 1e-5 while correlating is just below the resolution. Therefore there are many zeros.

View solution in original post

2 REPLIES 2
MMett
Associate III

The problem was the resolution of q31 which I had overrated. The Q-31 format has a resolution of 2^(-31) = 4.6566e-10. A multiplication of two numbers of size 1e-5 while correlating is just below the resolution. Therefore there are many zeros.

Thanks for coming back with the solution

JW