<< 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

do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
Maciej
characteristics of micro business
Abigail
Do somebody tell me a best nano engineering book for beginners?
s. Reply
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
so some one know about replacing silicon atom with phosphorous in semiconductors device?
s. Reply
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
SUYASH Reply
for screen printed electrodes ?
SUYASH
What is lattice structure?
s. Reply
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
Sanket Reply
what's the easiest and fastest way to the synthesize AgNP?
Damian Reply
China
Cied
types of nano material
abeetha Reply
I start with an easy one. carbon nanotubes woven into a long filament like a string
Porter
many many of nanotubes
Porter
what is the k.e before it land
Yasmin
what is the function of carbon nanotubes?
Cesar
I'm interested in nanotube
Uday
what is nanomaterials​ and their applications of sensors.
Ramkumar Reply
what is nano technology
Sravani Reply
what is system testing?
AMJAD
preparation of nanomaterial
Victor Reply
Yes, Nanotechnology has a very fast field of applications and their is always something new to do with it...
Himanshu Reply
good afternoon madam
AMJAD
what is system testing
AMJAD
what is the application of nanotechnology?
Stotaw
In this morden time nanotechnology used in many field . 1-Electronics-manufacturad IC ,RAM,MRAM,solar panel etc 2-Helth and Medical-Nanomedicine,Drug Dilivery for cancer treatment etc 3- Atomobile -MEMS, Coating on car etc. and may other field for details you can check at Google
Azam
anybody can imagine what will be happen after 100 years from now in nano tech world
Prasenjit
after 100 year this will be not nanotechnology maybe this technology name will be change . maybe aftet 100 year . we work on electron lable practically about its properties and behaviour by the different instruments
Azam
name doesn't matter , whatever it will be change... I'm taking about effect on circumstances of the microscopic world
Prasenjit
how hard could it be to apply nanotechnology against viral infections such HIV or Ebola?
Damian
silver nanoparticles could handle the job?
Damian
not now but maybe in future only AgNP maybe any other nanomaterials
Azam
Hello
Uday
I'm interested in Nanotube
Uday
this technology will not going on for the long time , so I'm thinking about femtotechnology 10^-15
Prasenjit
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
Good
Got questions? Join the online conversation and get instant answers!
QuizOver.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?

Ask