<< Chapter < Page | Chapter >> Page > |
In this lab, you implement a fourth-order IIR filter completely in fixed-point C. While programming in C provides ease of coding, portability, and comprehension, fixed-point processing raises a few challenges that were handled automatically in assembly. In particular, it is the programmer's responsibility to explicitly handle overflow errors and accumulator sizing.
On the DSP, you will write and test the C function for the elliptic low-pass filter designed from Prelab (Part 1) . You should not try to implement the notch filter designed in Prelab (Part 2) , because it will not work correctly when implemented using Direct Form II. (Why not?)
To implement the fourth-order filter, start with a single set of second-order coefficients and implement a single second-order section. A suggested outline of the implementation steps are:
The first step, and the majority of the work, is to implement a single second-order section, which was shown in Figure 1 . Before writing in C, carefully design and plan out the algorithm on paper in pseudo-code. For an example of how pseudo-code is used to implement an FIR filter, see this link FIR filter implementation.
From your design, you should have a very clear idea about:
Which buffer should be circularly addressed: coefficients or state buffer?
The intermediate state buffer. If you do not clearly understand why, go back to Figure 1 and spend more time on this part of the lab!
You may want to implement the second-order section with the following function declaration:
long iirSoS(int *b, int *a, int *w_states, long input);
The above declaration is only a recommendation, and the exact number of arguments or even the datatypes used can be designed differently. The point though, is that this specification enables function re-use, unlike Lab 2 where different assembly functions were written for each filter.
In the suggested function declaration above, the first two arguments are pointers to the filter coefficients, the third argument is a pointer to the intermediate state buffer, and the final argument is the current input sample. The returned value is the output of the given second-order section.
Notification Switch
Would you like to follow the 'Ece 420 fall 2013' conversation and receive update notifications?