Sei sulla pagina 1di 48
Real-Time DSP for Educators Michael Morrow University of Wisconsin-Madison Thad Welch United States Naval Academy
Real-Time DSP for Educators
Michael Morrow
University of Wisconsin-Madison
Thad Welch
United States Naval Academy
Cameron Wright
University of Wyoming
Morrow University of Wisconsin-Madison Thad Welch United States Naval Academy Cameron Wright University of Wyoming
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
Motivation • Do you teach or want to teach a DSP course? • Do you

Motivation

Motivation • Do you teach or want to teach a DSP course? • Do you use

• Do you teach or want to teach a DSP course?

• Do you use MATLAB ® exercises in your courses?

• Do you assign exercises that work with actual signals (not generated in MATLAB)?

• Do you include real-time DSP demonstrations in your courses?

• Do you assign real-time projects?

in M ATLAB )? • Do you include real-time DSP demonstrations in your courses? • Do
Real-time DSP Lots of details come up that just aren’t an issue when programming in

Real-time DSP

Lots of details come up that just aren’t an issue when programming in a workstation
Lots of details come up that just aren’t an issue
when programming in a workstation environment
Documentation is written for experts
• Learning curve is steep, if not vertical!
Few understandable examples are available
• Complexity is the norm
On-line and seminar style training is available
directly from TI and the third party vendors
But, most of this training is not appropriate for the
typical student (or educator) due to at least one of
the following issues…

It can be a real struggle to get started with real-time DSP

least one of the following issues… It can be a real struggle to get started with
Typical Training Issues Our first courses should motivate our students to learn more about real-time
Typical Training Issues Our first courses should motivate our students to learn more about real-time
Typical Training Issues
Our first courses should motivate our students to
learn more about real-time DSP
Much of the industry does not do sample-by-
sample DSP, despite the fact that few teach
anything else
Expects significant familiarity with DSP system
design
Intended for engineers transitioning from other
DSP targets
Usually introducing the latest innovations and
technologies, not fundamentals

• Not meant for educators

• Meant for DSP experts

innovations and technologies, not fundamentals – – • Not meant for educators • Meant for DSP
What You Can Take Away From This Workshop microphone, headphones, audio cable, and music CD
What You Can Take Away From This Workshop microphone, headphones, audio cable, and music CD
What You Can Take Away
From This Workshop
microphone, headphones, audio cable, and music
CD

• A TI TMS320C6713 DSK (and Code Composer Studio™ software development suite) – Also includes some useful accessories - a

• An Educational DSP DSK6XXXHPI daughtercard

• Our real-time DSP book, and (most importantly)

• The ability to easily use the DSK and incorporate real- time DSP hardware into your DSP courses/labs

importantly) • The ability to easily use the DSK and incorporate real- time DSP hardware into
The DSP Big Picture y[n] = difference equation h[n] H(z) impulse transfer response function H(e
The DSP Big Picture y[n] = difference equation h[n] H(z) impulse transfer response function H(e
The DSP Big Picture
y[n] =
difference
equation
h[n]
H(z)
impulse
transfer
response
function
H(e jω )
frequency
response
pole/zero
diagram
block
diagram
h[n] H(z) impulse transfer response function H(e jω ) frequency response pole/zero diagram block diagram
y[n] = difference equation h[n] H(z) impulse transfer response function real-time implementation H(e jω )
y[n] = difference equation h[n] H(z) impulse transfer response function real-time implementation H(e jω )
y[n] =
difference
equation
h[n]
H(z)
impulse
transfer
response
function
real-time
implementation
H(e jω )
frequency
response
pole/zero
diagram
block
diagram

The Real-time DSP Big Picture

implementation H(e jω ) frequency response pole/zero diagram block diagram The Real-time DSP Big Picture
DSP of Analog Signals anti sample aliasing and filter hold analog to digital converter reconstruction
DSP of Analog Signals anti sample aliasing and filter hold analog to digital converter reconstruction
DSP of Analog Signals
anti
sample
aliasing
and
filter
hold
analog to
digital
converter
reconstruction
digital
to analog
converter
DSP
filter

analog

world

analog

world

hold analog to digital converter reconstruction digital to analog converter DSP filter analog world analog world
Our Methodology • Review of theory • Demonstration/motivation using winDSK6 • MATLAB coding • Transition
Our Methodology
Our Methodology

• Review of theory

• Demonstration/motivation using winDSK6

• MATLAB coding

• Transition to real-time C on the DSK

• Review of theory • Demonstration/motivation using winDSK6 • MATLAB coding • Transition to real-time C
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
Hardware Discussion • Let’s unpack our DSKs • Look at what comes in your box
Hardware Discussion
Hardware Discussion

• Let’s unpack our DSKs

• Look at what comes in your box

• Note that like many USB devices, the hardware installation comes AFTER the

software installation • A quick tour of the board …

many USB devices, the hardware installation comes AFTER the software installation • A quick tour of
DSK Overview Microphone & line inputs Headphone & line outputs Uses both McBSPs We configure
DSK Overview Microphone & line inputs Headphone & line outputs Uses both McBSPs We configure
DSK Overview
Microphone & line inputs
Headphone & line outputs
Uses both McBSPs
We configure for 16-bits at 48KHz

• TMS320C6713 DSP at 225MHz

• TLV320AIC23 stereo codec

• 16MB SDRAM / 512KB Flash memory

• Onboard USB-based JTAG emulator

• 4 DIP switches & 4 LEDs (user controlled)

• 16MB SDRAM / 512KB Flash memory • Onboard USB-based JTAG emulator • 4 DIP switches
DSK Overview (continued) J1 – HPI interface • New to the C6713 DSK • Used
DSK Overview (continued) J1 – HPI interface • New to the C6713 DSK • Used
DSK Overview (continued)
J1 – HPI interface
• New to the C6713 DSK
• Used by the Educational DSP HPI daughtercard
– Direct DSP control from a host computer
– DSP can use daughtercard for communications (USB/RS-
232), digital I/O, and analog inputs
J3 – Peripheral Interface
• McBSPs, Timers
J4 – EMIF (parallel memory bus)
• SDRAM, Flash Memory

• Three daughtercard connectors

• Many EVMs and daughtercards are available from TI and others

Memory – – – • Three daughtercard connectors • Many EVMs and daughtercards are available from
TI TMS320C6713 DSK
TI TMS320C6713 DSK
TI TMS320C6713 DSK
TI TMS320C6713 DSK
TI TMS320C6713 DSK
TI TMS320C6713 DSK
TI TMS320C6713 DSK
TI TMS320C6713 DSK
DSK w/ HPI Daughtercard
DSK w/ HPI Daughtercard
DSK w/ HPI Daughtercard
DSK w/ HPI Daughtercard
Software Installation Follow the CD’s instructions Do not attempt to register the software at this
Software Installation Follow the CD’s instructions Do not attempt to register the software at this
Software Installation
Follow the CD’s instructions
Do not attempt to register the software at this time
Be sure to install both CCStudio 3.1 and the C6713 DSK target
content.
Leave the CD in after the install finishes and then connect the
DSK to install the USB driver.
Note that there are two CCStudio icons on the Desktop
• The C6713 icon will automatically import the DSK into CCStudio.

• Quick Start Installation Guide

• CCStudio software installation

winDSK6

• A quick look at the contents of the textbook CD-ROM

Installation Guide • CCStudio software installation • winDSK6 • A quick look at the contents of
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
Our Software Organization • All software is interrupt-driven • All configuration code is contained in
Our Software Organization
Our Software Organization

• All software is interrupt-driven

• All configuration code is contained in a “common_code” directory

• All applications are designed to run on both the C6713 DSK and the TMS320C6711 DSK (with the onboard codec and several codec daughtercards)

• A single #define selects the proper software to configure the codec, the input source, and the sampling rate

• A single #define selects the proper software to configure the codec, the input source, and
A Basic Application (Talk-through)
A Basic Application (Talk-through)

A Basic Application (Talk-through)

A Basic Application (Talk-through)
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
The CCStudio Project Big Picture – Be aware of what directory you are in, especially

The CCStudio Project Big Picture

– Be aware of what directory you are in, especially if you then navigate somewhere
– Be aware of what directory you are in, especially if
you then navigate somewhere within CCStudio
– Our code is interrupt driven, so most work today
will be done on isrs.c

• Open CCStudio

• Create a project

• Add files to the project directory

• Add files to project

• Setup the compiler options

• Build the project

• Load the project

• Run the project

• Add files to project • Setup the compiler options • Build the project • Load
CCStudio: A Tutorial • Appendix A of the textbook
CCStudio: A Tutorial
CCStudio: A Tutorial

• Appendix A of the textbook

CCStudio: A Tutorial • Appendix A of the textbook
CCStudio Observations • Does the talk-through program work? • You can run or halt the
CCStudio Observations
CCStudio Observations

• Does the talk-through program work?

• You can run or halt the program at anytime and you don’t need to reload

• You can establish a watch window by highlighting and right-clicking on the variable that you selecting, then selecting Add to Watch Window

• Watched variables can be modified while the program is running (if they are in scope)

selecting Add to Watch Window • Watched variables can be modified while the program is running
A Few Comments – Make sure that you are in scope • Watch window(s) •
A Few Comments – Make sure that you are in scope
A Few Comments
– Make sure that you are in scope

• Watch window(s)

• The volatile keyword

• Function prototypes and return types

• ISRs and the run-time schedule

• Sample-by-sample processing

• Gain adjustments (volume control)

• “Hello, world” … can we print to the host PC?

• Turning the user LEDs on and off

adjustments (volume control) • “Hello, world” … can we print to the host PC? • Turning
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
FIR Filtering FIR filters are the most popular type of digital filter • Always stable
FIR Filtering
FIR Filtering

FIR filters are the most popular type of digital filter • Always stable

• Easy to design

• Easy to ensure linear phase response

• Require more coefficients for same roll off compared to IIR filters

design • Easy to ensure linear phase response • Require more coefficients for same roll off
FIR Filter b 0 x[n] + y[n] -1 z b 1 x[n-1] + -1 z
FIR Filter b 0 x[n] + y[n] -1 z b 1 x[n-1] + -1 z
FIR Filter
b
0
x[n]
+
y[n]
-1
z
b
1
x[n-1]
+
-1
z
b
2
x[n-2]
+
-1
z
b
3
x[n-3]
+
-1
z
b
4
x[n-4]
Filter b 0 x[n] + y[n] -1 z b 1 x[n-1] + -1 z b 2
y FIR Difference Equation ∞ yn [] = ∑ hk xn k [][ −= ]

y

FIR Difference Equation ∞ yn [] = ∑ hk xn k [][ −= ] hn
FIR Difference Equation
yn
[]
=
hk xn k
[][
−=
]
hn
[] []
*
xn
k =−∞
N
yn
[]
=
bk xn k
[][
−=
]
bn
[] []
*
xn
k
= 0
N
y
[]
0
=
bk x
[] [
k
]
k
= 0
[
0
]
=
b
[
00 x
]
[
]
+
b
[] [
1
x
−+ +
1
]
L
bN x
[
]
[
N
]
x [] [ − k ] k = 0 [ 0 ] = b [ 00
y FIR Difference Equation (con’t) [] [][] [][ ] 0 = b 00 x +

y

FIR Difference Equation (con’t) [] [][] [][ ] 0 = b 00 x + b
FIR Difference Equation (con’t)
[] [][] [][ ]
0
=
b
00
x
+
b
1
x
−+ +
1
L
bN x
[ ][
N
]
but we can modify the indices
y
[
0
]
=
b
[
0
]
x
[
0
]
+
b
[] []
11
x
++ L
bN xN
[
]
[
]
N ] but we can modify the indices y [ 0 ] = b [ 0
CCStudio Implementation – Declare the b coefficients in the ISR – Cut-and-paste can also work
CCStudio Implementation – Declare the b coefficients in the ISR – Cut-and-paste can also work
CCStudio Implementation
– Declare the b coefficients in the ISR
– Cut-and-paste can also work
– Great for large filters
• But do you really want to type in all of those
coefficients by hand?
– Create the files directly from MATLAB
• FIR_dump2c.m

• Local declaration

• Additional files (e.g., coeff.c and coeff.h)

the files directly from MATLAB • FIR_dump2c.m • Local declaration • Additional files (e.g., coeff.c and
Sptool Startup GUI
Sptool Startup GUI
Sptool Startup GUI
Sptool Startup GUI
Fdatool Startup GUI
Fdatool Startup GUI
Fdatool Startup GUI
Fdatool Startup GUI
More FIR … a few ideas – e.g., second order sections • Flanging • Chorus
More FIR … a few ideas – e.g., second order sections
More FIR … a few ideas
– e.g., second order sections

• Flanging

• Chorus

• Circular buffering

• Echo creation

• Other FIR filter forms

• Impulse modulator … digital transmitter

Chorus • Circular buffering • Echo creation • Other FIR filter forms • Impulse modulator …
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
Real-time Waveform Generation – V OUT = V MAX sin(2πft) – Calculate directly as a

Real-time Waveform Generation

– V OUT = V MAX sin(2πft) – Calculate directly as a function of t
– V OUT = V MAX sin(2πft)
– Calculate directly as a function of t
– Calculate as a function of the desired signal phase
– Use lookup table to obtain sine values, use index as phase
accumulator
– Use complex vector rotation
– Use a digital resonator

• Your mission – generate a 1 kHz sinusoid

• Some ways to do it

• May want to glance at textbook

• Modify your talk-through application as necessary create a sinusoid generator

it • May want to glance at textbook • Modify your talk-through application as necessary create
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
Intro to DSP/BIOS™ Software Kernel Foundation Section B.1 – Introduction Section B.2 – Exercise in

Intro to DSP/BIOS™ Software Kernel Foundation

Section B.1 – Introduction Section B.2 – Exercise in using threads • Can come back
Section B.1 – Introduction
Section B.2 – Exercise in using threads
• Can come back to this if you have time & desire
Section B.5 – Talk-through on the C6713 DSK
• This is equivalent to the earlier tutorial, but in a DSP/BIOS
environment
• Text for cut-and-paste is on your CD-ROM

• DSP/BIOS™ kernel is a lean real-time operating system (RTOS) specific to the TI DSPs

• There are advantages and disadvantages to introducing it into an academic setting

• Follow Appendix B of your textbook

There are advantages and disadvantages to introducing it into an academic setting • Follow Appendix B
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
Using a host PC to control the DSK without CCStudio • winDSK6 • MATLAB Interfaces
Using a host PC to control the DSK without CCStudio • winDSK6 • MATLAB Interfaces
Using a host PC to control the DSK without CCStudio
• winDSK6
• MATLAB Interfaces (data acquisition and real-time control)
• DSK6X_Control for host application development
The DSP software can use the daughtercard resources
as well
• USB and RS-232 communications
• Up to 16 digital I/O pins
• Up to 8 analog inputs
Software interface is already provided – simple function
calls are used to access all resources

eDSP DSK6713HPI Daughtercard

• Host Services

• DSP Services

calls are used to access all resources – eDSP DSK6713HPI Daughtercard • Host Services • DSP
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

• Introduction

• Building Real-Time DSP Applications

• Advanced Topics

• Wrap-Up

– • Introduction • Building Real-Time DSP Applications – – – – • Advanced Topics –
Individual Project Time • Have at it! • Feel free to ask questions
Individual Project Time
Individual Project Time

• Have at it!

• Feel free to ask questions

Individual Project Time • Have at it! • Feel free to ask questions
Agenda Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR

Agenda

Motivation DSK and Software Installation Software Organization Building a CCStudio Talk-Through Application FIR
Motivation
DSK and Software Installation
Software Organization
Building a CCStudio Talk-Through Application
FIR Filtering
Signal Generation
DSP/BIOS™ Application
HPI Daughtercard (DSP Services/Host Services)
Individual Projects

Introduction

Building Real-Time DSP Applications

Advanced Topics

Wrap-Up

– – Building Real-Time DSP Applications – – – – Advanced Topics – – – Wrap-Up
Wrap-Up http://eceserv0.ece.wisc.edu/~morrow/software/ http://www.educationaldsp.com – • The DSK development
Wrap-Up http://eceserv0.ece.wisc.edu/~morrow/software/ http://www.educationaldsp.com
Wrap-Up
http://eceserv0.ece.wisc.edu/~morrow/software/
http://www.educationaldsp.com

• The DSK development environment is fairly easy to use … once you know how!

• Practice making your own CCStudio projects

• Mike’s software page has lots of software for the C6713 and older DSKs

• For more information on the HPI daughtercard see the Educational DSP website

for the C6713 and older DSKs • For more information on the HPI daughtercard see the
Real-Time DSP for Educators Michael Morrow (morrow@ieee.org) University of Wisconsin-Madison Thad Welch
Real-Time DSP for Educators Michael Morrow (morrow@ieee.org) University of Wisconsin-Madison Thad Welch
Real-Time DSP for Educators
Michael Morrow (morrow@ieee.org)
University of Wisconsin-Madison
Thad Welch (t.b.welch@ieee.org)
United States Naval Academy
Cameron Wright (c.h.g.wright@ieee.org)
University of Wyoming
References • [1] – TMS320C6713 DSK Technical Reference, Spectrum Digital, Jan. 2004 • [2] –
References
References

• [1] – TMS320C6713 DSK Technical Reference, Spectrum Digital, Jan. 2004

• [2] – Digital Signal Processing, a computer-based approach, Sanjit K. Mitra, McGraw Hill, 2001

• [3] – Real-time Digital Signal Processing from MATLAB to C with the TMS320C6X™, Thad B. Welch, Cameron H. G. Wright, Michael G. Morrow, CRC Press, 2006

from MATLAB to C with the TMS320C6X™, Thad B. Welch, Cameron H. G. Wright, Michael G.
winDSK6 DSK6_Control host application and DSP software C6XDAQ MATLAB data acquisition C6XDSK MATLAB program interface
winDSK6
DSK6_Control host application and DSP software
C6XDAQ MATLAB data acquisition
C6XDSK MATLAB program interface

acquisition C6XDSK MATLAB program interface – – – • Numerous demonstration and experimentation applications

• Numerous demonstration and experimentation applications

• Other software

MATLAB program interface – – – • Numerous demonstration and experimentation applications • Other software
MATLAB program interface – – – • Numerous demonstration and experimentation applications • Other software