This waveform can be observed on an oscilloscope.o Spectrum mode: The frequency spectrum of the reconstructed analog signal isavailable at the ANALOG OUTPUT.. The selected output mode is
Trang 1ĐẠI HỌC BÁCH KHOA HÀ NỘI
TRƯỜNG ĐIỆN - ĐIỆN TỬ
TRUNG TÂM ĐÀO TẠO THỰC HÀNH ĐIỆN – ĐIỆN TỬ
TÀI LIỆU BÁO CÁO KẾT QUẢ THÍ NGHIỆM
Trang 2BÀI 3: I/O AND PERIPHERALS 48
3.1 I/O and Peripherals: Fundamentals 48
3.2 EX01: An Application Using I/Os and Peripherals 48
3.2.1 Discussion: An Application Using I/Os and Peripherals 48
3.2.2 Procedure: An Application Using I/Os and Peripherals 48
Set Up and Connections of the DSP Board 48
Peripheral Registers 49
3.2.3 Review Questions 50
3.3 Unit Test 51
BÀI 4: DSP REAL-TIME PROCESSING 54
4.1 DSP Real-time Processing: Fundamentals 54
4.2 EX01: Sampling and Analog-to-Digital/Digital-to-Analog Conversion 54
4.2.1 Discussion: Sampling and Analog-to-Digital/Digital-to-Analog Conversion 54
4.2.2 Procedure: Sampling and Analog-to-Digital/Digital-to-Analog Conversion 54
The Sampling Application Used in This Exercise 54
4.2.3 Review Questions 63
4.3 EX02: The FFT and Optimizing DSP Applications 64
4.3.1 Discussion: The FFT and Optimizing DSP Applications 64
4.3.2 Procedure: The FFT and Optimizing DSP Applications 65
The FFT Application Used in the Exercise 65
4.3.3 Review Questions 76
4.4 Unit Test 78
BÀI 5: 79
5.1 Signal Processing Applications: Fundamentals 79
5.2 EX01: Applications - FIR and IIR Filters 79
5.2.1 Discussion: Applications - FIR and IIR Filters 79
5.2.2 Procedure: Applications - FIR and IIR Filters 79
5.2.3 Review Questions 79
5.3 Unit Test 79
GI Ớ I THI U Ệ
Tài liệu này ghi nhận các kết quả thí nghiệm của sinh viên dựa trên quá trình làm việc thực tế với bo mạch và các thiết bị thí nghiệm
2
Trang 3BÀI 1: UNIT 1 - DSP Trainer Familiarization
1.1 EX1: DSP Trainer Familiarization
o DSP Trainer Familiarization: Introduction
o Types of Microprocessors
o Peculiarities of DSPs
o Program Execution
1.2 EX2: Overview of the DSP Circuit Board
1.2.1 Discussion: Overview of the DSP Circuit Board
o Discussion
o The Accessories Section
o The DSP and its Peripherals Section
1.2.2 Procedure: Overview of the DSP Circuit Board
In this section, you will begin to familiarize yourself with some of the componentsand circuit blocks found on the digital signal processor circuit board
1
Locate, on the digital signal processor circuit board, all the common terminals.With the power OFF and using an ohmmeter, verify if the common terminals areconnected together Are all the common terminals connected together?:
4
Connect a microphone to the input of the microphone pre-amplifier and connectthe output of the pre-amplifier to the input of the audio amplifier Note: “You canalso use earphones if you are in an area where an audio output from the speaker isnot desirable
3
Choose Answer: a
Vmin(V)= -0.8
Vmax(V)= 0.9
Trang 45 While talking into the microphone, familiarize yourself with the use of thepotentiometers of the microphone pre-amplifier and of the audio amplifier blocks 6.
Remove all the connections (leads) present on the circuit board
Familiarization with the Circuit Board Using a DSP Program
In this section, you will familiarize yourself with the development environmentand you will load and run a program on the DSP
7
Connect the DSP board to your computer using USB port number 2 on the boardand a standard USB port on your computer Make sure that the circuit board powersource is turned ON and that the Code Composer software is installed as explained
in Appendix C Launch Code Composer on your computer
8
Make exercise_1_1 the active project simply by clicking on that project in theProject Explorer window Launch the Debug mode by clicking the icon to loadthe program into the DSP Next, press the icon in the menu where the debugicon was in order to run the program At this point, you should see the followinginformation on the LCD of the DSP circuit board: LabVolt 91031 Ex1-1 EchoGenerator
Using the microphone, input a signal (your voice) into the DSP Adjust the GAINpotentiometers of the pre-amplifier and of the audio amplifier to obtain a goodquality of sound at the output Experiment with the potentiometers Note that aseries of black rectangles light up on the last line of the LCD as you talk into themicrophone The length of that line corresponds to the magnitude of the inputsignal from the microphone pre-amplifier The program you downloaded into theDSP takes the input from the CODEC (which you connected to the microphonepre-amplifier), displays its amplitude on the LCD, and processes the signal which
is then sent to the output of the CODEC (connected to the speaker/headphones) 12
Adjust the DIP switch such that the 8-bit number sent to the DSP corresponds to
15 (or 0000 1111<sub>b</sub>, that is, 0000 111 in binary) Set the switchescorresponding to a one (1) to the I position Press the interrupt button so thatthe LCD displays an Echo Delay 15ms Notice the effect of the signal processing
on the sound of your voice
Trang 5Using a second application
In this section, you will experiment with a different program using the sameconnections
15
Make exercise_1_1b the active project simply by clicking on that project in theProject Explorer window Launch the Debug mode by clicking the icon to loadthe program into the DSP Next, press the to run the program At this point, youshould see the following information on the LCD of the DSP circuit board:LabVolt 91031 Ex1-1b Echo/Flanger Generator
16
Experiment with this application Press the and interrupt buttons andmodify the value of the DIP switch Speak in the microphone or use a soundsignal What is the function of pressing the interrupt button in thisapplication?
a To select Voice mode
b To select Echo mode
c To select Flanger mode
d All of the above
What is the function of pressing the interrupt button in this application?
a To change the mode
e To update the variable (value read from the DIP switch)
f To reset the DIP switch
g All of the above
5
Choose Answer: b
Choose Answer: d
Trang 617.
Click on the icon to terminate the execution of the program Return to theprojects tab and quit Code Composer Turn OFF the power supply and remove theconnections (leads) you made on the circuit board
1.2.3 Review Questions
1 Before the DSP circuit board can be used, a few steps must first be taken Which stepsmust be completed before using the board?
a Make certain that the DIP switches of the I/O interface are all in the OFF position
b Make certain that a USB connection between the board and the computer ispresent
c Make certain that the power source of the board is turned ON
a The DSP uses its 100 MHz internal oscillator
b The DSP uses a 32.768 kHz external oscillator and a phase-locked loop
c The DSP uses the 33.3 MHz oscillator of the CODEC
d The DSP uses the clock of the computer through the USB connection
4 Which of the following components is usually found in a CODEC?
Trang 75 Increasing the echo delay has which effect on the signal at the output of the DSP?
a It increases the echo effect
b It increases the time between consecutive echoes
c The sound seems more remote
d All of the above
1.3 EX3: Integrated Development Environment (IDE) and Project Structure
1.3.1 Integrated Development Environment (IDE) and Project Structure: Discussion
o The Code Composer Studio Software
o The Code Development Perspective
o Registers, Expressions, and Variables Windows
1.3.2 Procedure: Integrated Development Environment (IDE) and Project Structure
1
Connect the output of the DC source to the analog input of the CODEC and theanalog output of the CODEC to the audio amplifier as shown Also, connect onechannel of your oscilloscope to the analog output of the CODEC
2
Connect the DSP board to your computer using USB port number 2 on the boardand a standard USB port on your computer Make sure that the circuit board powersource is turned ON and that the Code Composer software is installed as explained
Trang 8Do not run the program yet.
5
Where is the memory address identified at which the main function starts?
a In the Project Explorer window
b In the Debug window at the end of the main() function string
c In the Disassembly window at the start of the debug session
d Both b and c
6
Go to the Registers tab and look for the Program Counter (PC) register Thisregister is in the Core Registers list Is the value of the PC register the same as themain function starting address?
a Yes
b No
Press the assembly step into button to go to the next assembly instruction What
is the value of the PC register now?
a The next sequential address in the program
c The main function starting address
d The function ending address
e None of the above
What does this number correspond to?
a The address where the main function started
f The address of the current assembly instruction
g The total number of program lines
h The address of the last assembly instruction
What is the use of the Program Counter register?
a To keep track of the total number of instruction addresses in the memory
i To keep track of the total number of programs in the memory
j To keep track of the address of the current instruction in the memory
k All of the above
Trang 9with the different debugger step arrows to observe what happens with the debuggerand the different variables.
8
Press the run button to run the program on the board Adjust the GAINpotentiometer of the audio amplifier to obtain a sound output of the appropriatevolume At this point, you should see the following information on the LCD of theDSP circuit board: LabVolt 91031 Ex1-2 - Sin Generator freq = x Hz (where x is anumber)
9
It should be quite obvious by the name on the LCD and by playing with the dcsource knob that this application generates a sinusoidal waveform which is heardfrom the loudspeaker (or earphones) Adjust the potentiometer of the dc source andobserve the result on the signal:
a The frequency of the signal displayed is modified as the potentiometer
is adjusted
b The value of the frequency is also modified accordingly on theLCD.</li>
c As the frequency changes the audio signal also changes.</li>
d All of the above
What is the obtainable range of frequency?
a The frequency can go from about 1 Hz to 500 Hz ± 5%
c The frequency can go from about 50 Hz to 50 kHz ± 5%
d The frequency can go from about 10 Hz to 5027 Hz ± 5%
or Variables tabs Here is a case where this method is not as convenient:
In the main.c file of Exercise 1-2, a table is declared on line 22 like this:
Trang 10On lines 47 to 51 of the main.c file, a loop calculates a value for each of theelements of the sintbl variable:
// fill sin table</code><br>
for (i=0; i<2048;i++) {
sintbl[i]=sin (i/2048.0 * 2.0 *3.14159265) * 32767;
}
Open the Expressions tab and type sintbl in the <new> field to obtain the values ofthe sintbl table of integers It is necessary to expand the display to see an element ofinterest Note the address of the sintbl variable:
13
Another method is to open a Memory window to visualize the data table Go to theView menu of Code Composer and choose Memory Browser to open a newwindow
sintbl variable = <recall>recall(hex1)</recall></p>
Search for the address of the sintbl variable in the Memory window Specify thatthe looked-after variable is in the DATA part of the memory and that its type is 16-bitsigned integer
The content of the memory can thus be observed in a table such as this:
This is an improvement, but due to the sheer size of the sintbl integer table, adifferent method should be used
Which of the following best represents the resulting graph of the contents of thesintbl table?
a
10
0x1
Trang 1116
The use of breakpoints is very important to any debug process With the debugprocess halted, insert a breakpoint in the main function below the commentidentified as “ //Breakpoint #01 ” in the code Do so by double clicking to the left
of the line number below the Breakpoint #01 identifier in the code
In the expressions tab, keep an eye on the value of the freq variable
Press the run button to run the program The execution of the program shouldhalt pretty quickly at the appropriate line in the main function Note the value of the freqvariable:
Adjust the dc source potentiometer in any direction and press the run button again The process should run briefly until it halts again at the same line of code.Observed freq variable = <recall>recall(fib1)</recall>
Is the current value of the freq variable the same or close to the same as observed
in the previous step?
a Yes
b No
Press the yellow step into arrow to execute the current line
What is the value of the freq variable now?
a The value remained the same
c The value updated corresponding to the new position of the dc sourcepotentiometer
d The value has dropped to zero
e None of the above
Trang 12Add a breakpoint in the Disassembly window at address 0x023086
This adds a corresponding breakpoint in the main.c file at which line?
Breakpoint line = <recall>recall(fib2)</recall>
Remove the breakpoint at address 0x023086, then add a breakpoint in the main.cfile at the line you just wrote down
At which address in the Disassembly window is a breakpoint added?
f The instruction at address 0x023046 was an include statement
g The instruction at address 0x023046 was a comment only
Remove all breakpoints inserted so far
Editing Memory and Registers
18
Open the interrupt.c program file Place a breakpoint after the “ //Breakpoint #02 “identifier Observe that the index variable is modified by this line of code.Open the Expressions tab and add the index variable to the list of variables ofinterest
It is possible to edit the value of the index variable from the Expressions tab Click
Trang 13on the Value field and change the value of the variable.
19
It is also possible to edit the registers of the DSP Open the Registers tab and locatethe XAR1 register in the Core Registers Click on the value field and edit the value
of the register (in hexadecimal)
Remove the breakpoint and run the debugger again by pressing the run button The program should be running properly
1 Which is the correct syntax for an assembly source statement?
a mnemonic [operand list] [Label + :] [; + comment]
b [Label + :] [operand list] mnemonic [; + comment]
c [Label + :] mnemonic [; + comment] [operand list]
d [Label + :] mnemonic [operand list] [; + comment]
2 What step(s) must you perform to execute a program from within the Code ComposerStudio software?
a Turn the power on to the DSP circuit board and connect it to your computer
b Launch Code Composer and start the debug mode for your program
c Execute the Run command from the Debug toolbar
d All of the above
3 Which of these features of Code Composer is false? Code Composer Studio allows adeveloper:
a to run and halt a program and execute single instructions
13
Choose Answer: b
Choose Answer: d
Choose Answer: d
Trang 14b to automatically generate C code for any application.
c to place breakpoints at source statements
d to edit, build, debug, and manage DSP projects
4 Which of the following sentences is correct?
a The breakpoints disappear when a program is executed in debug mode
b Breakpoints are not used by serious programmers
c The program is automatically halted when an execution line reaches a breakpoint
d All of the above
5 What are the best ways to visualize a large table of data?
a The Expressions tab
b The Graph tool
c The Memory window
d b or c., depending on the type of data
1.4 Unit Test
1 What characterizes a digital signal processor?
a Specialized internal structures that make them execute commands rapidly andefficiently
b Fast multiply instructions
c Reduced set of instructions, making the programming of DSP simpler
d All of the above
2 Which of the following is not displayed in one of the columns of the Disassemblywindow in Code Composer Studio?
a The CPU register
b The machine code instruction
c The instruction mnemonic
d The instruction operand(s)
Trang 153 Which of the following is written in machine code?
a if(freq > 300) then (freq = freq*2)
b 0x022F25 ADD #4369 << #3,AC0,AC0
c 1011 1110 0001 0011
d OMEGA: MPY #031h
4 Which of the following statements about digital signal processors is not true?
a They allow for more complex processing of signals than is possible with analogcircuitry
b They are less common than before in high-tech devices
c They provide repeatable performance
d Digital processing code can be easily modified, making design updates or changesmore flexible
5 What files are generated by Code Composer when a program is compiled and built?
7 What is the role of the CODEC?
a It detects code problems
b It encodes the data from the DSP into a string of ones
c It transforms an input analog signal into a digital one and transforms the outputdigital signal into an analog one
d It produces machine code for the DSP
Trang 168 The output of the dc source is adjusted with:
a a setting in Code Composer
b a potentiometer
c a lever
d It cannot be adjusted
9 The auxiliary power input is used to:
a generate power for the DSP board
b adjust the level of the input signal of the microphone
c receive power from an external source and distribute it to the DSP board
d All of the aboveabove
Trang 17BÀI 2: UNIT 2 - Architecture
2.1 Architecture: Fundamentals
o Architecture: Introduction
o The Von Neumann Architecture
o The Harvard Architecture
o The Architecture of the TMS320C5535
2.2 EX01: Processor Arithmetic
2.2.1 Discussion: Processor Arithmetic
o Fixed-Point and Floating-Point DSPs
o Binary and Hexadecimal Numbers
Introduction
Decimal to Binary Conversion
Binary to Decimal Conversion
Hexadecimal Numbers
Enter decimal number:
Binary
Hexadecimal:
Decimal to Hexadecimal Conversion
Hexadecimal to Decimal Conversion
Binary to Hexadecimal and Hexadecimal to Binary Conversion
o Two’s Complement Representation (2s-format)
o Fractional Numbers – Q-Format
o Fractional Numbers – Floating-Point Format
2.2.2 Procedure: Processor Arithmetic
Converting a Signed Fractional Number to Q14-Format
1
Convert -0.984375, a decimal signed fractional number to a binary Q14-format To
do so, open the Microsoft® Calculator tool or an equivalent one able to performbase conversions A pocket calculator with base conversion features works welltoo
C
Trang 18number to a binary number (in 2s-format) What is the integral decimal valueobtained?
3
Use the decimal to binary conversion tool of your calculator to obtain a one Word(16 bits) binary value You might have to specify that you want a Word result byclicking a checkbox
What is the binary result obtained?
What does it corresponds to in 2sformat?
Converting a Binary Number to a Decimal Value
Convert the following number to a decimal value in the following cases:B093h = 1011 0000 1001 0011b
Trang 19Calculate the resulting decimal value and select the correct result.
Remembering to include the implied bit what is the value of the mantissa?
Trang 20What is the Decimal value of the mantissa?
B093h = 1011 0000 1001 0011b
Identify the bit weights associated with the exponent:
What is the Decimal value of the exponent?
What is the decimal value of the number in 16-bit floating point format?
9
Connect the DSP board to your computer using USB port number 2 on the boardand a standard USB port on your computer Make sure that the circuit board powersource is turned ON and that the Code Composer software is installed as explained
in Appendix C Launch Code Composer on your computer
12
Open the Expressions tab and type “ var1 ” in the <new> field to see the value ofthis variable
Right-click on the current value and select Q-values > Select Q-Value
Then specify you want to use the Q14-format to display the value, using the selectQ-value option in the Q-Values submenu
Type in -0.984375 as the value of the variable
Trang 21OUTPUT This waveform can be observed on an oscilloscope.
o Spectrum mode: The frequency spectrum of the reconstructed analog signal isavailable at the ANALOG OUTPUT This frequency spectrum can be observed
on an oscilloscope
The output mode is selected using the button The selected output mode isdisplayed on the LCD
The anti-aliasing filter at the input of the CODEC and the post-filter at the output
of the CODEC can be turned on or off together using the button
The LCD displays the sampling rate, the output mode and the state of the filters 1
Connect the DSP board to your computer using USB port number 2 on the boardand a standard USB port on your computer Make sure that the circuit board powersource is turned ON and that the Code Composer software is installed as explained
Launch the Debug mode by clicking the icon to load the program into the DSP 3
Press the run button to run the program on the board At this point, you shouldsee the following information on the LCD of the DSP circuit board:
5
This Table shows the DIP switch settings to use for the different sampling rates.The application has an effective internal sampling rate of 12 000 Hz (12 000samples per second) Lower sampling rates are obtained by decimating the samples
by a factor that varies from 1 to 9
The LCD displays the sampling Rate It also displays the output mode (Waveform
or Spectrum) and the state of the anti-aliasing filter and post-filter (Filters OFF or FiltersON)
55
Trang 22Use the DIP switch to set the sampling rate to 12 000 Hz (DIP SW: 0000 0001) Use the button to set the output mode to Waveform
Use the button to turn the filters OFF
Adjust the signal generator to produce a sine wave message signal with anamplitude of 0.7 V peak
Set the frequency ƒm of the sine wave to 300 Hz
Our Figure shows an example of what you should observe on the oscilloscope.How does the output signal compare to the input signal?
a The output signal is a stepped waveform that has twice the frequency asthe input signal
b The output signal is a stepped waveform at one half the frequency asthe input signal
c The output signal is a stepped waveform that has the same shape andfrequency as the input signal
Set the parameters as shown in the Figure
This Figure shows execution stopped at the breakpoint and shows an examplegraph of the values in x (The starting point of the waveform will be different each timeexecution reaches this breakpoint.)
Does the graph of the values in x resemble the output signal waveform displayed
Trang 238.
In Code Composer, deactivate or remove the breakpoint Press the run button Use the button to turn the filters ON What effect does the anti-aliasing filterhave under the present conditions?
a It has little effect on the input waveform because its cutoff frequency(3100 Hz) is much higher than the input signal frequency (300 Hz)
b It has a large effect on the input waveform because its cutoff frequency(3100 Hz) is much higher than the input signal frequency (300 Hz)
What effect does the post filter have under the present conditions?
a Since the filters are ON, the output signal amplitude diminishes rapidly
as the input signal frequency increases beyond 3000 Hz
b At 4000 Hz, the output signal amplitude is zero
c All of the above
Determine the Nyquist rate for the selected sampling rate F_Nyquest = ƒs/2
ƒs =
ƒ_ Nyquest =
What is the purpose of the anti-aliasing filter?
a It removes high-frequency components from the input signal that could result
in aliasing
d Since the 3-dB cutoff frequency of the filter is approximately 3100 Hz,the filter completely removes frequencies above 4000 Hz
e 4000Hz is well below the Nyquist rate
f All of the above
Trang 2411.
Set the sampling rate to 6000 Hz (set the DIP switch to 0000 0010) Our Figureshows an example of what you should observe Describe the output signal
a a sinusoidal waveform at a higher frequency than the input signal
b a sinusoidal waveform at a lower frequency than the input signal
c a sinusoidal waveform at the same frequency than the input signal
What is the frequency of the output waveform?
The frequency of the output waveform is Hz
Explain what has happened by answering the following:
The Nyquist rate is now ƒs/2 = 6000/2 = 3000 Hz
Describe the output waveform with the sampling rate set to 2000 Hz and explainwhat is happening
Trang 25a The output waveform exactly duplicates the input signal Four samplesare taken per cycle.
b The output waveform is almost a square wave at the same frequency asthe input signal Four samples are taken per cycle
c The output waveform is almost a square wave at the same frequency asthe input signal Two samples are taken per cycle
What is the frequency of the output waveform?
The frequency of the output waveform is Hz
Explain what has happened by answering the following:
The Nyquist rate is now ƒs/2 = 1500⁄2 = 750 Hz
Trang 26to make qualitative observations in the frequency domain
In this mode, when the filters are ON, the output signal is filtered by the post filterbefore the spectrum is calculated This allows you to display the spectrum of the filteredsignal
14
Use the DIP switch to set the sampling rate to 12000 (DIP SW: 0000 0001) Usethe button to set the output mode to Spectrum Use the button to turnthe filters OFF Adjust the output level of the signal generator to 0 V
On the oscilloscope:
o set the Time Base to 0.5 ms/div
o set the Channel 2 Scale to 50 mV/div.<
o set the Trigger Source to Ch 2, set the Trigger Slope to Falling and set theTrigger Level to approximately -0.05 V
The oscilloscope should trigger on a negative peak If necessary, move thehorizontal trigger point in order to see this peak, as shown in our Figure
15
Move the horizontal trigger position to the extreme left side of the graticule Adjustthe signal generator to produce a sine wave message signal with an amplitude of0.7 Vpp Set the frequency ƒm of the sine wave to 1000 Hz You should see apositive peak near the middle of the first division, as shown in the Figure.This positive peak represents a sinusoidal frequency of 1000 Hz Show the verticalcursors and position a vertical cursor at the center of this positive peak Do not move thiscursor for the rest of this exercise The oscilloscope should indicate the horizontalposition of this cursor in ms
The extreme left side of the Ch 2 trace corresponds to 0 Hz (dc) The position in
ms of the cursor you moved over the positive peak corresponds to 1000 Hz
16
Set the frequency ƒm of the input message signal to 3000 Hz The left-mostpositive peak should now be in the second division of the graticule and three otherpeaks should be visible, as shown in this Figure.Position a second vertical cursorvertical at the center of the left-most positive peak, as shown in the same Figure.This horizontal position corresponds to 3000 Hz (Do not move the cursor at 1000Hz.)
Enter the horizontal position (in ms) that corresponds to 3000 Hz in the first row ofthe Table
Use the second cursor to determine the horizontal position of the three other peaksand enter these in the Table
The frequency scale of the Spectrum display is roughly 4500 Hz/ms Use this scale
to determine the approximate frequencies of the last three positive peaks in the Table.Peak (from Horizontal position Frequency Fpeak Frequency calculation
60
Trang 27the left) (ms) (Hz) fpeak in tearms of
As the sine wave message signal frequency increases, its peak in the spectrumdisplay moves to the right At the same time, the peaks in the first replica spread apart
a True
b False
Explain what happens as the input sine wave frequency reaches the Nyquist rate:
a The first replica is much lower than that of the message signal because ofaliasing
c The message signal and the lower component of the first replicacoincide
Explain what happens as the input sine wave frequency goes above the Nyquistrate
a The lower component of the first replica moves below the message signalfrequency and aliasing occurs