E71 Lab 4 - The Moving Average Filter

The goal this week is to implement and characterize a simple moving average filter on a real time DSP.


Task 0: Getting Ready

  1. You can use the same project as you did in the last lab (or you can right-click on it and create a duplicate).  If you want to keep your old program file, you can:
  2. Throughout this lab, leave all the compiler optimizations as they were in the project you downloaded for the previous lab.  If you haven't changed them, don't worry.  If you have changed them, make sure they are put back to the original settings.
  3. Make sure your code is set to sample at 44.1 kHz.
  4. Change the main loop in "E71Shell.c" to
            //--- Main Loop
            while(1) // Endless loop - but interrupts still occur.
               asm(" NOP");

    unless you have a reason to do otherwise.
  5. In the file "GPIO.C" locate the lines that set the AIO4 pin to a general purpose I/O and an output and change them to:
            GpioCtrlRegs.AIOMUX1.bit.AIO4 = 0;  // 0,1=AIO4
            GpioCtrlRegs.AIODIR.bit.AIO4 = 1;   // AIO4 is an output

    We will be using this pin to time your functions.   This pin is set high at the beginning of the Interrupts Service Routine, and low at the end.
  6. Add the line
            GpioDataRegs.AIODAT.bit.AIO4 = 0; // Mark start of function
    as the first line executed in the function "E71Func()" when it is called; this function is in "E71Shell.c."  This sets the AIO4 line low (so you can tell when your function starts).
  7. Add the line
            GpioDataRegs.AIODAT.bit.AIO4 = 1; // Mark end of function
    as the last line to be executed in "E71Func()."  This set the AIO4 line high to indicate the end of your function.
  8. The cables in the lab bring out the left channel from the line-in and headphone-out connections.
  9. To find the amount of time spent in your function you can put one of the oscilloscope probes on AIO4 (shown below in the expanded selection from the image of the Peripheral Explorer Board); this is marked as A4 on the printed circuit board.   You shouldn't need a ground connection (the scope will ground through the audio in/out connections).  But if you find you need one, you can clip the scope ground at the location shown.

Task 1: Short Running Average

  1. If you put the input through an 8 point moving average filter, determine the frequencies at which the output should be zero.
  2. Write an 8 point moving average filter and put it in the function "E71Func()" between the lines you added that manipulate AIO4.  About this code:
  3. Obtain a scope printout that shows the AIO4 line during the ISR.  The printout should
  4. Collect evidence that the program works as expected (i.e., the frequency response).
  5. Save a copy of this program - you need it for the report..

Task 2: Longer Running Average

Repeat the above task for a 64 point running average. 

To Turn in:

Strive for clarity.  The grading on this lab will be somewhat different than the others.  It should be done in a more formal style with different sections for "Introduction," "Theory," "Results," "Discussion," etc...  If you do everything I ask for, you will get a B for the lab.  To get a higher grade you need to go beyond the basics.


Make sure you include (as a start):