Skip to main content
MMett
Associate III
December 10, 2018
Solved

Do a corralation with DSP Library

  • December 10, 2018
  • 2 replies
  • 1202 views

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?

This topic has been closed for replies.
Best answer by MMett

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.

2 replies

MMett
MMettAuthorBest answer
Associate III
December 13, 2018

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.

waclawek.jan
Super User
December 13, 2018

Thanks for coming back with the solution

JW