How to implement the Digital FIR filter algorithm on TMS320C6745 DSP kit

Spread the love


In my previous blog, we learned how to implement the DSP Algorithms on DSP kits. In the same fashion am going to present this topic too.

My Previous Blog Link:



Digital FIR filter fully involve with the signal, Applying FIR filter algorithm by doing some mathematical operation on signals like an addition, convolution, shifting etc.., then it produces an output signal in the form of digital so the digital to analog conversion is required at output and an analog to digital conversion is required to provide the input to Digital signal processor, this is called the basic elements of dsp.



FIR (Finite Impulse Response) filter is a digital filter without a feedback, it is also known as non-recursive digital filters, even though recursive algorithms can be used for FIR filter realization. The output y (n) of a filter system is determined by convolving its input signal x (n)   with its impulse response h (n).

For a discrete-time FIR filter, the output is a weighted sum of the current and a finite number of previous values of the input. The operation is described by the following equation and shown in the figure1, which defines the output sequence y (n) in terms of its input sequence x (k) and h (k):

The equation of the FIR filter is as follows:




x (n) is input signal

y (n) is output signals are related via the convolution operation.

h (k) is filter coefficients (ci) c0, c1, c2, etc..,

N is a filter order.

Coefficients h (n): always coefficients are fixed constants for a fixed cut off frequency; we may change the coefficients at any time. Mostly use MATLAB fda tool to generate the coefficients.


Input data x (n): always read the new sample from ADC for every clock cycle and update the filter system for all iteration.                       After the convolution process, read the new sample for x (n), one time shifts the all the old sample and omit the fifth sample for every clock cycle.


Example:   Consider the above FIR filter system with N=5

Let N = 5 order of coefficients Then,

Let Coefficients h (n) is:



5th order 1 kHz cut off frequency coefficients Ci are {0.0202, 0.5069, 0.9806, 0.8125, and 0.9981}

Input data x (n):


x (n) is new adc sample values.


The equation in this case is as follows:


detailed description of the fir filter algorithm is given below:

Here x (0) = 0; and x (n) = adc samples;   n = 0, 1, 2…










Implementation of FIR filter algorithm on DSP kit


Note: This explanation is done with the help of TMS320C6745 DSP kit (


Implement the fir filter algorithm on kit


  • Receive the inputs via SPI ADC on TMS320C6745 DSP kit.
  • Then, process the fir filter algorithm on Processor it is called Digital signal processing.
  • Transmit the y (n) value to the SPI DAC on TMS320C6745 dsp kit.


Consider the fir filter implementation in C language for Digital signal processor.


Store the coefficients in program using an array, N=10

coeff[0] = 0x090E;

coeff[1] =  0x0F45C;

coeff[2] =  0x04C00;

coeff[3] =  0x0E4D7;

coeff[4] =  0x0517C;

coeff[5] =  0x0517C;

coeff[6] =  0x0E4D7;

coeff[7] =  0x0104C;

coeff[8] =  0x0F45C;

coeff[9] =  0x090E;

Initialize the TMS320C6745 kit, spi adc and spi dac.

C6745_init ();

spiadc_init ();

spidac_init ();

For initial operation load a zero at input array locations.





Start the operation with conditional loop statements (for, if, while). Send command to SPI SLAVE ADC device and Read the adc value for x (n).



spiadcbuf[0] = 0x01;          // ADC commands  to receive sample

spiadcbuf[1] = 0xBF;

spiadcbuf[2] = 0x00;

spiadc_cycle(spiadcbuf, 3);  // Execute spiadc read cycle

adc_value = ((spiadcbuf[1]&0x0f) << 8)| spiadcbuf[2];

This adc_value variable will contain the new sample x (n) for every clock cycle.

Start the Fir filter operation, by convoluting the input sample and coefficients it provides the output y (n). The output is a weighted sum of the current and a finite number of previous values of the input.


xval[0] = adc_value;

sum = 0x0;



temp = (xval[k])*(coeff[k]);

sum = sum + temp;


sum = sum >> 16;


Check the analog output signal with the help of SPI DAC so transmit the “sum” variable.



Shift the values to the next level and omit the last sample, so that first place of array is waiting for new adc sample values.  for each iteration it updates the filter system input.



xval[i+1] = xval[i];


Again repeat the above steps from while (1) function to see the fir filter frequency response.


For an input:

Connect the function generator to the SPI ADC external connector on TMS320C6745 DSP kit.

For an output:

Connect the CRO/DSO to the SPI DAC connector on TMS320C6745 DSP kit.


Vary the input frequency to check the fir filter frequency response.


The four basic filter types:

  1. Low pass filter
  2. High pass filter
  3. Band pass filter
  4. Band stop filter


All the above filters we can achieve in this same method on any DSP kit only initializing, ADC and DAC have to care for different kits. We can generate the coefficients using MATLAB fda tool. In this fda tool, we have to mention which type of filter we going implement and cut off frequency because the coefficients only will decide the filter types as well as cut off frequency.