<< Chapter < Page Chapter >> Page >
You will implement band-pass finite impulse-response (FIR) filters with time-domain processing.

Introduction

In this exercise, you will program in the DSP's assembly language to create FIR filters. Begin by studying theassembly code for the basic FIR filter filter.asm .

Filter.asm

1 .copy "core.asm" ; Copy in core file 2 ; This initializes DSP and jumps to "main" 3 4 FIR_len .set 8 ; This is an 8-tap filter. 5 6 .sect ".data" ; Flag following as data declarations 7 8 .align 16 ; Align to a multiple of 16 9 coef ; assign label "coeff" 10 .copy "coef.asm" ; Copy in coefficients 11 12 .align 16 13 firstate 14 .space 16*8 ; Allocate 8 words of storage for 15 ; filter state. 16 17 .sect ".text" ; Flag the following as program code 18 main 19 ; Initialize various pointers 20 stm #FIR_len,BK ; initialize circular buffer length 21 stm #coef,AR2 ; initialize coefficient pointer 22 stm #firstate,AR3 ; initialize state pointer 23 stm #1,AR0 ; initialize AR0 for pointer increment 24 25 loop 26 ; Wait for a new block of 64 samples to come in 27 WAITDATA 28 29 ; BlockLen = the number of samples that come from WAITDATA (64) 30 stm #BlockLen-1, BRC ; Put repeat count into repeat counter 31 rptb endblock-1 ; Repeat between here and 'endblock' 32 33 ld *AR6,16, A ; Receive ch1 into A accumulator 34 mar *+AR6(2) ; Rcv data is in every other channel 35 ld *AR6,16, B ; Receive ch2 into B accumulator 36 mar *+AR6(2) ; Rcv data is in every other channel 37 38 ld A,B ; Transfer A into B for safekeeping 39 40 ; The following code executes a single FIR filter. 41 42 sth A,*AR3+% ; store current input into state buffer 43 rptz A,(FIR_len-1) ; clear A and repeat 44 mac *AR2+0%,*AR3+0%,A ; multiply coef. by state & accumulate 45 46 rnd A ; Round off value in 'A' to 16 bits 47 48 ; end of FIR filter code. Output is in the high part of 'A.' 49 50 sth A, *AR7+ ; Store filter output (from A) into ch1 51 sth B, *AR7+ ; Store saved input (from B) into ch2 52 53 sth B, *AR7+ ; Store saved input to ch3...ch6 also 54 sth B, *AR7+ ; ch4 55 sth B, *AR7+ ; ch5 56 sth B, *AR7+ ; ch6 57 58 endblock: 59 b loop

filter.asm applies an FIR filter to the signal from input channel 1 and sends the resulting output to outputchannel 1. It also sends the original signal to output channel 2.

First, create a work directory on your network drive for the files in this exercise, and copy filter.asm and core.asm into it. Then use MATLAB to generate two 20-tap FIR filters. The first filter should pass signals from 4 kHz to 8kHz; the second filter should pass from 8 kHz to 12 kHz. For both filters, allow a 1 kHz transition band on each edge ofthe filter passband. To create these filters, first convert these band edges to digital frequencies based on the 44.1 kHzsample rate of the system, then use the MATLAB command remez to generate this filter; you can type help remez for more information. Use the save_coef command to save each of these filters into different files. (Make sure you reverse the vectors of filter coefficients before you save them.) Also save yourfilters as a MATLAB matrix, since you will need them later to generate test vectors. This can be done using the MATLAB save command. Once this is done, use the freqz command to plot the frequency response of each filter.

Part 1: single-channel fir filter

For now, you will implement only the filter with a 4 kHz to 8 kHz passband. Edit filter.asm to use the coefficients for this filter by making several changes.

First, the length of the FIR filter for this exercise is 20, not 8. Therefore, you need to change FIR_len to 20. FIR_len is set using the .set directive, which assigns a number to a symbolic name. You will need to change this to FIR_len .set 20 .

Second, you will need to ensure that the .copy directive brings in the correct coefficients. Change the filename to point to the file that contains the coefficientsfor your first filter.

Third, you will need to modify the .align and .space directives appropriately. The TI TMS320C54x DSP requires that circular buffers, which are usedfor the FIR filter coefficient and state buffers, be aligned so that they begin at an address that is a multiple of a powerof two greater than the length of the buffer. Since you are using a 20-tap filter (which uses 20-element state andcoefficient buffers), the next greater power of two is 32. Therefore, you will need to align both the state andcoefficient buffers to an address that is a multiple of 32. (16-element buffers would also require alignment to a multipleof 32.) This is done with the .align command. In addition, memory must be reserved for the state buffer. Thisis done using the .space directive, which takes as its input the number of bits of space to allocate. Therefore, to allocate 20 words of storage, usethe directive .space 16*20 as shown below:

1 .align 32 % Align to a multiple of 32 2 coef .copy "filter1.asm" % Copy FIR filter coefficients 3 4 .align 32 % Align to a multiple of 32 5 state .space 16*20 % Allocate 20 words of data space

Questions & Answers

what is microbiology
Agebe Reply
What is a cell
Odelana Reply
what is cell
Mohammed
how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Dsp laboratory with ti tms320c54x. OpenStax CNX. Jan 22, 2004 Download for free at http://cnx.org/content/col10078/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Dsp laboratory with ti tms320c54x' conversation and receive update notifications?

Ask