RM0440
17.3.12
Filter design tips
The FMAC architecture imposes some constraints on the design of digital filters.
1.
Implementation of direct form 2, or transposed forms, is not efficient. Filters which have
been designed for such forms should be converted to direct form 1.
2.
Cascaded filters must either be combined into a single stage, or implemented as
separate filters. In the latter case, multiple sets of filter coefficients can be pre-loaded
into the memory, one set per stage, and only the X2_BASE address changed to select
which set is used. The most efficient method of implementing a multi-stage filter is to
pre-load a large X1 buffer with input samples, run the IIR filter function on it using the
first stage coefficients, and store the output samples back in memory. Then change the
X2_BASE pointer to point to the 2nd stage coefficients, and reload the input buffer with
the output of the first stage (with a gain if required), before running the IIR function
again. The procedure is repeated for all stages. Once the final stage samples have
been transferred back into system memory, the input buffer can be loaded with the next
set of input samples, and a new round of calculations started. Note that the N sample
input buffer of each stage must be pre-loaded first of all with the N-1 last inputs from the
previous round, plus one new sample, in order to keep continuity between each round.
Similarly, the output buffer of each stage must be loaded with the last M samples from
the previous round, for the same reason.
3.
The use of direct form 1 for IIR designs can lead to large positive or negative partial
sums in the accumulator, if for example a large step occurs on the input, or some of the
filter coefficients' absolute values are >1. Since the accumulator is limited to 26 bits, the
biggest value that it can handle without wrapping (changing sign) is 0x1FFFFFF
positive or 0x2000000 negative. This corresponds to 3.99999988 and -4 respectively in
q3.23 fixed point format. Wrapping does not represent a problem provided the
wrapping is "undone" before the end of the accumulation. However this is not always
the case when a filter is starting up and can lead to unexpected results. Consider pre-
loading the output buffer with suitable values to avoid this.
4.
The IIR filter has feed-forward (numerator) coefficients [b
(denominator) coefficients [1, a
denominator coefficients to have an absolute value greater than 1 to achieve a steep
roll-off in the frequency response. Given that the coefficients are coded in fixed point
q1.15 format, this is not possible. Nevertheless, by scaling the denominator coefficients
by a factor 2
implemented. However an inverse gain of 2
accumulator to compensate the scaling. This will have an adverse effect on the signal-
to-noise ratio.
, ..., a
1
-R
-R
, such that 2
.[1, a
1
RM0440 Rev 1
Filter Math Accelerator (FMAC)
]. Many IIR filters require some of the
M
, ..., a
] are all less than 1, such filters can be
M
R
must be applied at the output of the
, b
, ..., b
], and feed-back
0
1
N-1
465/2083
473
Need help?
Do you have a question about the STM32G4 Series and is the answer not in the manual?