Digital Signal Processing Reference
In-Depth Information
// BPSK_demod.c PLL demodulator. Input from 1st DSK
#include "dsk6713_aic23.h"
//codec-DSK support file
#include <math.h>
Uint32 fs=DSK6713_AIC23_FREQ_16KHZ; //set sampling rate
#define NUMSAMP 16
//# samples per symbol
#define PI 3.1415926
short sample_data;
//input sample
short ri=0, r[10000]={0};
//buffer index/received data
short r_symbol[NUMSAMP];
//buffer to receive one period
short SBind=0, phiBind=0;
//symbol/phi buffer index
float phiBuf[1000] = {0};
//buffer to view phi estimates
float y1, y2, damp=1;
//correlation vectors,damping
float phi = PI;
//phase estimate
interrupt void c_int11() //interrupt service routine
{
int i, max=1;
sample_data=(short)input_sample(); //receive sample
r[ri++] = sample_data;
r_symbol[SBind++] = sample_data; //put sample in symbol buffer
if(ri >= 10000) ri = 0;
//reset buffer index
if(SBind == NUMSAMP)
//after one period is received
{
//then perform phi estimate
SBind = 0;
//reset buffer index
y1 = 0, y2 = 0;
for(i=0; i<NUMSAMP; i++)
//correlate received symbol
{
y1 += r_symbol[i]*sin(2*PI*i/NUMSAMP + phi - 0.1);
y2 += r_symbol[i]*sin(2*PI*i/NUMSAMP + phi + 0.1);
if(r_symbol[i] > max) max = r_symbol[i];
}
y1=y1/max; y2=y2/max; //normalize correlation coefs
phi = phi + 0.4*(y2 - y1)*phi; //determine new estimate for phi
if(phi < 1) phi=phi+2*PI; //normalize phi
if(phi >(2*PI+1)) phi=phi-2*PI;
phiBuf[phiBind++]=phi; //put phi in buffer for viewing
if(phiBind >= 1000) phiBind = 0; //reset buffer index
}
output_sample(phi);
}
void main()
{
comm_intr(); while(1);
//init DSK/infinite loop
}
FIGURE 10.29. C program implementing a PLL demodulator ( bpsk_demod.c ).
10.11.4 BPSK Transmitter and Receiver with PLL
The support files for this project are in the subfolders transmitter and receiver . This
project is the final product and includes the demodulation of a transmitted BPSK
signal. It uses two DSKs: one to transmit a BPSK signal and the other to demodu-
late it. The transmitter.c program shown in Figure 10.31 uses the stereo capa-
bility of the AIC23 codec to transmit a 12-kHz carrier signal through the right
Search WWH ::




Custom Search