Digital Signal Processing Reference
In-Depth Information
TABLE 10.2 Characters and
Corresponding LEDs
1
0001
2
0010
3
0011
4
0100
5
0101
6
0110
7
0111
8
1000
9
1001
*
1010
0
1011
#
1100
// DTMF.c Core program to decode DTMF signals and turn on LEDs
#define N 100
#define thresh 40000
short i;short buffer[N]; short sin697[N],cos697[N],sin770[N],cos770[N];
...
long weight697,weight697_sin,weight697_cos; long ... weight1477_cos;
long weight1,weight2,choice1,choice2;
interrupt void c_int11()
{
for (i = N-1; i > 0; i--)
buffer[i]=buffer[i-1];
// initialize buffer
buffer[0] = input_sample();
//input into buffer
output_sample(buffer[0]*10);
//output from buffer
weight697_sin=0; weight697_cos=0;
//weight @ each freq
...
weight1477_sin = 0; weight1477_cos = 0;
for (i = 0; i < N; i++)
{
weight697_sin = weight697_sin + buffer[i]*sin697[i];
weight697_cos = weight697_cos + buffer[i]*cos697[i];
...
weight1477_cos= weight1477_cos + buffer[i]*cos1477[i];
}
//for each freq compare sine and cosine weights and choose largest
if(abs(weight697_sin)>abs(weight697_cos)) weight697=abs(weight697_sin);
else weight697 = abs(weight697_cos);
...
if(abs(weight1477_sin)>abs(weight1477_cos)) weight1477 = abs(weight1477_sin);
else weight1477 = abs(weight1477_cos);
weight1=weight697; choice1=1;//among weight697,..weight941->largest
if(weight770 > weight1) {weight1 = weight770; choice1=2;} //...
if(weight941 > weight1) {weight1 = weight941; choice1=4;}
weight2=weight1209; choice2=1;//among weight1209,..weight1477->largest
if(weight1336> weight2) {weight2 = weight1336; choice2=2;}
FIGURE 10.1. Core C program using correlation to detect DTMF tones ( dtmf.c ).
Search WWH ::




Custom Search