Determine the desired corner
frequency and filter response.
Set the ADC sampling frequency.
This must be at least twice the expected bandwidth of the signal.
Calculate the desired
coefficients and filter order. The filter coefficients are rational numbers
which, combined with the sampling frequency, determine the pass and rejection
bands of the filter.
There are different
methods and tools for FIR filter coefficient calculation, which is not
discussed in this document.
Convert the filter coefficients
to fixed point values.
In the example code, a
Q16 (16 fractional bits) representation is used. Perform this conversion
using the IQMath library or by multiplying the
coefficients by 2n where n is the desired number of
fractional bits. Verify that the selected data type can hold these
values without overflowing.
The filter coefficients
are constant values, and as a result, can be contained in flash to save
room in SRAM if desired.