81,99 €
Features inexpensive ARM® Cortex®-M4 microcontroller development systems available from Texas Instruments and STMicroelectronics.
This book presents a hands-on approach to teaching Digital Signal Processing (DSP) with real-time examples using the ARM® Cortex®-M4 32-bit microprocessor. Real-time examples using analog input and output signals are provided, giving visible (using an oscilloscope) and audible (using a speaker or headphones) results. Signal generators and/or audio sources, e.g. iPods, can be used to provide experimental input signals. The text also covers the fundamental concepts of digital signal processing such as analog-to-digital and digital-to-analog conversion, FIR and IIR filtering, Fourier transforms, and adaptive filtering.
Digital Signal Processing Using the ARM® Cortex®-M4:
Digital Signal Processing Using the ARM® Cortex®-M4 serves as a teaching aid for university professors wishing to teach DSP using laboratory experiments, and for students or engineers wishing to study DSP using the inexpensive ARM® Cortex®-M4.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 307
Veröffentlichungsjahr: 2015
Cover
Title Page
Copyright
Dedication
Preface
Chapter 1: ARM® CORTEX®-M4 Development Systems
1.1 Introduction
Reference
Chapter 2: Analog Input and Output
2.1 Introduction
2.2 TLV320AIC3104 (AIC3104) Stereo Codec for Audio Input and Output
2.3 WM5102 Audio Hub Codec for Audio Input and Output
2.4 Programming Examples
2.5 Real-Time Input and Output Using Polling, Interrupts, and Direct Memory Access (DMA)
2.6 Real-Time Waveform Generation
2.7 Identifying the Frequency Response of the DAC Using Pseudorandom Noise
2.8 Aliasing
2.9 Identifying The Frequency Response of the DAC Using An Adaptive Filter
2.10 Analog Output Using the STM32F407'S 12-BIT DAC
References
Chapter 3: Finite Impulse Response Filters
3.1 Introduction to Digital Filters
3.2 Ideal Filter Response Classifications: LP, HP, BP, BS
3.3 Programming Examples
Chapter 4: Infinite Impulse Response Filters
4.1 Introduction
4.2 IIR Filter Structures
4.3 Impulse Invariance
4.4 BILINEAR TRANSFORMATION
4.5 Programming Examples
Reference
Chapter 5: Fast Fourier Transform
5.1 Introduction
5.2 Development of the FFT Algorithm with RADIX-2
5.3 Decimation-in-Frequency FFT Algorithm with RADIX-2
5.4 Decimation-in-Time FFT Algorithm with RADIX-2
5.5 Decimation-in-Frequency FFT Algorithm with RADIX-4
5.6 Inverse Fast Fourier Transform
5.7 Programming Examples
5.8 Frame- or Block-Based Programming
5.9 Fast Convolution
Reference
Chapter 6: Adaptive Filters
6.1 Introduction
6.2 Adaptive Filter Configurations
6.3 Performance Function
6.4 Searching for the Minimum
6.5 Least Mean Squares Algorithm
6.6 Programming Examples
Index
End User License Agreement
xi
xii
1
2
3
4
5
6
7
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
299
300
301
302
Cover
Table of Contents
Preface
Begin Reading
Chapter 1: ARM® CORTEX®-M4 Development Systems
Figure 1.1 Texas Instruments TM4C123 LaunchPad.
Figure 1.2 STMicroelectronics STM32F407 Discovery.
Figure 1.3 AIC3104 audio booster pack.
Figure 1.4 Wolfson Pi audio card.
Chapter 2: Analog Input and Output
Figure 2.1 Basic digital signal processing system.
Figure 2.2 Simplified block diagram representation of input side of AIC3104 codec showing selected blocks and signal paths used by the example programs in this book (left channel only).
Figure 2.3 Simplified block diagram representation of output side of AIC3104 codec showing selected blocks and signal paths used by the example programs in this book (left channel only).
Figure 2.4 Analog input and output connections on the AIC3104 audio booster pack.
Figure 2.5 Analog input and output connections on the Wolfson audio card.
Figure 2.6 Pulse output on GPIO pin PE2 by program tm4c123_loop_dma.c.
Figure 2.7 Delay introduced by use of DMA-based i/o in program tm4c123_loop_dma.c. Upper trace shows rectangular pulse of duration 1 ms applied to LINE IN, lower trace shows output from LINE OUT. BUFSIZE = 256, sampling rate 48 kHz.
Figure 2.8 Delay introduced by use of interrupt-based i/o in program tm4c123_loop_intr.c. Upper trace shows rectangular pulse of duration 1 ms applied to LINE IN, lower trace shows output from LINE OUT. Sampling rate 48 kHz.
Figure 2.9 Delay introduced by use of DMA-based i/o in program stm32f4_loop_dma.c. Upper trace shows rectangular pulse of duration 1 ms applied to LINE IN, lower trace shows output from LINE OUT. BUFSIZE = 256, sampling rate 48 kHz.
Figure 2.10 Delay introduced by use of interrupt-based i/o in program stm32f4_loop_intr.c. Upper trace shows rectangular pulse of duration 1 ms applied to LINE IN, lower trace shows output from LINE OUT. Sampling rate 48 kHz.
Figure 2.11 Block diagram representation of program tm4c123_delay_intr.c.
Figure 2.12 Block diagram representation of program tm4c123_echo_intr.c.
Figure 2.13 Block diagram representation of program tm4c123_flanger_intr.c.
Figure 2.14 (a) impulse response and (b) magnitude frequency response of flanger implemented using program tm4c123_flanger_intr.c at an instant when delay is equal to 104.2 µs. The notches in the magnitude frequency response are at frequencies 4800 and 14,400 Hz.
Figure 2.15 (a) Impulse response and (b) magnitude frequency response of modified flanger implemented using program tm4c123_flanger_intr.c at an instant when delay is equal to 208.3 µs. The notches in the magnitude frequency response are at frequencies 0, 4800, 9600, 14,400, and 19,200 Hz.
Figure 2.16 Output waveform produced using program tm4c123_flanger_dimpulse_intr.c at an instant when delay is equal to approximately 400 µs.
Figure 2.21 Rectangular pulse output on GPIO pin PD15 by program stm32f4_sine_intr.c.
Figure 2.17 Spectrum and spectrogram of flanger output for pseudorandom noise input. In the spectrogram, the -axis represents time in seconds and the -axis represents frequency in Hz.
Figure 2.18 Sample values stored in array lbuffer by program stm32f4_loop_buf_intr.c plotted using MATLAB function stm32f4_logftt(). Input signal frequency was 350 Hz.
Figure 2.19 (a) 1-kHz sinusoid generated using program tm4c123_sine48_intr.c viewed using
Rigol DS1052E
oscilloscope connected to (black) LINE OUT connection on audio booster pack. (b) Magnitude of FFT of signal plotted using MATLAB.
Figure 2.20 (a) 1-kHz sinusoid generated using program tm4c123_sine48_intr.c viewed using
Rigol DS1052E
oscilloscope connected to scope hook on audio booster pack. (b) Magnitude of FFT of signal plotted using MATLAB.
Figure 2.22 Output from program tm4c123_sineDTMF_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.23 Output from program stm32f4_square_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.24 Output from program stm32f4_square_intr.c viewed in both time and frequency domains using
Rigol DS1052 oscilloscope
.
Figure 2.25 Output from program tm4c123_square_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.26 Output from program tm4c123_square_intr.c viewed in both time and frequency domains using
Rigol DS1052 oscilloscope
.
Figure 2.27 Output from program tm4c123_square_1khz_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.28 Output from program stm32f4_dimpulse_intr.c viewed in time and frequency domains using
Rigol DS1052 oscilloscope
.
Figure 2.29 Output from program tm4c123_dimpulse_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.30 Output waveform generated by program tm4c123_ramp_intr.c.
Figure 2.31 Output waveform generated by program tm4c123_am_intr.c.
Figure 2.32 Output from program tm4c123_prbs_intr.c viewed using
Rigol DS1052
oscilloscope and
Goldwave
.
Figure 2.33 Output from program tm4c123_prbs_deemph_intr.c viewed using
Rigol DS1052
oscilloscope and
Goldwave
.
Figure 2.34 Output from program tm4c123_prbs_hpf_intr.c viewed using
Rigol DS1052
oscilloscope and
Goldwave
.
Figure 2.35 Output from program tm4c123_prbs_biquad_intr.c viewed using
Rigol DS1052
oscilloscope and
Goldwave
.
Figure 2.36 Output from program tm4c123_prandom_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.38 Sample values read from the WM5102 ADC and stored in array lbuffer by program stm32f4_loop_buf_intr.c.
Figure 2.37 Square wave input signal used with program stm32f4_loop_buf_intr.c.
Figure 2.39 Sample values read from the WM5102 ADC and stored in array lbuffer by program tm4c123_loop_buf_intr.c.
Figure 2.40 Sample values read from the AIC3104 ADC and stored in array buffer by program tm4c123_sine48_loop_intr.c.
Figure 2.41 Connection diagram for program tm4c123_sysid_CMSIS_intr.c.
Figure 2.42 The impulse response and magnitude frequency identified using program tm4c123_sysid_CMSIS_intr.c with connections as shown in Figure 2.41, displayed using MATLAB function tm4c123_logfft(). Sampling frequency 8000 Hz, 128-coefficient adaptive filter.
Figure 2.43 The impulse response and magnitude frequency identified using program tm4c123_sysid_CMSIS_intr.c with a first-order low-pass analog filter connected between LINE IN and LINE OUT sockets, displayed using MATLAB function tm4c123_logfft(). Sampling frequency 8000 Hz, 128-coefficient adaptive filter.
Figure 2.44 The impulse response and magnitude frequency identified using program tm4c123_sysid_CMSIS_intr.c with connections as shown in Figure 2.41 and de-emphasis enabled, displayed using MATLAB function tm4c123_logfft(). Sampling frequency 8000 Hz, 128-coefficient adaptive filter.
Figure 2.45 The impulse response and magnitude frequency identified using program stm32f4_sysid_CMSIS_intr.c with LINE OUT connected directly to LINE OUT, displayed using MATLAB function stm32f4_logfft(). Sampling frequency 8000 Hz, 128-coefficient adaptive filter.
Figure 2.46 Connection diagram for program tm4c123_sysid_CMSIS_intr.c.
Figure 2.47 The impulse response and magnitude frequency identified using program tm4c123_sysid_CMSIS_intr.c with connections as shown in Figure 2.46, displayed using MATLAB function tm4c123_logfft(). Sampling frequency 16,000 Hz, 192-coefficient adaptive filter.
Figure 2.48 Pulse output on GPIO pin PE2 by program tm4c123_sysid_CMSIS_intr.c running at a sampling rate of 16 kHz and using 192 adaptive filter coefficients.
Figure 2.49 Output from program stm32f4_sine8_dac12_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.50 Output from program stm32f4_square_dac12_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.51 Output from program stm32f4_dimpulse_dac12_intr.c viewed using
Rigol DS1052 oscilloscope
.
Figure 2.52 Output from program stm32f4_prbs_dac12_intr.c viewed using
Rigol DS1052 oscilloscope
.
Chapter 3: Finite Impulse Response Filters
Figure 3.1 Block diagram representation of a generic FIR filter.
Figure 3.2 Poles and zeros and region of convergence for causal sequence , , plotted in the -plane.
Figure 3.3 Poles and zeros and region of convergence for anticausal sequence , , plotted in the -plane.
Figure 3.4 Possible region of convergence, plotted in the -plane, corresponding to a right-sided causal sequence for a system with two real-valued poles.
Figure 3.6 Possible region of convergence, plotted in the -plane, corresponding to a two-sided noncausal sequence for a system with two real-valued poles.
Figure 3.7 Poles and zeros and region of convergence for plotted in the -plane, for . Corresponding sequence is causal and stable.
Figure 3.9 Poles and zeros and region of convergence for plotted in the -plane, for . Corresponding sequence is causal and unstable.
Figure 3.10 Poles and zeros and region of convergence for plotted in the -plane, for . Corresponding sequence is anticausal and stable.
Figure 3.12 Poles and zeros and region of convergence for plotted in the -plane, for . Corresponding sequence is anticausal and unstable.
Figure 3.13 Time-domain and -domain block diagram representations of a discrete-time LTI system.
Figure 3.14 Mapping from the -plane to the -plane.
Figure 3.15 Ideal filter magnitude frequency responses. (a) Low-pass (LP). (b) High-pass (HP). (c) Band-pass (BP). (d) Band-stop (BS).
Figure 3.16 Ideal low-pass frequency response defined over normalized frequency range .
Figure 3.17 Sixty-one of the infinite number of values in the discrete-time impulse response obtained by taking the inverse DTFT of the ideal low-pass frequency response of Figure 3.16.
Figure 3.18 The discrete-time impulse response of Figure 3.17 truncated to values.
Figure 3.19 The continuous, periodic magnitude frequency response obtained by taking the DTFT of the truncated impulse response shown in Figure 3.18 (plotted against normalized frequency ).
Figure 3.20 A 33-point Hanning window.
Figure 3.21 The magnitude frequency response corresponding to the filter coefficients of Figure 3.22 (plotted against normalized frequency ).
Figure 3.22 The filter coefficients of Figure 3.17 multiplied by the Hanning window of Figure 3.20.
Figure 3.23 The magnitude frequency responses of Figure 3.19 and 3.21 plotted on a logarithmic scale, against normalized frequency .
Figure 3.24 Ideal high-pass filter magnitude frequency response.
Figure 3.25 Ideal band-pass filter magnitude frequency response.
Figure 3.26 Ideal band-stop filter magnitude frequency response.
Figure 3.27 Theoretical magnitude frequency response of the five-point moving average filter (sampling rate 8 kHz).
Figure 3.28 Magnitude frequency response of the five-point moving average filter demonstrated using program stm32f4_average_prbs_intr.c and displayed using (a)
Rigol DS1052E
oscilloscope (lower trace) and (b)
Goldwave
.
Figure 3.29 Connection diagram for use of program tm4c123_sysid_CMSIS_intr.c to identify the characteristics of a moving average filter implemented using two sets of hardware.
Figure 3.30 Impulse response of the five-point moving average filter identified using two launchpads and booster packs and programs tm4c123_sysid_CMSIS_intr.c and tm4c123_average_intr.c.
Figure 3.31 Magnitude frequency response of the five-point moving average filter identified using two sets of hardware and programs tm4c123_sysid_CMSIS_intr.c and tm4c123_average_intr.c.
Figure 3.32 Connection diagram for program tm4c123_sysid_average_CMSIS_intr.c.
Figure 3.33 Magnitude frequency response of an eleven-point moving average filter implemented using program tm4c123_average_prbs_intr.c and displayed using
Goldwave
.
Figure 3.34 Magnitude frequency response of a five-point moving average filter with Hanning window implemented using program stm32f4_average_prbs_intr.c and displayed using
Goldwave
.
Figure 3.35 MATLAB fdatool window corresponding to design the of an FIR band-stop filter centered at 2700 Hz.
Figure 3.36 MATLAB fdatool window corresponding to design of FIR band-pass filter centered at 1750 Hz.
Figure 3.37 Output generated using program tm4c123_fir_prbs_intr.c and coefficient file bs2700.h displayed using (a)
Rigol DS1052E
oscilloscope and (b)
GoldWave
.
Figure 3.38 Output generated using program tm4c123_fir_prbs_intr.c using coefficient files (a) pass2b.h and (b) hp55.h.
Figure 3.39 Magnitude of the FFT of the output from program stm32f4_fir_prbs_buf_intr.c using coefficient header file bp1750.h.
Figure 3.40 Filter coefficients used in program stm32f4_fir_prbs_buf_intr.c (bp1750.h).
Figure 3.41 Magnitude of the FFT of the filter coefficients used in program stm32f4_fir_prbs_buf_intr.c.
Figure 3.42 A 200 Hz square wave passed through three different low-pass filters implemented using program tm4c123_fir3lp_intr.c.
Figure 3.43 Output generated using program tm4c123_fir_4types_intr.c.
Figure 3.44 Pseudorandom noise filtered using program tm4c123_notch2_intr.c.
Figure 3.45 Block diagram representation of scrambler implemented using program tm4c123_scrambler_intr.c.
Figure 3.46 Pulses output on GPIO pin PE2 by programs tm4c123_fir_prbs_intr.c and tm4c123_fir_prbs_dma.c.
Chapter 4: Infinite Impulse Response Filters
Figure 4.1 Direct form I IIR filter structure.
Figure 4.2 Direct form II IIR filter structure.
Figure 4.3 Direct form II transpose IIR filter structure.
Figure 4.4 Cascade form IIR filter structure.
Figure 4.5 Fourth-order IIR filter with two direct form II sections in cascade.
Figure 4.6 Parallel form IIR filter structure.
Figure 4.7 Fourth-order IIR filter with two direct form II sections in parallel.
Figure 4.8 Relationship between analog and digital frequencies, and , due to frequency warping in the bilinear transform.
Figure 4.9 (a) Magnitude frequency response of filter . (b) Phase response of filter .
Figure 4.10 Impulse responses (scaled by sampling period ) and of continuous-time filter and its impulse-invariant digital implementation.
Figure 4.11 Output from program tm4c123_iirsos_prbs_intr.c using coefficient file impinv.h, viewed using the FFT function of a
Rigol DS1052E
oscilloscope.
Figure 4.12 Output from program tm4c123_iirsos_prbs_intr.c using coefficient file impinv.h, viewed using
Goldwave
.
Figure 4.13 Output from program tm4c123_iirsos_delta_intr.c using coefficient file impinv.h, viewed using the FFT function of a
Rigol DS1052E
oscilloscope.
Figure 4.14 The magnitude frequency response of the filter implemented by program tm4c123_iirsos_delta_intr.c using coefficient file impinv.h, plotted using MATLAB function tm4c123_logfft().
Figure 4.15 Output from program tm4c123_iirsos_prbs_intr.c using coefficient file bilinear.h, viewed using the FFT function of a
Rigol DS1052E
oscilloscope.
Figure 4.18 The magnitude frequency response of the filter implemented by program tm4c123_iirsos_delta_intr.c using coefficient file bilinear.h, plotted using MATLAB function tm4c123_logfft().
Figure 4.19 The effect of the bilinear transform on the magnitude frequency response of the example filter.
Figure 4.20 MATLAB fdatool window showing the magnitude frequency response of a fourth-order elliptic low-pass filter.
Figure 4.21 MATLAB fdatool window showing the magnitude frequency response of a second-order Chebyshev low-pass filter.
Figure 4.16 Output from program tm4c123_iirsos_prbs_intr.c using coefficient file bilinear.h, viewed using
Goldwave
.
Figure 4.22 Impulse response and magnitude frequency response of the filter implemented by program tm4c123_iirsos_delta_intr.c, using coefficient file elliptic.h, plotted using MATLAB function tm4c123_logfft().
Figure 4.23 Output from program tm4c123_iirsos_delta_intr.c, using coefficient file elliptic.h viewed using a
Rigol DS1052E
oscilloscope.
Figure 4.24 MATLAB fdatool window showing the magnitude frequency response of an 18th-order band-pass filter centered on 2000 Hz.
Figure 4.25 Output from program tm4c123_iirsos_prbs_intr.c, using coefficient file bp2000.h viewed using a
Rigol DS1052E
oscilloscope.
Figure 4.26 Output from program tm4c123_iirsos_prbs_intr.c, using coefficient file bp2000.h viewed using
Goldwave
.
Figure 4.27 Connection diagram for program tm4c123_sysid_biquad_intr.c.
Figure 4.28 Frequency response of signal path through DAC, connecting cable, and ADC shown in Figure 4.27 with biquad filters disabled.
Figure 4.29 Frequency response of signal path through DAC, connecting cable, and ADC shown in Figure 4.27 with biquad filters programmed as a fourth-order elliptic low-pass filter and enabled.
Figure 4.30 fdatool used to design a fourth-order elliptic band-pass filter.
Figure 4.31 Frequency response of signal path through DAC, connecting cable, and ADC shown in Figure 4.27 with biquad filters programmed as a fourth-order elliptic band-pass filter and enabled.
Figure 4.32 Block diagram representation of Equation (4.53).
Figure 4.33 Block diagram representation of Equation (4.54).
Figure 4.34 Output samples generated by program stm32f4_sinegenDTMF_intr.c plotted using MATLAB function stm32f4_logfft().
Figure 4.35 Output signal generated by program stm32f4_sinegenDTMF_intr.c viewed using a
Rigol DS1052E
oscilloscope.
Figure 4.36 Pole-zero map for notch filter described by Equation (4.56) for and .
Figure 4.37 Frequency response of notch filter described by Equation (4.56) for and .
Figure 4.38 Pseudorandom noise filtered by program tmc123_iirsos_prbs_intr.c using header file iir_notch_coeffs.h.
Chapter 5: Fast Fourier Transform
Figure 5.1 Twiddle factors for represented as vectors in the complex plane.
Figure 5.2 Decomposition of 8-point DFT into two 4-point DFTs using decimation-in-frequency with radix-2.
Figure 5.3 Decomposition of 4-point DFT into two 2-point DFTs using decimation-in-frequency with radix-2.
Figure 5.4 2-point FFT butterfly structure.
Figure 5.5 Block diagram representation of 8-point FFT using decimation-in-frequency with radix-2.
Figure 5.6 Decomposition of 8-point DFT into two 4-point DFTs using decimation-in-time with radix-2.
Figure 5.7 Decomposition of 4-point DFT into two 2-point DFTs using decimation-in-time with radix-2.
Figure 5.8 Block diagram representation of 8-point FFT using decimation-in-time with radix-2.
Figure 5.9 Complex contents of array samples (TESTFREQ = 800.0) before calling function dft(), viewed in a
Memory
window in the
MDK-ARM debugger
.
Figure 5.10 Complex contents of array samples (TESTFREQ = 800.0) before calling function dft(), plotted using MATLAB function stm32f4_plot_complex().
Figure 5.11 Complex contents of array samples (TESTFREQ = 800.0) after calling function dft(), plotted using MATLAB function stm32f4_plot_complex().
Figure 5.12 Complex contents of array samples (TESTFREQ = 900.0) after calling function dft(), plotted using MATLAB function stm32f4_plot_complex().
Figure 5.13
MDK-ARM Register
window showing
Sec
item.
Figure 5.14 Output signal from program tm4c123_dft128_dma.c viewed using an oscilloscope.
Figure 5.15 Output signal from program stm32f4_dft128_dma.c viewed using an oscilloscope.
Figure 5.16 Partial contents of array outbuffer, plotted using MATLAB function tm4c123_plot_real(), for input sinusoid of frequency 1750 Hz.
Figure 5.17 Detail of output signal from program tm4c123_dft128_dma.c for input sinusoid of frequency 1781 Hz.
Figure 5.18 Detail of output signal from program tm4c123_dft128_dma.c for input sinusoid of frequency 1750 Hz.
Figure 5.19 Partial contents of array outbuffer, plotted using MATLAB function tm4c123_plot_real(), for input sinusoid of frequency 1781 Hz.
Figure 5.20 Detail of output signal from program tm4c123_dft128_dma.c, modified to apply a Hamming window to blocks of input samples, for input sinusoid of frequency 1750 Hz.
Figure 5.21 Detail of output signal from program tm4c123_dft128_dma.c, modified to apply a Hamming window to blocks of input samples, for input sinusoid of frequency 1781 Hz.
Figure 5.22 Partial contents of array outbuffer, plotted using MATLAB function tm4c123_plot_real(), for input sinusoid of frequency 1750 Hz. (Hamming window applied to blocks of input samples.)
Figure 5.23 Partial contents of array outbuffer, plotted using MATLAB function tm4c123_plot_real(), for input sinusoid of frequency 1781 Hz. (Hamming window applied to blocks of input samples.)
Figure 5.24 Output signal generated by program tm4c123_fft128_sinetable_dma.c, displayed using a
Rigol DS1052E
oscilloscope.
Figure 5.25 Output signal from program tm4c123_graphicEQ_CMSIS_dma.c, displayed using
Goldwave
, for a pseudorandom noise input signal. bass_gain = 0.1, mid_gain = 0.1, treble_gain = 0.25.
Chapter 6: Adaptive Filters
Figure 6.1 Basic adaptive filter structure.
Figure 6.2 Simplified block diagram of basic adaptive filter structure.
Figure 6.3 Basic adaptive filter structure configured for prediction.
Figure 6.4 Basic adaptive filter structure configured for system identification.
Figure 6.5 Basic adaptive filter structure configured for noise cancellation.
Figure 6.6 Alternative representation of basic adaptive filter structure configured for noise cancellation emphasizing the difference in paths from a single noise source to primary and reference sensors.
Figure 6.7 Basic adaptive filter structure configured for equalization.
Figure 6.8 Block diagram representation of FIR filter.
Figure 6.9 Performance function for single weight case.
Figure 6.10 Steepest descent algorithm illustrated for single weight case.
Figure 6.11 Plots of (a) desired output, (b) adaptive filter output, and (c) error generated using program stm32f4_adaptive.c and displayed using MATLAB function stm32f4_plot_real().
Figure 6.12 Block diagram representation of program tm4c213_adaptnoise_intr.c.
Figure 6.13 Block diagram representation of program tm4c123_noise_cancellation_intr.c.
Figure 6.14 Impulse response and magnitude frequency response of IIR filter identified by the adaptive filter in program tm4c123_noise_cancellation_intr.c and plotted using MATLAB function tm4c123_logfft().
Figure 6.15 Block diagram representation of program tm4c123_adaptIDFIR_CMSIS_intr.c.
Figure 6.16 Output from program stm32f4_adaptIDFIR_CMSIS_intr.c using coefficient header file bs55.h viewed using
Rigol DS1052E
oscilloscope.
Figure 6.17 Output from adaptive filter in program tm4c123_adaptIDFIR_CMSIS_init_intr.c.
Figure 6.18 Block diagram representation of program tm4c123_iirsosadapt_CMSIS_intr.c.
Figure 6.19 Output from adaptive filter in program tm4c123_iirsosadapt_CMSIS_intr.c viewed using a
Rigol DS1052E
oscilloscope.
Figure 6.20 Adaptive filter coefficients from program tm4c123_iirsosadapt_CMSIS_intr.c plotted using MATLAB function tm4c123_logfft().
Figure 6.21 Connection diagram for program tm4c123_sysid_CMSIS_intr.c in Example 6.14.
Figure 6.22 Adaptive filter coefficients from program tm4c123_sysid_CMSIS_intr.c plotted using MATLAB function tm4c123_logfft()
Figure 6.23 Adaptive filter coefficients from program tm4c123_sysid_CMSIS_dma.c plotted using MATLAB function tm4c123_logfft(). (a) BUFSIZE = 32 (b) BUFSIZE = 64.
Chapter 2: Analog Input and Output
Table 2.1 Summary of DMA Control Structures Used and Flags Set in Interrupt Service Routines SSI0IntHandler() and SSI1IntHandler() in Program tm4c123_loop_dma.c
Chapter 5: Fast Fourier Transform
Table 5.1 Execution Times for Functions dft(), dftw(), fft() and arm_cfft_f32()
DONALD S. REAY
Heriot-Watt University
Copyright © 2016 by John Wiley & Sons, Inc. All rights reserved
Published by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
ARM and Cortex are registered trademarks of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. All rights reserved.
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/ trademarks for a list of additional trademarks. The MathWorks Publisher Logo identifies books that contain MATLAB® content. Used with Permission. The book's or downloadable software's use of discussion of MATLAB® software or related products does not constitute endorsement or sponsorship by the MathWorks of a particular use of the MATLAB® software or related products.
For MATLAB® product information, or information on other related products, please contact:
The MathWorks, Inc., 3 Apple Hill Drive, Natick. MA 01760-2098 USA, Tel: 508-647-7000, Fax: 508-647-7001, E-mail: info@mathworks.com, Web: www.mathworks.com, How to buy: www.mathworks.com/store
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: While the publisher and author have used their best efforts in preparing this book, they make no representations or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for a particular purpose. No warranty may be created or extended by sales representatives or written sales materials. The advice and strategies contained herein may not be suitable for your situation. You should consult with a professional where appropriate. Neither the publisher nor author shall be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages.
For general information on our other products and services or for technical support, please contact our Customer Care Department within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic formats. For more information about Wiley products, visit our web site at www.wiley.com.
Library of Congress Cataloging-in-Publication Data:
Reay, Donald (Donald S.), author.
Digital signal processing using the ARM Cortex-M4 / Donald Reay.
pages cm
Includes bibliographical references and index.
ISBN 978-1-118-85904-9 (pbk.)
1. Signal processing–Digital techniques. 2. ARM microprocessors. I. Title.
TK5102.9.R4326 2015
621.382′2–dc23
2015024771
To Reiko
This book continues the series started in 1990 by Rulph Chassaing and Darrell Horning's Digital Signal Processing with the TMS320C25, which tracked the development of successive generations of digital signal processors by Texas Instruments. More specifically, each book in the series up until now has complemented a different inexpensive DSP development kit promoted for teaching purposes by the Texas Instruments University Program. A consistent theme in the books has been the provision of a large number of simple example programs illustrating DSP concepts in real time, in an electrical engineering laboratory setting.
It was Rulph Chassaing's belief, and this author continues to believe, that hands-on teaching of DSP, using hardware development kits and laboratory test equipment to process analog audio frequency signals, is a valuable and effective way of reinforcing the theory taught in lectures.
The contents of the books, insofar as they concern fundamental concepts of digital signal processing such as analog-to-digital and digital-to-analog conversion, finite impulse response (FIR) and infinite impulse response (IIR) filtering, the Fourier transform, and adaptive filtering, have changed little. Every academic year brings another cohort of students wanting to study this material. However, each book has featured a different DSP development kit.
In 2013, Robert Owen suggested to me that hands-on DSP teaching could be implemented using an inexpensive ARM® Cortex-M4® microcontroller. I pointed out that a Texas Instruments C674x processor was very significantly more computationally powerful than an ARM Cortex-M4. But I also went ahead and purchased a Texas Instruments Stellaris LaunchPad. I constructed an audio interface using a Wolfson WM8731 codec and successfully ported the program examples from my previous book to that hardware platform.
This book is aimed at senior undergraduate and postgraduate electrical engineering students who have some knowledge of C programming and linear systems theory, but it is intended, and hoped, that it may serve as a useful resource for anyone involved in teaching or learning DSP and as a starting point for teaching or learning more.
I am grateful to Robert Owen for first making me aware of the ARM Cortex-M4; to Khaled Benkrid at the ARM University Program and to the Royal Academy of Engineering for making possible a six-month Industrial Secondment to ARM during which teaching materials for the STM32f01 platform were developed; to Gordon McLeod and Scott Hendry at Wolfson Microelectronics for their help in getting the Wolfson Pi audio card to work with the STM32f01 Discovery; to Sean Hong, Karthik Shivashankar, and Robert Iannello at ARM for all their help; to Joan Teixidor Buixeda for helping to debug the program examples; to Cathy Wicks at the TI University Program and Hieu Duong at CircuitCo for developing the audio booster pack; and to Kari Capone and Brett Kurzman at Wiley for their patience. But above all, I thank Rulph Chassaing for inspiring me to get involved in teaching hands-on DSP.
Donald S. Reay
Edinburgh
2015
Traditionally, real-time digital signal processing (DSP) has been implemented using specialized and relatively expensive hardware, for example, digital signal processors or field-programmable gate arrays (FPGAs). The ARM® Cortex®-M4 processor makes it possible to process audio in real time (for teaching purposes, at least) using significantly less expensive, and simpler, microcontrollers.
The ARM Cortex-M4 is a 32-bit microcontroller. Essentially, it is an ARM Cortex-M3 microcontroller that has been enhanced by the addition of DSP and single instruction multiple data (SIMD) instructions and (optionally) a hardware floating-point unit (FPU). Although its computational power is a fraction of that of a floating-point digital signal processor, for example, the Texas Instruments C674x, it is quite capable of implementing DSP algorithms, for example, FIR and IIR filters and fast Fourier transforms for audio signals in real-time.
A number of semiconductor manufacturers have developed microcontrollers that are based on the ARM Cortex-M4 processor and that incorporate proprietary peripheral interfaces and other IP blocks. Many of these semiconductor manufacturers make available very-low-cost evaluation boards for their ARM Cortex-M4 microcontrollers. Implementing real-time audio frequency example programs on these platforms, rather than on more conventional DSP development kits, constitutes a reduction of an order of magnitude in the hardware cost of implementing hands-on DSP teaching. For the first time, students might realistically be expected to own a hardware platform that is useful not only for general microcontroller/microprocessor programming and interfacing activities but also for implementation of real-time DSP.
At the time that the program examples presented in this book were being developed, there were no commercially available low-cost ARM Cortex-M4 development boards that incorporated high-quality audio input and output. The STMicroelectronics STM32F407 Discovery board features a high-quality audio digital-to-analog converter (DAC) but not a correspondinganalog-to-digital converter (ADC). Many ARM Cortex-M4 devices, including both the STMicroelectronics STM32F407 and the Texas Instruments TM4C123, feature multichannel instrumentation-quality ADCs. But without additional external circuitry, these are not suitable for the applications discussed in this book.
The examples in this book require the addition (to an inexpensive ARM Cortex-M4 development board) of an (inexpensive) audio interface.
In the case of the STMicroelectronics STM32F407 Discovery board and of the Texas Instruments TM4C123 LaunchPad, compatible and inexpensive audio interfaces are provided by the Wolfson Pi audio card and the CircuitCo audio booster pack, respectively. The low-level interfacing details and the precise performance characteristics and extra features of the two audio interfaces are subtly different. However, each facilitates the input and output of high-quality audio signals to and from an ARM Cortex-M4 processor on which DSP algorithms may be implemented.
Almost all of the program examples presented in the subsequent chapters of this book are provided, in only very slightly different form, for both the STM32F407 Discovery and the TM4C123 LaunchPad, on the partner website http://www.wiley.com/go/Reay/ARMcortexM4.
However, in most cases, program examples are described in detail, and program listings are presented, only for one or other hardware platform. Notable exceptions are that, in Chapter 2, low-level i/o mechanisms (implemented slightly differently in the two devices) are described in detail for both hardware platforms and that a handful of example programs use features unique to one or other processor/audio interface.
This book does not describe the internal architecture or features of the ARM Cortex-M4 processor in detail. An excellent text on that subject, including details of its DSP-related capabilities, is The Definitive Guide to ARM® Cortex®-M3 and Cortex®-M4 Processors by Yiu [1].
The Texas Instruments and STMicroelectronics ARM Cortex-M4 processor boards used in this book are shown in Figures 1.1 and 1.2. The program examples presented in this book assume the use of the Keil MDK-ARM development environment, which is compatible with both development kits. An alternative development environment, Texas Instruments' Code Composer Studio, is available for the TM4C123 LaunchPad and the program examples have been tested using this. Versions of the program examples compatible with Code Composer Studio version 6 are provided on the partner website http://www.wiley.com/go/Reay/ARMcortexM4.
Figure 1.1 Texas Instruments TM4C123 LaunchPad.
Figure 1.2 STMicroelectronics STM32F407 Discovery.
The CircuitCo audio booster pack (for the TM4C123 LaunchPad) and the Wolfson Pi audio card (for the STM32F407 Discovery) are shown in Figures1.3 and 1.4. The audio booster pack and the launchpad plug together, whereas the Wolfson audio card, which was designed for use with a Raspberry Pi computer, must be connected to the Discovery using a custom ribbon cable (available from distributor Farnell).
Figure 1.3 AIC3104 audio booster pack.
Figure 1.4 Wolfson Pi audio card.
Rather than presenting detailed instructions here that may be obsolete as soon as the next version of MDK-ARM is released, the reader is directed to the “getting started” guide at the partner website http://www.wiley.com/go/Reay/ARMcortexM4. and before progressing to the next chapter of this book will need to install MDK-ARM, including the “packs” appropriate to the hardware platform being used and including the CMSIS DSP library, download the program examples from the website, and become familiar with how to open a project in MDK-ARM, add and remove files from a project, build a project, start and stop a debug session, and run and halt a program running on the ARM Cortex-M4 processor.
