<< Chapter < Page Chapter >> Page >

Now that you understand how your assembly routine is called from C, modify it to return the value of the filter output, instead of writing it to outBuffer directly in assembly. Modify main.c with the following:

  1. Replace the function declaration extern void filter(void) with extern int filter(void) .
  2. Create an output variable called outval to store the value returned from filter() .
  3. Store outval into output channels 1 and 3, and your unfiltered input sample from channel 1 into output channels 2 and 4.
Use typecasting, bitshifting, and bitwise operations to pack the output variables accordingly.

Now that the C code has been changed, you must modify the assembly code to actually return the value. To do this, there is an established convention for how to pass and return values between C and assembly. The rules for this convention are given in Section 6.4 of the TMS320C55x Optimizing C/C++ Compiler User's Guide .

Please read and understand this section in the manual before proceeding!

Currently, the filter output and raw input are copied to the output buffers:

MOV HI(AC0), *AR7+
MOV HI(AC1), *AR7+
MOV HI(AC0), *AR7+
MOV HI(AC1), *AR7+

Replace these commands with a single command to return only the filter output. Hint: you will need register T0 .

Now after compiling, loading, and running your code, your filter should behave just as in Part 1. In this second part of the lab, you have learned how to make a call to an assemblyroutine much more modular as you should know how to pass and return values between C and assembly. This will become valuable in later labs, when you may want to cascade multiple assembly subroutines together.

Part 3: alternative single-channel fir implementation

An alternative method of implementing symmetric FIR filters uses the firsadd instruction. First, make a copy of filtercode.asm , as you will have to demo this part separately from the previous two. Modify your code to implement the filter with a 4 kHz to 8 kHz passband using the firsadd .

Two differences in implementation between your code from Part 1 and the code you will write for this part are that firsadd requires the states to be broken up into two separate circular buffers. Refer tothe firsadd instruction on page 5-152 in the Mnemonic Instruction Set manual.

1 mov *AR1, *AR2- ; write x(-N/2) over x(-N) 2 mov HI(AC0), *AR1 ; write x(0) over x(-N/2)3 add *AR1-, *AR2-, AC0 ; add x(0) and x(-(N-1)) 4 ; (prepare for first multiply)5 rpt #(FIR_len1/2-1) 6 firsadd *AR1-, *AR2-, *CDP+, AC0, AC17 round AC1 8 amar ???????????????? ; Fill in these two instructions9 amar ????? ; They modify AR1 and AR2 1011 ; note that the result is now in the 12 ; AC1 accumulator

Because states and coefficients are now treated differently than in your previous FIR implementation, you will need tomodify the pointer initializations to

1 bset AR1LC ; sets circular addressing for AR1 2 bset AR2LC ; sets circular addressing for AR23 45 mov #firState1, AR1 6 mov #firState1Index, AR47 mov mmap(AR1), BSA01 8 mov *AR4, AR1 ; get pointer to oldest delayBuf in AR19 10 mov #firState2, AR211 mov #firState2Index, AR5 12 mov mmap(AR2), BSA2313 mov *AR5, AR2 1415 16 mov #(FIR_len1/2), BKC17 mov #(FIR_len1/2), BK03 ; initialize circular buffer length for register 0-3 18 mov #coef1, CDP ; CDP contains address of coefficients19 mov *AR6<<#16, AC0 ; copy input into AC0

There are also a couple other changes that need to be made before the code will compile successfully. Read the comments carefully and understand how the firsadd instruction works to make the necessary changes. Hint: Make sure accumulator usage (AC0, AC1, AC2) and what is sent to output is correct.

Using the techniques introduced in Lab 0: DSP Hardware Introduction , generate an appropriate test vector and find the expected output in MATLAB. In MATLAB, plot the expected and actual outputs of the filter, and the difference between the expected and actual outputs. Why is the output from the DSP system not exactly the same as the output from MATLAB?

Next, compare the output of this code against the output of the same filter implemented using the mac instruction. Are the results the same? Why or why not? Ensure that the filtered output is sent to output channel 1, and that the unmodified output is still sent to output channel 2.

You will lose credit if the unmodified output is not present or if the channels are reversed!

Quiz information

The points for Lab 1 are broken down as follows:

  • 1 point: Prelab (must be ready to show the TA the week before the quiz)
  • 3 points: Working code from Parts 2 and 3: you must demonstrate that your code works using input from the function generator and that it works using input from appropriate test vectors. Have an .asm file ready to demonstrate each.
  • 4 points: Quiz score.

The quiz may cover signal processing material relating to fixed point processing fundamentals, convolution, and the differences between ideal FIR filters and realizable FIR filters. You may also be asked questions about digital sampling theory, including, but not limited to, the Nyquist sampling theorem and the relationship between the analog frequency spectrum and the digital frequency spectrum of a continuous-time signal that has been sampled.

The quiz will cover the code that you have written during the lab. You are expected to understand, in detail, all of the code in the files you have worked on, even if your partner wrote it. The quiz may cover various key lines of code, 2's complement fractional arithmetic, circular buffers, alignment, typecasting and bit manipulation in C, function calling conventions between C and assembly, and the mechanics of either of the two FIR filter implementations.

Use the TI documentation, specifically the Mnemonic Instruction Set manual. Also, feel free to ask the TAs to help explain the code that you have been given.

Questions & Answers

where we get a research paper on Nano chemistry....?
Maira Reply
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
yes that's correct
I think
Nasa has use it in the 60's, copper as water purification in the moon travel.
nanocopper obvius
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
how nano science is used for hydrophobicity
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
what is differents between GO and RGO?
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
analytical skills graphene is prepared to kill any type viruses .
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Ece 420 fall 2013. OpenStax CNX. Sep 26, 2013 Download for free at http://cnx.org/content/col11560/1.3
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ece 420 fall 2013' conversation and receive update notifications?