Digital Signal Processing Reference
In-Depth Information
// Loop_stereo.c Stereo input and output with both channels
#include "dsk6713_aic23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
#define
LEFT 0
//reversed in init file
#define RIGHT 1
union {Uint32 combo; short channel[2];} AIC23_data;
interrupt void c_int11()
//interrupt service routine
{
AIC23_data.combo = input_sample(); //input 32-bit sample
output_left_sample(AIC23_data.channel[LEFT]);//left channels for I/O
return;
}
void main()
//main function
{
comm_intr();
//init DSK, codec, McBSP
while(1);
//infinite loop
}
FIGURE 2.6. Loop program with stereo input and output ( loop_stereo.c ).
Within the function input_sample , support functions from the BSL are included
to read a 32-bit data. The function input _ sample captures 32-bit data, 16 bits from
the left input channel and 16 bits from the right input channel. The union statement
is used to process each channel independently. The union of AIC23 _ data and combo
contains these 32-bit input data. The line of code for output is from the left channel
(by default) to output 16-bit data from the left input channel.
Build and run this project as loop _ stereo using the support files as in Example
1.2 for an interrupt-driven program. The main C source file loop _ stereo.c is con-
tained in the folder loop_stereo . Connect a 1 kHz (with approximate amplitude
of 2 V p-p) sine wave into the left input channel and a 2-kHz sine wave into the
right input channel. Verify that the left (default) output channel has the same input
signal frequency of 1 kHz, but reduced in amplitude (as expected). You do not need
a second adapter for the output side since the output defaults to the left channel.
Change the output line of code to
output _ left _ sample(AIC23 _ data.channel[RIGHT]);
and verify that the output is the 2-KHz sine wave from the right input channel. With
the line of code
output_right_sample(AIC23_data.channel[RIGHT]);
Search WWH ::




Custom Search