Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[REQ]C code for detecting DTMF with DSP/Micro ?

Status
Not open for further replies.

bobcat1

Advanced Member level 4
Joined
Jul 10, 2002
Messages
1,284
Helped
99
Reputation
198
Reaction score
34
Trophy points
1,328
Activity points
8,546
Hi

I'm looking for C language procedure for detecting DTMF signal for 16 bit micro/DSP controller (Non floting).


thanks

Bobi
 

Hi,
Texas Instruments has a application note for their MSP430, they use the goertzel algorithm, but it was only in assembler.
 

Hi,
Check out the Embree book and you can modify the code to suit to you.
B R M
 

Mr_Programmer said:
Hi,
Texas Instruments has a application note for their MSP430, they use the goertzel algorithm, but it was only in assembler.

Whether I can look your the sources of algorithm Goertzel for MSP430?
 

A complete application is available under **broken link removed**

and also a more theoretical app note is available at this adress:
**broken link removed**
 

Thanks Mr_Programmer

But the code for the application's above was written in assembly language, And I was looking for C language code


Best regards


Bobi
 

check for the Goertzel algorithm, it's easy to implement.


I have implement it for TMS320LF2401A from texas, using a 8000Hz sample rate, you must put the rutine det_DTMF inside a periodic interrupt that reaches at 8000 samples per second, use "y" like the sample at it moment. After 320 samples, in the arm array have the results:

#include "LF2401A.H"
// ***************************************************************************************************
/*
Coeficientes de Goertzel
kgt[n]=256*cos(6.2832*frec/8000 )
*/
const int t_kgt[]=
{
219, // 697Hz
211, // 770Hz
201, // 852Hz
189, // 941Hz
149, // 1209Hz
128, // 1336Hz
102, // 1477Hz
73 // 1633Hz
};


int arm[8]={0,0,0,0,0,0,0,0};

void inline det_DTMF(int y)
{
static int N_DTMF=0,arm_DTMF=0;
static int qn[8],qn1[8],qn2[8];

int * p_tb;
int j,c,d;
long mp;
int kgt;


// Lee el coeficiente de Goertzel de la armónica que estoy tratando
p_tb=(int *)t_kgt;
p_tb+=arm_DTMF;
kgt=WordReadFlash(p_tb);

// Hago la función de Goertzel
// mp=kgt*qn1[j]/128;
// Pero: Como qn1 puede ser > 256, entonces la multiplicación
// se sobrepasa de un int. Hay que tener cuidado con el
// manejo de longs, ya que ocupan mucho tiempo de proceso

mp=qn1[arm_DTMF];
mp*=kgt;
mp>>=7;

qn[arm_DTMF]=mp-qn2[arm_DTMF]+y;
qn2[arm_DTMF]=qn1[arm_DTMF];
qn1[arm_DTMF]=qn[arm_DTMF];

arm_DTMF++;
if (arm_DTMF== 8 )
{
N_DTMF++;
arm_DTMF=0;
}

// Cuando pasan las 320 muestras, proceso el resultado
// para filtrar las armónicas.

if (N_DTMF==320 )
{
for (j=0; j<8; j++)
{
p_tb=(int *)t_kgt;
p_tb+=arm_DTMF;
kgt=WordReadFlash(p_tb);

qn1[j]=abs(qn1[j])>>8;
qn2[j]=abs(qn2[j])>>8;

arm[j]=qn1[j]*qn1[j]+qn2[j]*qn2[j]+(((qn1[j]*qn2[j])>> 8 )*kgt)>>8;

arm[j]=abs(arm[j]);
if (arm[j]>0x0001) arm[j]=0xEEEE; else arm[j]=0x0000;

qn2[j]=0;
qn1[j]=0;
}
N_DTMF=0;
}

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top