Hello,
I am using a MSP430F2252, and performing a goertzel algorithm, to detect DTMF tones.
In my current implementation, the calculation of the goertzel algorithm, takes about 7ms, with a MCLK of 3.579.545Hz.
Is there a possibility to speed this up?
As I can read in the Datasheet the F2252, does not have a hardware multiplier.
I am using the ADC10, so I am getting 10Bit values for adc_values.
Current code:
const int coeff[7]={27667,26510,25248,23887,17558,15786,12063};
int goertzel (int sample[], long int coeff, int bksize) { int Q, Q_prev, Q_prev2, i; long power2; long prod1, prod2, prod3; Q_prev = 0; //set delay element1 Q_prev as zero Q_prev2 = 0; //set delay element2 Q_prev2 as zero power2 = 0; //set power as zero for (i = 0; i < bksize; i++) // loop bksize times and calculate Q, Q_prev, Q_prev2 at each iteration { Q = (sample[i]) + ((coeff * Q_prev) >> 14) - (Q_prev2); // >>14 used as the coeff was used in Q15 format Q_prev2 = Q_prev; // shuffle delay elements Q_prev = Q; } //calculate the three products used to calculate power prod1 = ((long) Q_prev * Q_prev); prod2 = ((long) Q_prev2 * Q_prev2); prod3 = ((long) Q_prev * coeff) >> 14; prod3 = (prod3 * Q_prev2); power2 = ((prod1 + prod2 - prod3)) >> 8; //calculate power using the three products and scale the result down return power2; }
Thanks!
Manuel