Presentation is loading. Please wait.

Presentation is loading. Please wait.

DSP Implementation Using The TMS320C6711 Demo Eastern Mediterranean University Department of Electrical & Electronics Engineering Texas Instruments Assistant:

Similar presentations


Presentation on theme: "DSP Implementation Using The TMS320C6711 Demo Eastern Mediterranean University Department of Electrical & Electronics Engineering Texas Instruments Assistant:"— Presentation transcript:

1 DSP Implementation Using The TMS320C6711 Demo Eastern Mediterranean University Department of Electrical & Electronics Engineering Texas Instruments Assistant: Burçin ÖZMEN Lecturer: Erhan A. İNCE

2 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 2 Learning Objectives  Why process signals digitally?  Definition of a real-time application.  Why use Digital Signal Processing processors?  What are the typical DSP algorithms?  Parameters to consider when choosing a DSP processor.

3 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 3 Why go digital?  Digital signal processing techniques are now so powerful that sometimes it is extremely difficult, if not impossible, for analogue signal processing to achieve similar performance.  Examples:  FIR filter with linear phase.  Adaptive filters.

4 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 4 Why go digital?  Analogue signal processing is achieved by using analogue components such as:  Resistors.  Capacitors.  Inductors.  The inherent tolerances associated with these components, temperature, voltage changes and mechanical vibrations can dramatically affect the effectiveness of the analogue circuitry.

5 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 5 Why go digital?  With DSP it is easy to:  Change applications.  Correct applications.  Update applications.  Additionally DSP reduces:  Noise susceptibility.  Chip count.  Development time.  Cost.  Power consumption.

6 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 6 Why NOT go digital?  High frequency signals cannot be processed digitally because of two reasons:  Analog to Digital Converters, ADC cannot work fast enough.  The application can be too complex to be performed in real-time. real-time.

7 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 7  DSP processors have to perform tasks in real-time, so how do we define real- time?  The definition of real-time depends on the application.  Example: a 100-tap FIR filter is performed in real-time if the DSP can perform and complete the following operation between two samples: Real-time processing

8 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 8  Why not use a General Purpose Processor (GPP) such as a Pentium instead of a DSP processor?  What is the power consumption of a Pentium and a DSP processor?  What is the cost of a Pentium and a DSP processor? Why do we need DSP processors?

9 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 9  Use a DSP processor when the following are required:  Cost saving.  Smaller size.  Low power consumption.  Processing of many “high” frequency signals in real-time.  Use a GPP processor when the following are required:  Large memory.  Advanced operating systems. Why do we need DSP processors?

10 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 10 What are the typical DSP algorithms?  The Sum of Products (SOP) is the key element in most DSP algorithms:

11 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 11 Floating vs. Fixed point processors  Applications which require:  High precision.  Wide dynamic range.  High signal-to-noise ratio.  Ease of use. Need a floating point processor.  Drawback of floating point processors:  Higher power consumption.  Can be higher cost.  Can be slower than fixed-point counterparts and larger in size.

12 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 12 Floating vs. Fixed point processors  It is the application that dictates which device and platform to use in order to achieve optimum performance at a low cost.  For educational purposes, use the floating-point device (C6711) as it can support both fixed and floating point operations.

13 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 13 Learning Objectives  Introduction to Code Composer Studio (CCS).  Introduction to the DSK.  Laboratory.

14 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 14 Code Composer Studio  The Code Composer Studio (CCS) application provides an integrated environment with the following capabilities:  Integrated development environment with an editor, debugger, project manager, profiler, etc.  ‘C/C++’ compiler, assembly optimiser and linker (code generation tools).  Simulator.  Real-time operating system (DSP/BIOS™).  Real-Time Data Exchange (RTDX™) between the Host and Target.  Real-time analysis and data visualisation.

15 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 15  Start CCS by either:  Using the desktop icon:  Start -> Programs -> Texas Instruments -> Code Composer Studio 2 -> Code Composer Studio.  Run cc_app.exe in c:\ti\cc\bin\ Using CCS

16 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 16Troubleshooting  If the following window appears on your screen then:  Check that the DSK is connected properly and powered up.  Check if the port address and mode is correct (See Slide 7).

17 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 17 Introduction to the ‘C6711 DSK  The ‘C6711 DSK provides a powerful, low-cost development environment.  The DSK comes with CCS code development tools (does not include the simulator).  A laboratory at the end of this section takes you through the DSK setup and shows you how to run the confidence test to check it is working correctly.

18 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 18 DSK Contents Hardware (Schematics)Schematics   150 MHz ‘C6711 DSP   TI 16-bit A/D Converter (‘AD535)   External Memory   16M Bytes SDRAM   128K Bytes Flash ROM   LED’s   Daughter card expansion   Power Supply & Parallel Port Cable Software   Code Generation Tools (C Compiler, Assembler & Linker)   Code Composer Debugger (256K program limitation)   Example Programs & S/W Utilities   Power-on Self Test   Flash Utility Program   Board Confidence Test   Host access via DLL   Sample Program(s)

19 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 19 1.8V Power Supply16M SDRAM128K FLASH Daughter Card I/F (EMIF Connector) Parallel Port I/F Power Jack Power LED 3.3V Power Supply JTAG Header Emulation JTAG Header Reset Line Level Output (speakers) Line Level Input (microphone) 16-bit codec (A/D & D/A) Three User LEDs User DIP switches ‘C6711 DSP D. Card I/F (Periph Con.) TMS320C6711 Hardware: (1) Overview  The daughter card interface socket provides a method for accessing most of the C6711 DSP for hardware extension.

20 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 20 Hardware: (2) Power On Self Test (POST) TestLED 3LED 2LED 1Description 0000Start state 1001DSP internal SRAM test 2010External SDRAM test 3011DSP McBSP0 loop back test 4100External codec read/write test 5101External codec tone generation test 6110External LED and DSP timer test 7111Unused – available for future test use B L I N K A L LAll tests completed successfully  There are three LEDs to provide the user with feedback from the test procedure.  The test program (stored in the FLASH memory, code available on the DSK CD-ROM) runs every time DSK is powered on and reset.

21 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 21 TMS320C6711 Hardware: (3) Resets Apply Power   POST runs CCS Reset   Menu selection: Debug  DSP Reset   Resets ‘C6711 DSP   Causes bootload from FLASH which overwrites internal memory Absolute Reset On rare occasions you might have to:   Pull power jack   Pull parallel port Reset Pushbutton   Don’t push when CCS is running   Does not force FULL system reset   To fully reset board, pull power plug Power On Self Test (POST)   Counts 1 - 7   4:  mic input  spkr out   5: sinewave  spkr out   Don’t start CCS until end (all 3 LEDs flash at the end)   If switches are set to 0100, a fast version of POST is run

22 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 22 Software: (1) PC Host Utilities DSK Loader dsk6ldr.exe filename.out  Runs on PC host  Downloads.out file to DSK memory map  Stand alone DSK loader for when you want to bypass CCS FLASH Programming hex6x.exe f.out h.cmd flash.exe f.hex  First, convert file.out to file.hex  The flash utility downloads the hex file into the on-DSK FLASH  Both programs run on the PC host. Links\SPRA804.pdf Links\SPRA804.pdf DSK Confidence Test dsk6xtst  Run from MSDOS prompt  Command-line utility tests proper installation of the DSK board  Additionally, it tests: Internal SRAM, SDRAM, FLASH, McBSP, Timers, EDMA, LEDs and Audio codec

23 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 23 Software: (2) CCS DSK Utilities Confidence Test 1.Unload any gel files already loaded in CCS 2.Load conftest.gel 3.Run confidence tests from GEL menu Quick Test Quick Test  Run from CCS GEL menu  Defined in dsk6xinit.gel  Non-intrusive test by reading and writing:  LEDs  Switches  DSK board revision  Outputs switch values General Extension Language (GEL): An interpretive language that enables you to write functions to configure the IDE and access the target processor.

24 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 24 Software: (3) DSK Help  DSK6711 help is available via the Help menu in CCS.

25 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 25 Laboratory Exercise: DSK Hardware Setup (1)Connect the following cables:  Parallel port.  Audio cables. (2)Connect the power and observe the Power On Self- Test (POST) (Refer to Slide 15). (3)Run the confidence test for the PC. There are three methods to run this test: (a)Run the “dsk6xtst.exe” by double-clicking on the file in “\Code\Chapter 03 - CCS and DSK\”. (b)Run the “dsk6xtst.exe” file from windows by double clicking on the file in “\ti\c6000\dsk\conftest\Host\Debug”. (c)Open a DOS window and run the “dsk6xtst.exe” file located in the directory above.

26 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 26 Laboratory exercise: DSK hardware setup Notes:  The SDRAM may take a while due to the large amount of SDRAM on the ‘C6711 DSK.  The CODEC test performs two operations: (1) a 1kHz tone output, and (2) an audio input to output loopback. You must have a speaker connected to the the output jack to hear the test.  If the confidence test fails: (1)Remove the power and parallel cable from the DSK. (2)Reset your PC. (3)Reconnect the power and the parallel cable. (4)Invoke CCS.

27 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 27 Laboratory Exercise: Using CCS Implement: with: a i = {40, 39, …, 1} x i = {1, 2, …, 40} (1)Create a working directory and copy the following files from \Code\Chapter 03 - CCS and DSK\: (a)lab3.cdb (b)lab3.c (c)lab3cfg.cmd (2)Create a new project: (a)Start CCS. (b)Create a new project as shown on the following slide.

28 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 28 Laboratory Exercise: Using CCS

29 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 29 Laboratory Exercise: Using CCS (3)Add files to the project (lab3.c, lab3.cdb, lab3cfg.cmd).

30 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 30 Laboratory Exercise: Using CCS (4)Change the build options (compile and link):

31 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 31 Laboratory Exercise: Using CCS (5)Build the output program (lab3.out): (a)Build the project by: (i)Clicking the Rebuild All toolbar icon. (ii)Selecting Rebuild All in the project menu. (b)Verify that the build output window is complete with “0 errors, 0 warnings”:

32 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 32 Laboratory Exercise: Using CCS (6)Load the output file lab3.out into DSP memory: (a)The program will be automatically loaded after each project build if the “Program Load after Build” option is selected as shown below:

33 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 33 Laboratory Exercise: Using CCS (6)Load the output file lab3.out into DSP memory: (b)Load the lab3.out by selecting File:Load Program as shown below:

34 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 34 Laboratory Exercise: Using CCS (7)Debug and run code: (a)Go to the beginning of the program, that is main() by selecting Debug:Go Main. (b)Watch variables: (i) Select the variable (to be watched) from the lab3.c file, right click and select “Add To Watch Window”. If the variable is y for instance, the following window will be shown. (ii)To add another variable to the watch select it and then drag and drop it on to the window.

35 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 35 Laboratory Exercise: Using CCS (7)Debug and run code: (c) CCS will automatically add the local variables:

36 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 36 Laboratory Exercise: Using CCS (7)Debug and run code: (d) You can run or step through the code by using the various icons on the toolbar or use the Debug menu:

37 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 37 (8)Benchmarking and profiling code: (a)Stop the processor, reload the code or select Debug:Restart then select Debug:Go Main. (b)Open a new profiling session and name it “Session 1” and select “Profile All Functions” by clicking the following toolbar button: Laboratory Exercise: Using CCS (e)Stop the processor from running and watch the variable y: y = 0x2cdb or 11480

38 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 38 Laboratory Exercise: Using CCS (8)Benchmarking and profiling code: (c)Expand the lab3.c as shown below:

39 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 39 Laboratory Exercise: Using CCS (8)Benchmarking and profiling code: (d)Add a breakpoint at “for(;;);”. This can be done by: (i)Click the cursor on the highlighted line below. (ii)Click the “Add Breakpoint” toolbar button:

40 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 40 Laboratory Exercise: Using CCS (8)Benchmarking and profiling code: (e)Run the program and examine the profile window:

41 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 41 Part 2 Developing A Simple Program

42 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 42 Learning Objectives  Learn how to create a simple program  Learn basic debug techniques  Understand how CCS facilitates development

43 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 43 Creating a New Project  Double-click the Code Composer Studio icon on your desktop.

44 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 44 Creating a New Project  From the Project menu, choose New.  In the Project Name field, type volume1.  In the Location field, browse to the working folder you created in step 1.  In the Project Type field, select Executable (.out).  In the Target field, select the target you have CCS configured for and click Finish.

45 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 45 Adding Files to a Project Adding Files to a Project  Choose Project→Add Files to Project. Select volume.c and click Open.  Choose Project→Add Files to Project.  Select Asm Source Files (*.a*, *.s*) in the Files of type box.  Select vectors.asm and load.asm, and click Open.  Choose Project→Add Files to Project.  Select Linker Command File (*.cmd) in the Files of type box.  Select volume.cmd and click Open.

46 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 46 Adding Files to a Project  Choose Project→Add Files to Project. Go to the compiler library folder (C:\ti\c6000\cgtools\lib). C:\ti  Select Object and Library Files (*.o*, *.lib) in the Files of type box.  Select the rts.lib file for the target you are configured for and click Open. rts.libtargetrts.libtarget  In the Project View window, right-click on volume1.pjt and select Scan All Dependencies.  volume.h should appear under the Include folder in the Project View window.

47 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 47 Adding Files to a Project  Expand the Project list by clicking the + signs next to Project, volume1.pjt, Libraries, and Source.  This list is called the Project View.

48 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 48 Reviewing the Source Code  The processing function multiplies each value in the input buffer by the gain and puts the resulting values into the output buffer.  It also calls the assembly load routine, which consumes instruction cycles based on the processingLoad value passed to the routine.  The dataIO function in this example does not perform any actions other than to return.  Rather than using C code to perform I/O, we will use a Probe Point within Code Composer Studio to read data from a file on the host into the inp_buffer location.

49 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 49 Building and Running the Program  Choose Project→Rebuild All or click the (Rebuild All) toolbar button.  By default, the.out file is built into a debug directory located under your current project folder.  Choose File→Load Program. Select the program you just rebuilt, Volume1.out, and click Open.  Choose View®Mixed Source/ASM.  This allows you to view your c source and the resulting assembly code at the same time.

50 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 50 Building and Running the Program  Choose Debug→Go Main to begin execution from the main function. The execution halts at main and is identified by.  Choose Debug→Run or click the (Run) toolbar button.  Choose Debug→ Halt to quit running the program.  From the View menu,  choose Mixed Source/ASM. This allows you to view c code without the assembly so you can accomplish the next task: Changing Program Options and Fixing Syntax errors

51 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 51 Changing Program Options and Fixing Syntax Errors Changing Program Options and Fixing Syntax Errors  Choose Project→Build Options.  In the Compiler tab of the Build Options window,  select Preprocessor from the Category list. Type FILEIO in the Define Symbols field. Press the Tab key.

52 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 52 Changing Program Options and Fixing Syntax Errors Changing Program Options and Fixing Syntax Errors  Click OK to save your new option settings.  Choose Project→Rebuild All or click the (Rebuild All) toolbar button. You need to rebuild all the files whenever the project options change.  A build message indicates the program contains compile errors. Click the Build tab and scroll up in the Build tab area. You see a syntax error message.

53 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 53 Changing Program Options and Fixing Syntax Errors Changing Program Options and Fixing Syntax Errors  Double-click on the red text that describes the location of the syntax error (line 68). Notice that the volume.c source file opens, and your cursor is on the following line:  processing(input, output);  Fix the syntax error in the line above the cursor location (The semicolon is missing.) It should look like this:  puts("begin processing");  Notice that an asterisk (*) appears next to the filename in the Edit window's title bar, indicating that the source file has been modified. The asterisk disappears when the file is saved.  Choose File→Save or press Ctrl+S to save your changes to volume.c.

54 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 54 Changing Program Options and Fixing Syntax Errors Changing Program Options and Fixing Syntax Errors  Choose Project→Build or click the (Incre-mental Build) toolbar button. Code Composer Studio rebuilds files that have been updated.  Choose File→Load Program and select volume1.out.  Choose Debug→Go Main to begin execution from the main function. The execution halts at main and is identified by.  Choose Debug→Run or click the (Run) toolbar button.  Choose Debug→ Halt to quit running the program.

55 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 55 Adding a Probe Point for File I/O  To transfer input data from a file on the host PC to a buffer on the target for use by the algorithm  To transfer output data from a buffer on the target to a file on the host PC for analysis  To update a window, such as a graph, with data

56 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 56 Adding a Probe Point for File I/O  Choose File→Load Program. Select volume1.out, and click Open.  Double-click on the volume.c file in the Project View.  Put your cursor in the line of the main function that says:  dataIO();  Click the (Toggle Probe Point) toolbar button. The selection margin indicates that a probepoint has been set.  From the File menu, choose File I/O.  The File I/O dialog appears so that you can select input and output files.

57 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 57 Adding a Probe Point for File I/O  In the File Input tab, click Add File.  Browse to the volume1 project folder you created, select sine.dat and click Open.  In the File I/O dialog, change the Address to inp_buffer and the Length to 100. Also, put a check mark in the Wrap Around box.

58 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 58 Adding a Probe Point for File I/O  Click Add Probe Point. The Probe Points tab of the Break/Probe Points dialog appears.  In the Probe Point list, highlight the line that says VOLUME.C line 61 --> No Connection.  In the Connect To field, click the down arrow and select the sine.dat file from the list.  Click Replace. The Probe Point list changes to show that this Probe Point is connected to the sine.dat file.  Click OK. The File I/O dialog shows that the file is now connected to a Probe Point.  Click OK to close the File I/O dialog.

59 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 59 Displaying Graphs  Choose View→Graph→Time/Frequency.  In the Graph Property Dialog, change some of the variable properties to the values shown here.  Click OK. An Input graph window for the Input Buffer appears.  Right-click on the Input graph window and choose Clear Display from the pop-up menu.  Choose View→Graph→Time/Frequency again.  This time, change the Graph Title to Output and the Start Address to out_buffer. All the other settings are correct.  Click OK to display the Output graph window.

60 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 60 Animating the Program and Graphs  In the volume.c window, put your cursor in the line that calls dataIO.  Click the (Toggle Breakpoint) toolbar button or press F9. A red icon is placed in the selection margin to represent the breakpoint.  Arrange the windows so that you can see both graphs.  Click the (Animate) toolbar button or press F12 to run the program.  Each time the Probe Point is reached, Code Composer Studio gets 100 values from the sine.dat file and writes them to the inp_buffer address.

61 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 61 Animating the Program and Graphs Choose Debug→Halt to quit running the program.

62 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 62 Adjusting the Gain  Choose View→Watch Window and select the Watch1 tab.  Click on the expression icon in the Name column and type gain as the name of the variable to watch.  Click on the white space in the watch window to save the change. The value should immediately appear as in the following example.

63 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 63 Adjusting the Gain  If you have halted the program, click the (Animate) toolbar button to restart the program. Observe the input and output graph you created earlier.  From the Debug menu, choose Halt.  In the Watch Window, select the value of gain (1) and change it to 10.  From the Debug menu, choose Animate. Notice that the amplitude of the signal in the Output graph changes to reflect the increased gain as in the following example:

64 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 64 Adjusting the Gain  From the Debug menu, choose Halt.  From the Project menu, choose Close.  Close all other windows and graphs.

65 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 65 Part 3 Finite Impulse Response (FIR) Filters

66 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 66 Learning Objectives  Introduction to the theory behind FIR filters:  Properties (including aliasing).  Coefficient calculation.  Structure selection.  Implementation in Matlab and C.

67 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 67Introduction  Amongst all the obvious advantages that digital filters offer, the FIR filter can guarantee linear phase characteristics.  Neither analogue or IIR filters can achieve this.  There are many commercially available software packages for filter design. However, without basic theoretical knowledge of the FIR filter, it will be difficult to use them.

68 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 68 Properties of an FIR Filter  Filter coefficients: x[n] represents the filter input, b k represents the filter coefficients, y[n] represents the filter output, N is the number of filter coefficients (order of the filter).

69 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 69 Properties of an FIR Filter  Filter coefficients: FIR equation Filter structure

70 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 70 Properties of an FIR Filter  Filter coefficients:  If the signal x[n] is replaced by an impulse  [n] then:

71 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 71 Properties of an FIR Filter  Filter coefficients:  If the signal x[n] is replaced by an impulse  [n] then:

72 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 72 Properties of an FIR Filter  Filter coefficients:  If the signal x[n] is replaced by an impulse  [n] then:

73 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 73 Properties of an FIR Filter  Filter coefficients:  Finally:

74 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 74 Properties of an FIR Filter  Filter coefficients: With:  The coefficients of a filter are the same as the impulse response samples of the filter.

75 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 75 Frequency Response of an FIR Filter Frequency Response of an FIR Filter  By taking the z-transform of h[n], H(z):  Replacing z by e -j  in order to find the frequency response leads to:

76 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 76 Frequency Response of an FIR Filter Frequency Response of an FIR Filter  Since e -j2  k = 1 then:  Therefore:  FIR filters have a periodic frequency response and the period is 2 .

77 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 77 Frequency Response of an FIR Filter Frequency Response of an FIR Filter  Frequency response: FIRy[n]x[n] F s /2 Freq Freq x[n]y[n]

78 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 78 Frequency Response of an FIR Filter Frequency Response of an FIR Filter  Solution: Use an anti-aliasing filter. FIRy[n] x[n] ADC Analogue Anti-Aliasing x(t) F s /2 Freq Freq x(t)y[n]

79 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 79 Phase Linearity of an FIR Filter  A causal FIR filter whose impulse response is symmetrical is guaranteed to have a linear phase response. Even symmetry Odd symmetry

80 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 80 Phase Linearity of an FIR Filter  A causal FIR filter whose impulse response is symmetrical (ie h[n] = h[N-1-n] for n = 0, 1, …, N-1) is guaranteed to have a linear phase response.

81 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 81 Phase Linearity of an FIR Filter  Application of 90° linear phase shift: Signal separation 90 o delay delay + + + - I Q Reverse Forward IH QH

82 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 82 Design Procedure  To fully design and implement a filter five steps are required: (1)Filter specification. (2)Coefficient calculation. (3)Structure selection. (4)Simulation (optional). (5)Implementation.

83 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 83 Filter Specification - Step 1

84 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 84 Coefficient Calculation - Step 2  There are several different methods available, the most popular are:  Window method.  Frequency sampling.  Parks-McClellan.  We will just consider the window method.

85 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 85 Window Method  First stage of this method is to calculate the coefficients of the ideal filter.  This is calculated as follows:

86 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 86 Window Method  Second stage of this method is to select a window function based on the passband or attenuation specifications, then determine the filter length based on the required width of the transition band. Using the Hamming Window:

87 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 87 Window Method  The third stage is to calculate the set of truncated or windowed impulse response coefficients, h[n]: for Where: for

88 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 88 Window Method  Matlab code for calculating coefficients: close all; clear all; fc = 8000/44100;% cut-off frequency N = 133;% number of taps n = -((N-1)/2):((N-1)/2); n = n+(n==0)*eps; % avoiding division by zero [h] = sin(n*2*pi*fc)./(n*pi);% generate sequence of ideal coefficients [w] = 0.54 + 0.46*cos(2*pi*n/N);% generate window function d = h.*w;% window the ideal coefficients [g,f] = freqz(d,1,512,44100);% transform into frequency domain for plotting figure(1) plot(f,20*log10(abs(g)));% plot transfer function axis([0 2*10^4 -70 10]); figure(2); stem(d);% plot coefficient values xlabel('Coefficient number'); ylabel ('Value'); title('Truncated Impulse Response'); figure(3) freqz(d,1,512,44100);% use freqz to plot magnitude and phase response axis([0 2*10^4 -70 10]);

89 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 89 Window Method

90 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 90 Realisation Structure Selection - Step 3 Realisation Structure Selection - Step 3  Direct form structure for an FIR filter:

91 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 91 Realisation Structure Selection - Step 3 Realisation Structure Selection - Step 3  Linear phase structures:  N even:  N Odd:  Direct form structure for an FIR filter:

92 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 92 Realisation Structure Selection - Step 3 Realisation Structure Selection - Step 3 (a) N even. (b) N odd.

93 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 93 Realisation Structure Selection - Step 3 Realisation Structure Selection - Step 3  Cascade structures:  Direct form structure for an FIR filter:

94 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 94 Realisation Structure Selection - Step 3 Realisation Structure Selection - Step 3  Cascade structures:  Direct form structure for an FIR filter:

95 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 95 Implementation - Step 5  Implementation procedure in ‘C’ with fixed-point:  Set up the codec (\Links\CodecSetup.pdf). \Links\CodecSetup.pdf  Transform: to ‘C’ code. (\Links\FIRFixed.pdf) \Links\FIRFixed.pdf  Configure timer 1 to generate an interrupt at 8000Hz (\Links\TimerSetup.pdf). \Links\TimerSetup.pdf  Set the interrupt generator to generate an interrupt to invoke the Interrupt Service Routine (ISR) (\Links\InterruptSetup.pdf). \Links\InterruptSetup.pdf

96 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 96 Implementation - Step 5  Implementation procedure in ‘C’ with floating-point: Same set up as fixed-point plus:  Convert the input signal to floating-point format.  Convert the coefficients to floating-point format.  With floating-point multiplications there is no need for the shift required when using Q15 format.  See \Links\FIRFloat.pdf \Links\FIRFloat.pdf

97 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 97 Implementation - Step 5  Implementation procedure in assembly: Same set up as fixed-point, however:  is written in assembly. (\Links\FIRFixedAsm.pdf) \Links\FIRFixedAsm.pdf  The ISR is now declared as external.

98 Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002 Slide 98 Thanks for Listening


Download ppt "DSP Implementation Using The TMS320C6711 Demo Eastern Mediterranean University Department of Electrical & Electronics Engineering Texas Instruments Assistant:"

Similar presentations


Ads by Google