Skip to content Skip to navigation


You are here: Home » Content » Lab: Implementing a FIR Filter on the F2812 DSP


Recently Viewed

This feature requires Javascript to be enabled.

Lab: Implementing a FIR Filter on the F2812 DSP

Module by: Deania Fernandez. E-mail the author

Summary: Lab guides students to learn how to implement a FIR filter on an audio source using a DSP.


In this lab, you will learn how to set up Spectrum Digital’s eZdsp™ F2812 to implement a finite impulse response (FIR) filter using an audio input. Since the F2812 does not have a digital-to-analog converter (DAC) as one of its peripherals, you will be using an audio processing daughtercard that features Texas Instruments’ (TI) TLV5638 DAC.

FIR Filtering Theory

Before you begin, review the basics of digital filtering.

Introduction to the eZdsp™ F2812

The eZdsp™ F2812 allows people to determine if the TI TMS320F2812 digital signal processor (DSP) is suitable for their application requirements. It also allows evaluators to develop and run software for the F2812 processor by using Code Composer Studio. A separate tutorial for the Code Composer Studio software is available in this course.

The eZdsp™ F2812 has the following features:

  • TMS320F2812 DSP
  • 150 MIPS operating speed
  • 18K words on-chip RAM
  • 128K words on-chip Flash memory
  • 64K words off-chip SRAM memory
  • 30 MHz clock
  • 2 Expansion Connectors (analog, I/O)
  • Onboard IEEE 1149.1 JTAG Controller
  • 5V only operation with supplied AC adapter
  • Onboard IEEE 1149.1 JTAG emulation connector

Figure 1
eZdsp™ F2812 Block Diagram from Spectrum Digital's Datasheet
eZdsp™ F2812 Block Diagram from Spectrum Digital's Datasheet (eZdspF2812BlockDiagram.jpg)

Setting Up Hardware

To begin this lab, there are a couple of tasks you need to do in order to set up your hardware before programming the DSP. The eZdsp™ requires a 5V power supply that is provided and should be connected to the board via connector P6. The supplied parallel cable also needs to be plugged into a lab PC.

Attach the audio processing daughtercard to the eZdsp™ board as shown in the following pictures:

Figure 2
(a) Side View of the Mounted Boards(b) Audio Daughtercard Mounted on the eZdsp
Figure 2(a) (Audio_eZdspHeaders.jpg)Figure 2(b) (AudioMountedoneZdsp.jpg)

Connect the power supply and parallel cable to the eZdsp™. The LED labeled Power on the daughtercard should light up bright orange.

Connect the provided speakers to the jumpers labeled R_SPKR and L_SPKR on the daughtercard. Make sure the black wire of each speaker is connected to the ‘-‘ and the red wire is connected to the ‘+’.

For the lab, you will be using an Apple iPod to supply the audio source. Connect the supplied cable to the jumper labeled J4 on the daughtercard. Since the iPod you are using does not have a reliable battery, make sure the iPod is connected to a power supply.

Your setup should look like this:

Figure 3: Total Hardware Setup
Figure 3 (TotalAudioSetup.jpg)

To turn the iPod on, press the Play button. To turn it off, hold the Play button until the screen goes blank, just like in the above picture.

Software Implementation

Please read how to set up the F2812 to run Code Composer Studio.

Exercise 1

Use Matlab to determine the FIR filter coeffients by using ‘remez’, ‘fir1’ and ‘fir2’ for each of the following filters:

  1. An order-30 low-pass filter having a cut-off frequency 15kHz by the windowing method using the fir1 command.
  2. An order-30 high-pass filter having transition band 15kHz-16kHz using the remez command.
  3. Compare the above by showing the frequency response using the freqz command. How are the filters different?
  4. An order-30 high-pass filter having transition band 14-15kHz by frequency sampling method using the fir2 command.
  5. An order-30 high-pass filter having a transition band 14-15kHz using the remez command.
  6. Compare the above two filters by showing the frequency response using the freqz command. How are the filters different?
  7. An order-60 band-pass filter having pass band 3kHz-6kHz using the remez command. Specify the transition bands as 2kHz-3kHz and 6kHz-7kHz.

After you have the filter coefficients, take the two’s complement by using twocomplement.m. You need them in that format in order to use them in the A/D-D/A conversion. Make sure you divide the coefficients by two before taking the two’s complement. To include them in your file, use the save_coeff.m function to create an assembly file.

Exercise 2

Download the following files to give you a good starting point: [Insert code files here] Read through the files and give a brief description of each one.

Serial Peripheral Interface (SPI)

The serial peripheral interface (SPI) is a high-speed synchronous serial input/output (I/O) port that allows a serial bit stream of programmed length (1-16 bits) to be shifted into and out of the device at a programmed bit-transfer rate. The SPI is normally used for communications between the DSP controller and external peripherals, the DAC in our case, or another controller.

Exercise 3

To implement the FIR filter, the DSP must be set up to communicate with the DAC on the daughtercard. Set up the SPI registers on the F2812 DSP by assigning the following values to the corresponding registers:

Table 1
Register Name Register Value (HEX)
SPICCR.all 0x005F
SPICTL.all 0x001F
SPISTS.all 0x0000
SPIBRR.all 0x0002
SPIFFTX.all 0xC028
SPIFFRX.all 0x0028
SPIFFCT.all 0x00
SPIPRI.all 0x0010

Which register is set to:

  1. Enable the FIFOs?
  2. Have the SPI interrupt-driven?
  3. The SPI bit transfer rate?

Analog-to-Digital Converter (ADC)

The F2812 DSP has a 12-bit ADC core with built-in dual sample-and-hold (S/H). Its options include:

  • Simultaneous sampling or sequential sampling mode
  • Operating as two independent 8-state sequencers or as a one large 16-state sequencer
  • 16-channel, multiplexed inputs
  • Multiple source triggers for the start-of-conversion (SOC) sequence

A block diagram of the ADC module from TI documents:

Figure 4: Texas Instruments' ADC Block Diagram
Figure 4 (F2812ADCBlockDiagram.jpg)

Exercise 4

Set the following ADC registers as follows:

Table 2
Register Name Register Value (HEX)
AdcRegs.ADCMAXCONV.all 0x0001
AdcRegs.ADCCHSELSEQ1.bit.CONV00 0x3
AdcRegs.ADCCHSELSEQ1.bit.CONV01 0x2
AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1 1
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 1
Which register enables or:
  1. Sequential sampling?
  2. 16-bit cascaded mode?
  3. Event manager A to be the source trigger for the SOC sequence?
  4. Selects ADCIN3 and ADCIN2 for input channels?
  5. Does one conversion on the sequence?
Which 16 registers does the ADC place its results?

Event Manager A (EVA)

The event manager peripheral in the DSP includes general-purpose (GP) timers, full-compare/PWM units, capture units, and quadrature-encoder pulse (QEP) circuits. You will use event manager A (EVA) to trigger the SOC sequence in the ADC.

EVA functional diagram from TI documents:

Figure 5: Texas Instruments' EVA Functional Overview
Figure 5 (F2812EVFunctionOverview.jpg)

Exercise 5

Set the following EVA registers as follows and describe what each one will do:

Table 3
Register Name Register Value (HEX)
EvaRegs.T1CMPR 0x00fa
EvaRegs.T1PR 0x1f4
EvaRegs.T1CON.all 0x1043


Interrupts, as described by Dr. Choi in one of his lab manuals in ELEC 434, provide a mechanism for handling any infrequent or exception event. The interrupt causes a CPU to make a temporary transfer of control from its current location to another location that services the event. Variety of sources, internal and external to the CPU, can generate interrupts. The use of interrupts greatly increases the performance of the CPU by allowing the I/O devices direct and rapid access to the CPU and by freeing the CPU from the task of continually testing the status of its I/O devices. The I/O devices assert interrupts to request the CPU to start a new I/O operation, to signal the completion of an I/O operation, and to signal the occurrence of hardware and software errors.

The F2812 DSP supports one nonmaskable interrupt (NMI) and 16 maskable prioritized interrupt requests (INT1-INT14, RTOSINT, and DLOGINT) at the CPU level.

Exercise 6

Program the interrupts for the ADC and the SPI along with the functions for:

  1. Two’s complement of the ADC output
  2. Send to appropriate filter
  3. Filter’s output to be reconverted to unsigned integers
  4. Send to DAC
You should hear the filtered audio through the speakers.

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens


A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks