AN2182
Application note
Filters using the ST10 DSP library
Introduction
The ST10F2xx family provides a 16-bit multiply and accumulate unit (MAC) allowing control-oriented
signal processing and filtering widely used in digital applications.
An ST10 DSP software library, developed by STMicroelectronics, contains a set of basic arithmetic
operations such as multiplication as well as two main filter functions, FIR (finite impulse response) and IIR
(infinite impulse response), mainly used in digital signal processing.
The first chapter of this application note describes a theoretical digital implementation of four different
filters:
■
■
■
■
Low-pass filter
High-pass filter
Passband filter
Cut-band filter
The method adopted for each filter is the approximation of the ideal filter model by a FIR filter. This theory
aims to compute the FIR’s coefficients by truncating the real signal with a known window.
The second chapter illustrates a practical implementation of a low-pass filter using the ST10 DSP library,
its results and its limitations.
July 2007
Rev 1
1/18
www.st.com
18
Contents
AN2182
Contents
1
2
ST10 DSP library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Digital filtering principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1
2.2
2.3
Fourier transform of a sampled signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Linear filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Finite impulse response filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3
4
5
6
7
Low-pass filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
High-pass filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Passband filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Cutoff band filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Implementation example using the ST10 DSP library . . . . . . . . . . . . . . . 12
7.1
7.2
7.3
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Sampling frequency and FIR coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
7.3.1
7.3.2
Frequency response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Phase response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
8
9
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2/18
AN2182
ST10 DSP library
1
ST10 DSP library
The ST10 DSP free library is a set of arithmetic and signal processing functions based on the
ST10 MAC unit. These functions are callable from C and fully compatible with the Tasking
compiler.
This library manipulates signed integers coded on 16 or 32 bits. These integers represent
numbers belonging to the interval [–1, 1[. We name these formats: Q1.31 and Q1.15.
Table 1.
Examples of integer representations
–1
Q1.15
Q1.31
0xFFFF
0xFFFF
FFFF
-0.5
0xC000
0xC000
0000
-0.25
0xA000
0
0x0000
0.25
0x2000
0.5
0x4000
1 - 1/2
15
0x7FFF
0x7FFF
0000
1 - 1/2
31
0x7FFF
0x7FFFFFFF
0xA0000 0x00000 0x20000 0x40000
000
000
000
000
For a detailed description of the ST10 DSP library, please refer to the application note AN1442
“Signal processing with ST10-DSP”.
3/18
Digital filtering principles
AN2182
2
Digital filtering principles
Assume a continuous signal x(t) (the complex form corresponds to the signal’s phase and
magnitude at the instant t) with a pass band B. Assume that this signal will be filtered using a
filter with a continuous impulse response h(t).
When digital processing has to be used, it is necessary to sample the input signal with a
frequency of F
s
= 1/T
s
(T
s
being the sampling period). The output signal is then reconstituted
from the samples obtained at the filter’s output.
Figure 1.
Example of input and output signals
Filter h
Input signal
Output signal
The Shannon theorem states that when sampling a signal at discrete intervals, the sampling
frequency F
s
should be greater than twice the highest frequency of the input signal.
2.1
Fourier transform of a sampled signal
Signals are converted from the time domain to the frequency domain usually through the
Fourier transform. With the Fourier transform, the signal is converted to a magnitude and phase
at each frequency.
The Fourier transform of the sampled signal x(k) has the following expression:
∞
X
(
f
)
=
∑
x
(
k
)e
–
∞
∞
i2kπf
The time representation can be computed from the X(f) as follows:
x
(
k
)
=
∑
X
(
f
)e
–
∞
–
i
2kπf
2.2
Linear filtering
Using the notations defined in the previous section, the output signal y(n) is the convolution of
the input signal x(k) and the filter impulse response h(k) .
∞
y
(
n
)
=
∑
h
(
n
–
k
)x (
k
)
–
∞
=
(
h
(
k
) ⊗
x
(
k
))
n
where x(n) = x(nT
s
), h(n – k) = h((n – k)T
s
) and y(n) = y(nT
s
).
4/18
AN2182
Digital filtering principles
The output signal frequency response is given by the following expression:
Y
(
f
)
= H
(
f
) ⋅
X
(
f
)
where H(f), X(f) and Y(f) are the respective Fourier transforms of h(k), x(k) and y(k).
2.3
Finite impulse response filters
The FIR (Finite Impulse Response) are non-recursive filters, meaning that the output signal y(i)
is a linear combination of N input samples x(k) in the case of a N–1 order filter. Its equation is
N
–
1
⎛
⎞
⎜
y
(
n
)
=
a x
(
n
–
k
)⎟
⎜
∑
k
⎟
⎝
k = 0
⎠
where a
k
are the FIR’s coefficients.
A FIR filter is characterized by its order and its coefficients and can be used to implement any
kinds of filters (low-pass, high-pass, pass-band or cutoff band).
5/18