Assignment #3: Due April 11, 2016
Assignment #3: Due April 11, 2016
For this part of the exercise use a 32 kHz sampling in the Cypress FM4 or
STM32F4. This gives you an audio capture bandwidth that well exceeds the 16
kHz folding frequency when using a PC sound system sampling at 44.1 or 48
ksps.
a.) In the appropriate ISR routine pass the input samples directly to the output.
Input a sinusoid from an Agilent 33250A function generator. Determine the
maximum input level of the input A/D and the maximum output level of the
D/A. This will likely require that you perform some scaling experiments as
you pass samples read from the A/D directly over the D/A. To understand
amplitude limiting issues, some form of scaling will also be needed. Do not
alter the default codec gain settings for this experiment. Note these settings
are hidden away in the codec library, but you do have access to them. The
idea is to determine the exact dynamic range values for the default settings
for future reference. I realize that these values can change if the codec atten-
uator settings are altered. Using a buffer to store left or right samples will
allow you to view the signal samples in say Python or MATLAB.
b.) Using the same configuration as in part (a), now apply a squarewave at the
input and measure the rising edge time delay in going from the analog input
to the analog output. Be sure to use a long enough period so that additional
Cortex-M4 Agilent 4395A
Real-Time
DSP Platform
Li
Li In
ne
ne
O
ut
Line
Wolfson 0 1
RF Out R .. A .. B
Codec
Active Probe/
Active Probe/
Adapter
Adapter
Cypress FM4 41802A
USB Adapter
or STM32F4 pwr
Figure 1: Agilent 4395A vector network analyzer interface to the Wolfson codec.
cycles do not creep in should the time delay be longer than you anticipate. Note the time
delay is clearly a function of the sampling clock, but with this signal sample processing
loop, the latency should be minimal.
c.) Repeat (b) when using the DMA frames-based loop thru found in the module, FM4_Co-
decLab_dma.c, with a frame size of 256 (default) and 512 (see Chapter 5 notes for
details on changing this). Note from the analysis of the ping/pong buffer scheme in notes
Chapter 5, you know that the delay is at least two buffer lengths. Here you again are mak-
ing the measurement in the analog domain using a scope.
d.) Using the vector network analyzer measure the frequency response magnitude in dB as the
analog output over the input (say using analyzer ports B/R). The frequency range you
sweep over should be consistent with the sampling frequency. Use what you learned in
part (a) to properly set the input level to the A/D. A good safe level for the input is 80-90%
of full-scale.
Plots from the 4395A can be obtained in several ways. A reliable approach is to use
the instrument capability to save an Excel data file or a tiff image file to the 4395A 3.5in
floppy drive. There are portable USB floppy drives in the lab for moving the captured files
to a PC.
Comment on the locations of the critical frequencies, e.g., lower and upper band edges
as appropriate, with respect to known A/D antialiasing filter characteristics in combination
with the known reconstruction filter characteristics. Try to verify the passband ripple that
we know exits in both the A/D and D/A signal paths.
2. In this problem you will again work with the WM5102 codec, but this time you will use a uni-
form white noise generator as a wideband signal source. The output of the D/A will then be
spectrum analyzed using Python/MATLAB via post-processing of a .wav audio file. You
may need to scale the output of the uniform random number generator before passing it to the
TM_GPIO_SetPinHigh(GPIOC, GPIO_Pin_8);
To ignore the A/D samples and use the noise generator samples instead, comment and uncom-
ment lines as shown above. When this program is run the noise generator is output to the D/A
which includes the a lowpass reconstruction filter (part of the delta-sigma D/A). In the dis-
crete-time domain we know that the power spectrum will be flat (white). Since here the noise
generator output is connected directly to the D/A, the PSD of the output should have shape
corresponding to the magnitude squared of the D/A lowpass filter frequency response, in cas-
cade with perhaps other analog circuit poles and zeros.
yn y a t Wolfson
White Ideal Shaping 2
Analog S out f = N o H shape f
Noise D/A Filter
Output
S in f = N o f
Figure 2: Model for the noise spectrum produced at the codec output.
Rather than using the analog spectrum analyzer as in Problem 1, this time we will use the
One condition to watch out for is overloading of the PC sound card line input. Goldwave has
level indicators to help with this however. Use the sound card line input found on the back of
the PC Workstation. The software mixer application has a separate set of mixer gain settings
just for recording. You will need to adjust the Line In volume and watch actual input levels on
Goldwave.
In summary, using the procedure described above obtain a MATLAB plot of the frequency
response magnitude in dB, of the Wolfson DAC output channel.
3. Using the sound card capture technique of Problem 2 modify the code to again pass signal
samples from input to output. Place a 1 kHz sinusoid at the input, at about 80-90% of full
scale. Capture the sinusoid at the output as a 30 second wave file. Perform spectral analysis as
in the noise case of Problem 2. Comment on the spectral purity and the presence of any distor-
tion terms. To understand the PC sound card ambient noise environment better, make a
recording with no input to the sound card to better characterize its limitations on dynamic
range and spectral purity. This reference plot should be made last, after you have properly set
the line-in level to avoid sound card input overload.
4. Using the STM32F4/LPC4088 Quickstart with Wolfson codec, and sampling rate of 48 kHz,
generate a sinusoidal oscillator that uses GUI slider app (STM32F4_GUI_slider.exe)
that connects via the serial port. Write your code so that the frequency of oscillation can be
tuned from 100 Hz to 20 kHz in 100 Hz steps using one of the six P_vals[] available. The
frequency determining variable will actually should be a float32_t variable. The approach
to generating the variable frequency oscillator will be via the equation
f0
s n = s nT = sin 2f 0 nT = sin 2 ---- n = sin n
fs
where T is the sample spacing, f s = 1 T , and f 0 is the analog oscillation frequency. The
angular change between samples is denoted by = 2 f 0 f s . If we let n = n , then
we can write that
n + 1 = n + 1 = n + = n +
For more information on this technique see Chapter 5 of the text. In C code we can build a
float version of this using the library <math.h> for the trig function (this will not be particu-
larly efficient in terms of CPU cycles, but will be interesting to investigate). Note: math.h is
also ready included via other headers in the project.
...
#define pi 3.141592653589
The A/D inputs will not be used for anything in this example. The output only needs to appear
on one channel, left or right.
5. OMIT This problem explores real-time generation of a dual tone multifrequency (DTMF)
tone. The row and column frequencies used to generate the telephone ‘touch tones’ are given
in Table 1.
697 Hz 1 2 3
770 Hz 4 5 6
852 Hz 7 8 9
941 Hz * 0 #
Using the frequency generation technique of Problem 4, a look-up table, or some other
method that works, to write a C program to serve as a DTMF signal generator. Use GEL files
to control modes of operation. The sampling rate will be f s = 8000 Hz. Additional require-
ments are as follows:
• The program will have a test mode, via two parameter sliders in the GUI slider app, so
that a given row column frequency pair can be generated for an indefinite duration.
• When not in the test mode, the program will dial a seven digit phone number, holding
each digit (frequency pair) for D ms. The value D will be set via a GUI slider app slider
too, over the range of 10ms to 1s. The phone number is to be held in an array or as a
character string, your choice. The bottom line is it needs to be changeable during the
demo.
• When dialing a phone number, the sequence will be repeated every 30s.