Texas Instruments DSP Implementation Using The TMS 320

  • Slides: 97
Download presentation
Texas Instruments DSP Implementation Using The TMS 320 C 6711 Demo Eastern Mediterranean University

Texas Instruments DSP Implementation Using The TMS 320 C 6711 Demo Eastern Mediterranean University Department of Electrical & Electronics Engineering Assistant: Burçin ÖZMEN Lecturer: Erhan A. İNCE Dr. Erhan Ince and Burcin Ozmen, Eastern Mediterranean University, (c) Texas Instruments 2002

Learning Objectives Slide 2 Why process signals digitally? Definition of a real-time application. Why

Learning Objectives Slide 2 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.

Why go digital? Digital signal processing techniques are now so powerful that sometimes it

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: Slide 3 FIR filter with linear phase. Adaptive filters.

Why go digital? Analogue signal processing is achieved by using analogue components such as:

Why go digital? Analogue signal processing is achieved by using analogue components such as: Slide 4 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.

Why go digital? With DSP it is easy to: Additionally DSP reduces: Slide 5

Why go digital? With DSP it is easy to: Additionally DSP reduces: Slide 5 Change applications. Correct applications. Update applications. Noise susceptibility. Chip count. Development time. Cost. Power consumption.

Why NOT go digital? High frequency signals cannot be processed digitally because of two

Why NOT go digital? High frequency signals cannot be processed digitally because of two reasons: Slide 6 Analog to Digital Converters, ADC cannot work fast enough. The application can be too complex to be performed in real-time.

Why do we need DSP processors? Why not use a General Purpose Processor (GPP)

Why do we need DSP processors? Why not use a General Purpose Processor (GPP) such as a Pentium instead of a DSP processor? Slide 8 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? Use a DSP processor when the following are

Why do we need DSP processors? Use a DSP processor when the following are required: Use a GPP processor when the following are required: Slide 9 Cost saving. Smaller size. Low power consumption. Processing of many “high” frequency signals in real-time. Large memory. Advanced operating systems.

What are the typical DSP algorithms? Slide 10 The Sum of Products (SOP) is

What are the typical DSP algorithms? Slide 10 The Sum of Products (SOP) is the key element in most DSP algorithms:

Floating vs. Fixed point processors Applications which require: Need a floating point processor. Drawback

Floating vs. Fixed point processors Applications which require: Need a floating point processor. Drawback of floating point processors: Slide 11 High precision. Wide dynamic range. High signal-to-noise ratio. Ease of use. Higher power consumption. Can be higher cost. Can be slower than fixed-point counterparts and larger in size.

Floating vs. Fixed point processors Slide 12 It is the application that dictates which

Floating vs. Fixed point processors Slide 12 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 (C 6711) as it can support both fixed and floating point operations.

Learning Objectives Slide 13 Introduction to Code Composer Studio (CCS). Introduction to the DSK.

Learning Objectives Slide 13 Introduction to Code Composer Studio (CCS). Introduction to the DSK. Laboratory.

Code Composer Studio The Code Composer Studio (CCS) application provides an integrated environment with

Code Composer Studio The Code Composer Studio (CCS) application provides an integrated environment with the following capabilities: Slide 14 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.

Using CCS Start CCS by either: Using the desktop icon: Start -> Programs ->

Using CCS 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: ticcbin Slide 15

Troubleshooting If the following window appears on your screen then: Slide 16 Check that

Troubleshooting If the following window appears on your screen then: Slide 16 Check that the DSK is connected properly and powered up. Check if the port address and mode is correct (See Slide 7).

Introduction to the ‘C 6711 DSK Slide 17 The ‘C 6711 DSK provides a

Introduction to the ‘C 6711 DSK Slide 17 The ‘C 6711 DSK provides a powerful, lowcost 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.

DSK Contents Hardware (Schematics) 150 MHz ‘C 6711 DSP TI 16 -bit A/D Converter

DSK Contents Hardware (Schematics) 150 MHz ‘C 6711 DSP TI 16 -bit A/D Converter (‘AD 535) External Memory 16 M Bytes SDRAM 128 K Bytes Flash ROM LED’s Daughter card expansion Power Supply & Parallel Port Cable Software Code Generation Tools (C Compiler, Assembler & Linker) Code Composer Debugger (256 K program limitation) Example Programs & S/W Utilities Slide 18 Power-on Self Test Flash Utility Program Board Confidence Test Host access via DLL Sample Program(s)

Hardware: (1) Overview The daughter card interface socket provides a method for accessing most

Hardware: (1) Overview The daughter card interface socket provides a method for accessing most of the C 6711 DSP for hardware extension. 1. 8 V Power Supply 16 M SDRAM 128 K FLASH Daughter Card I/F (EMIF Connector) Parallel Port I/F TMS 320 C 6711 Power Jack D. Card I/F (Periph Con. ) Power LED User DIP switches 3. 3 V Power Supply JTAG Header Slide 19 ‘C 6711 DSP Reset Emulation JTAG Header Three User LEDs 16 -bit codec (A/D & D/A) Line Level Input (microphone) Line Level Output (speakers)

Hardware: (2) Power On Self Test (POST) There are three LEDs to provide the

Hardware: (2) Power On Self Test (POST) 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. Test 0 1 2 3 4 5 6 7 use Slide 20 LED 3 0 0 1 1 LED 2 0 0 1 1 LED 1 0 1 0 1 BLINK ALL Description Start state DSP internal SRAM test External SDRAM test DSP Mc. BSP 0 loop back test External codec read/write test External codec tone generation test External LED and DSP timer test Unused – available for future test All tests completed successfully

Hardware: (3) Resets CCS Reset Menu selection: Debug DSP Resets ‘C 6711 DSP Causes

Hardware: (3) Resets CCS Reset Menu selection: Debug DSP Resets ‘C 6711 DSP Causes bootload from FLASH which overwrites internal memory TMS 320 C 6711 Absolute Reset On rare occasions you might have to: Pull power jack Pull parallel port Apply Power POST runs Slide 21 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

Software: (1) PC Host Utilities DSK Loader dsk 6 ldr. exe filename. out Runs

Software: (1) PC Host Utilities DSK Loader dsk 6 ldr. 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 Slide 22 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. LinksSPRA 804. pdf DSK Confidence Test hex 6 x. exe dsk 6 xtst Run from MSDOS prompt Command-line utility tests proper installation of the DSK board Additionally, it tests: Internal SRAM, SDRAM, FLASH, Mc. BSP, Timers, EDMA, LEDs and Audio codec

Software: (2) CCS DSK Utilities Confidence Test Quick Test 1. Unload any gel files

Software: (2) CCS DSK Utilities Confidence Test Quick Test 1. Unload any gel files already loaded in CCS 2. Load conftest. gel 3. Run confidence tests from GEL menu General Extension Language (GEL): An interpretive language that enables you to write functions to configure the IDE and access the target processor. Slide 23 Run from CCS GEL menu Defined in dsk 6 xinit. gel Non-intrusive test by reading and writing: LEDs Switches DSK board revision Outputs switch values

Software: (3) DSK Help Slide 24 DSK 6711 help is available via the Help

Software: (3) DSK Help Slide 24 DSK 6711 help is available via the Help menu in CCS.

Laboratory Exercise: DSK Hardware Setup (1) Connect the following cables: Parallel port. Audio cables.

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 “dsk 6 xtst. exe” by double-clicking on the file in “CodeChapter 03 - CCS and DSK”. (b) Run the “dsk 6 xtst. exe” file from windows by double clicking on the file in “tic 6000dskconftestHostDebug”. (c) Open a DOS window and run the “dsk 6 xtst. exe” file located in the directory above. Slide 25

Laboratory exercise: DSK hardware setup Notes: The SDRAM may take a while due to

Laboratory exercise: DSK hardware setup Notes: The SDRAM may take a while due to the large amount of SDRAM on the ‘C 6711 DSK. The CODEC test performs two operations: (1) a 1 k. Hz tone output, and (2) an audio input to output loopback. You must have a speaker connected to 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. Slide 26

Laboratory Exercise: Using CCS Implement: with: ai = {40, 39, …, 1} xi =

Laboratory Exercise: Using CCS Implement: with: ai = {40, 39, …, 1} xi = {1, 2, …, 40} Slide 27 (1) Create a working directory and copy the following files from CodeChapter 03 - CCS and DSK: (a) lab 3. cdb (b) lab 3. c (c) lab 3 cfg. cmd (2) Create a new project: (a) Start CCS. (b) Create a new project as shown on the following slide.

Laboratory Exercise: Using CCS Slide 28

Laboratory Exercise: Using CCS Slide 28

Laboratory Exercise: Using CCS (3) Add files to the project (lab 3. c, lab

Laboratory Exercise: Using CCS (3) Add files to the project (lab 3. c, lab 3. cdb, lab 3 cfg. cmd). Slide 29

Laboratory Exercise: Using CCS (4) Change the build options (compile and link): Slide 30

Laboratory Exercise: Using CCS (4) Change the build options (compile and link): Slide 30

Laboratory Exercise: Using CCS (5) Build the output program (lab 3. out): (a) Build

Laboratory Exercise: Using CCS (5) Build the output program (lab 3. 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”: Slide 31

Laboratory Exercise: Using CCS (6) Load the output file lab 3. out into DSP

Laboratory Exercise: Using CCS (6) Load the output file lab 3. 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: Slide 32

Laboratory Exercise: Using CCS (6) Load the output file lab 3. out into DSP

Laboratory Exercise: Using CCS (6) Load the output file lab 3. out into DSP memory: (b) Load the lab 3. out by selecting File: Load Program as shown below: Slide 33

Laboratory Exercise: Using CCS (7) Debug and run code: (a) Go to the beginning

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 lab 3. c file, right click and select “Add To Watch Window”. If the variable is y for instance, the following window will be shown. Slide 34 (ii) To add another variable to the watch select it and then drag and drop it on to the window.

Laboratory Exercise: Using CCS (7) Debug and run code: (c) CCS will automatically add

Laboratory Exercise: Using CCS (7) Debug and run code: (c) CCS will automatically add the local variables: Slide 35

Laboratory Exercise: Using CCS (7) Debug and run code: (d) You can run or

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: Slide 36

Laboratory Exercise: Using CCS (e) Stop the processor from running and watch the variable

Laboratory Exercise: Using CCS (e) Stop the processor from running and watch the variable y: y = 0 x 2 cdb or 11480 (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: Slide 37

Laboratory Exercise: Using CCS (8) Benchmarking and profiling code: (c) Expand the lab 3.

Laboratory Exercise: Using CCS (8) Benchmarking and profiling code: (c) Expand the lab 3. c as shown below: Slide 38

Laboratory Exercise: Using CCS (8) Benchmarking and profiling code: (d) Add a breakpoint at

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: Slide 39

Laboratory Exercise: Using CCS (8) Benchmarking and profiling code: (e) Run the program and

Laboratory Exercise: Using CCS (8) Benchmarking and profiling code: (e) Run the program and examine the profile window: Slide 40

Part 2 Developing A Simple Program Slide 41

Part 2 Developing A Simple Program Slide 41

Learning Objectives Slide 42 Learn how to create a simple program Learn basic debug

Learning Objectives Slide 42 Learn how to create a simple program Learn basic debug techniques Understand how CCS facilitates development

Creating a New Project Slide 43 Double-click the Code Composer Studio icon on your

Creating a New Project Slide 43 Double-click the Code Composer Studio icon on your desktop.

Creating a New Project Slide 44 From the Project menu, choose New. In the

Creating a New Project Slide 44 From the Project menu, choose New. In the Project Name field, type volume 1. 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.

 Adding Files to a Project Choose Project→Add Files to Project. Select volume. c

Adding Files to a Project Choose Project→Add Files to Project. Select volume. c and click Open. Choose Project→Add Files to Project. Slide 45 Select Asm Source Files (*. a*, *. s*) in the Files of type box. Select vectors. asm and load. asm, and click Open. Select Linker Command File (*. cmd) in the Files of type box. Select volume. cmd and click Open.

Adding Files to a Project Choose Project→Add Files to Project. Go to the compiler

Adding Files to a Project Choose Project→Add Files to Project. Go to the compiler library folder (C: tic 6000cgtoolslib). In the Project View window, right-click on volume 1. pjt and select Scan All Dependencies. Slide 46 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. volume. h should appear under the Include folder in the Project View window.

Adding Files to a Project Slide 47 Expand the Project list by clicking the

Adding Files to a Project Slide 47 Expand the Project list by clicking the + signs next to Project, volume 1. pjt, Libraries, and Source. This list is called the Project View.

Reviewing the Source Code Slide 48 The processing function multiplies each value in the

Reviewing the Source Code Slide 48 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 processing. Load value passed to the routine. The data. IO 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.

Building and Running the Program Choose Project→Rebuild All or click the (Rebuild All) toolbar

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, Volume 1. out, and click Open. Choose View®Mixed Source/ASM. Slide 49 This allows you to view your c source and the resulting assembly code at the same time.

Building and Running the Program Choose Debug→Go Main to begin execution from the main

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, Slide 50 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

 Changing Program Options and Fixing Syntax Errors Choose Project→Build Options. In the Compiler

Changing Program Options and Fixing Syntax Errors Choose Project→Build Options. In the Compiler tab of the Build Options window, Slide 51 select Preprocessor from the Category list. Type FILEIO in the Define Symbols field. Press the Tab key.

 Changing Program Options and Fixing Syntax Errors Slide 52 Click OK to save

Changing Program Options and Fixing Syntax Errors Slide 52 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.

 Changing Program Options and Fixing Syntax Errors Double-click on the red text that

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: Fix the syntax error in the line above the cursor location (The semicolon is missing. ) It should look like this: Slide 53 processing(input, output); 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.

 Changing Program Options and Fixing Syntax Errors Slide 54 Choose Project→Build or click

Changing Program Options and Fixing Syntax Errors Slide 54 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 volume 1. 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.

Adding a Probe Point for File I/O Slide 55 To transfer input data from

Adding a Probe Point for File I/O Slide 55 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

Adding a Probe Point for File I/O Choose File→Load Program. Select volume 1. out,

Adding a Probe Point for File I/O Choose File→Load Program. Select volume 1. 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: 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. Slide 56 data. IO(); The File I/O dialog appears so that you can select input and output files.

Adding a Probe Point for File I/O Slide 57 In the File Input tab,

Adding a Probe Point for File I/O Slide 57 In the File Input tab, click Add File. Browse to the volume 1 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.

Adding a Probe Point for File I/O Slide 58 Click Add Probe Point. The

Adding a Probe Point for File I/O Slide 58 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.

Displaying Graphs Slide 59 Choose View→Graph→Time/Frequency. In the Graph Property Dialog, change some of

Displaying Graphs Slide 59 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.

Animating the Program and Graphs Slide 60 In the volume. c window, put your

Animating the Program and Graphs Slide 60 In the volume. c window, put your cursor in the line that calls data. IO. Click the (Toggle Breakpoint) toolbar button or press F 9. 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 F 12 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.

Animating the Program and Graphs Choose Debug→Halt to quit running the program. Slide 61

Animating the Program and Graphs Choose Debug→Halt to quit running the program. Slide 61

Adjusting the Gain Slide 62 Choose View→Watch Window and select the Watch 1 tab.

Adjusting the Gain Slide 62 Choose View→Watch Window and select the Watch 1 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.

Adjusting the Gain Slide 63 If you have halted the program, click the (Animate)

Adjusting the Gain Slide 63 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:

Adjusting the Gain Slide 64 From the Debug menu, choose Halt. From the Project

Adjusting the Gain Slide 64 From the Debug menu, choose Halt. From the Project menu, choose Close all other windows and graphs.

Part 3 Finite Impulse Response (FIR) Filters Slide 65

Part 3 Finite Impulse Response (FIR) Filters Slide 65

Learning Objectives Introduction to theory behind FIR filters: Slide 66 Properties (including aliasing). Coefficient

Learning Objectives Introduction to theory behind FIR filters: Slide 66 Properties (including aliasing). Coefficient calculation. Structure selection. Implementation in Matlab and C.

Introduction Slide 67 Amongst all the obvious advantages that digital filters offer, the FIR

Introduction Slide 67 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.

Properties of an FIR Filter coefficients: x[n] bk y[n] N Slide 68 represents the

Properties of an FIR Filter coefficients: x[n] bk y[n] N Slide 68 represents the filter input, represents the filter coefficients, represents the filter output, is the number of filter coefficients (order of the filter).

Properties of an FIR Filter coefficients: FIR equation Filter structure Slide 69

Properties of an FIR Filter coefficients: FIR equation Filter structure Slide 69

Properties of an FIR Filter Slide 70 Filter coefficients: If the signal x[n] is

Properties of an FIR Filter Slide 70 Filter coefficients: If the signal x[n] is replaced by an impulse [n] then:

Properties of an FIR Filter Slide 71 Filter coefficients: If the signal x[n] is

Properties of an FIR Filter Slide 71 Filter coefficients: If the signal x[n] is replaced by an impulse [n] then:

Properties of an FIR Filter Slide 72 Filter coefficients: If the signal x[n] is

Properties of an FIR Filter Slide 72 Filter coefficients: If the signal x[n] is replaced by an impulse [n] then:

Properties of an FIR Filter Slide 73 Filter coefficients: Finally:

Properties of an FIR Filter Slide 73 Filter coefficients: Finally:

Properties of an FIR Filter coefficients: With: Slide 74 The coefficients of a filter

Properties of an FIR Filter coefficients: With: Slide 74 The coefficients of a filter are the same as the impulse response samples of the filter.

 Frequency Response of an FIR Filter Slide 75 By taking the z-transform of

Frequency Response of an FIR Filter Slide 75 By taking the z-transform of h[n], H(z): Replacing z by e-j in order to find the frequency response leads to:

 Frequency Response of an FIR Filter Slide 76 Since e-j 2 k =

Frequency Response of an FIR Filter Slide 76 Since e-j 2 k = 1 then: Therefore: FIR filters have a periodic frequency response and the period is 2.

 Frequency Response of an FIR Filter Frequency response: y[n] FIR x[n] Freq Fs/2

Frequency Response of an FIR Filter Frequency response: y[n] FIR x[n] Freq Fs/2 Slide 77 Freq Fs/2

 Frequency Response of an FIR Filter Solution: Use an anti-aliasing filter. x(t) ADC

Frequency Response of an FIR Filter Solution: Use an anti-aliasing filter. x(t) ADC x[n] FIR y[n] x(t) Analogue Anti -Aliasing Fs/2 Slide 78 Freq Fs/2 Freq

Phase Linearity of an FIR Filter A causal FIR filter whose impulse response is

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 Slide 79 Odd symmetry

Phase Linearity of an FIR Filter Slide 80 A causal FIR filter whose impulse

Phase Linearity of an FIR Filter Slide 80 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.

Phase Linearity of an FIR Filter Application of 90° linear phase shift: I Signal

Phase Linearity of an FIR Filter Application of 90° linear phase shift: I Signal separation Q Slide 81 o 90 IH + delay - 90 o + QH Reverse Forward

Design Procedure To fully design and implement a filter five steps are required: (1)

Design Procedure To fully design and implement a filter five steps are required: (1) (2) (3) (4) (5) Slide 82 Filter specification. Coefficient calculation. Structure selection. Simulation (optional). Implementation.

Filter Specification - Step 1 Slide 83

Filter Specification - Step 1 Slide 83

Coefficient Calculation - Step 2 There are several different methods available, the most popular

Coefficient Calculation - Step 2 There are several different methods available, the most popular are: Slide 84 Window method. Frequency sampling. Parks-Mc. Clellan. We will just consider the window method.

Window Method Slide 85 First stage of this method is to calculate the coefficients

Window Method Slide 85 First stage of this method is to calculate the coefficients of the ideal filter. This is calculated as follows:

Window Method Second stage of this method is to select a window function based

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: Slide 86

Window Method The third stage is to calculate the set of truncated or windowed

Window Method The third stage is to calculate the set of truncated or windowed impulse response coefficients, h[n]: for Where: for Slide 87

Window Method Matlab code for calculating coefficients: close all; clear all; fc = 8000/44100;

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

Window Method Slide 89

Window Method Slide 89

 Realisation Structure Selection - Step 3 Slide 90 Direct form structure for an

Realisation Structure Selection - Step 3 Slide 90 Direct form structure for an FIR filter:

 Realisation Structure Selection - Step 3 Slide 91 Direct form structure for an

Realisation Structure Selection - Step 3 Slide 91 Direct form structure for an FIR filter: Linear phase structures: N even: N Odd:

 Realisation Structure Selection - Step 3 (a) N even. (b) N odd. Slide

Realisation Structure Selection - Step 3 (a) N even. (b) N odd. Slide 92

 Realisation Structure Selection - Step 3 Slide 93 Direct form structure for an

Realisation Structure Selection - Step 3 Slide 93 Direct form structure for an FIR filter: Cascade structures:

 Realisation Structure Selection - Step 3 Slide 94 Direct form structure for an

Realisation Structure Selection - Step 3 Slide 94 Direct form structure for an FIR filter: Cascade structures:

Implementation - Step 5 Implementation procedure in ‘C’ with fixed-point: Set up the codec

Implementation - Step 5 Implementation procedure in ‘C’ with fixed-point: Set up the codec (LinksCodec. Setup. pdf). Transform: to ‘C’ code. (LinksFIRFixed. pdf) Configure timer 1 to generate an interrupt at 8000 Hz (LinksTimer. Setup. pdf). Set the interrupt generator to generate an interrupt to invoke the Interrupt Service Routine (ISR) (LinksInterrupt. Setup. pdf). Slide 95

Implementation - Step 5 Implementation procedure in ‘C’ with floating-point: Same set up as

Implementation - Step 5 Implementation procedure in ‘C’ with floating-point: Same set up as fixed-point plus: Slide 96 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 Q 15 format. See LinksFIRFloat. pdf

Implementation - Step 5 Implementation procedure in assembly: Same set up as fixed-point, however:

Implementation - Step 5 Implementation procedure in assembly: Same set up as fixed-point, however: is written in assembly. (LinksFIRFixed. Asm. pdf) Slide 97 The ISR is now declared as external.

Thanks for Listening Slide 98

Thanks for Listening Slide 98