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 developme
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 2Hà Nội, 2022
M Ụ C L Ụ C
BÀI 1: UNIT 1 - DSP TRAINER FAMILIARIZATION 3
1.1 EX1: DSP Trainer Familiarization 3
1.2 EX2: Overview of the DSP Circuit Board 3
1.2.1 Discussion: Overview of the DSP Circuit Board 3
1.2.2 Procedure: Overview of the DSP Circuit Board 3
1.2.3 Review Questions 6
1.3 EX3: Integrated Development Environment (IDE) and Project Structure 7
1.3.1 Integrated Development Environment (IDE) and Project Structure: Discussion 7
1.3.2 Procedure: Integrated Development Environment (IDE) and Project Structure 7
Editing Memory and Registers 12
1.3.3 Review Questions 13
1.4 Unit Test 14
BÀI 2: UNIT 2 - ARCHITECTURE 17
2.1 Architecture: Fundamentals 17
2.2 EX01: Processor Arithmetic 17
2.2.1 Discussion: Processor Arithmetic 17
2.2.2 Procedure: Processor Arithmetic 17
Converting a Signed Fractional Number to Q14-Format 17
Converting a Binary Number to a Decimal Value 18
Comparing the Multiplication of Integers to the Multiplication of Floats on a Fixed-point DSP 22
2.2.3 Review Questions 23
2.3 EX02: Data Computation Unit 24
2.3.1 Discussion: Data Computation Unit 24
2.3.2 Procedure: Data Computation Unit 24
Set Up of the DSP Board 24
Overflow, Saturation Mode and Carry Bit 27
2.3.3 Review Questions 30
2.4 EX03: Memory 31
2.4.1 Discussion: Memory 31
2.4.2 Procedure: Memory 31
Set Up and Connections of the DSP Board 31
Testing the Program 32
2.4.3 Review Questions 37
2.5 EX04: Addressing 38
2.5.1 Discussion: Addressing 38
2.5.2 Procedure: Addressing 38
Set Up and Connections of the DSP Board 39
2.5.3 Review Questions 44
2.6 Unit Test 45
1
Trang 3BÀ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 4BÀ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?:
a yes
b no
2 Turn the power supply ON to power the circuit board
3 Using a dc voltmeter, measure the voltage range at the output of the dc sourcecircuit block To do so, vary the potentiometer of the dc source from its smallest toits largest values What is the minimum voltage and maximum voiltage:
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 55 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
9 Perform the connections shown
10.Adjust the DIP switch of the I/O interface so that every bit is in the 0 position.Press the interrupt button so that the LCD displays an Echo Delay 0ms 11.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
13.Repeat the last step with the following DIP switch values:
031 (0001 1111)
063 (0011 1111)
127 (0111 1111)
4
Trang 6Using 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
5Choose Answer: d
Choose Answer: d
Trang 717.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 85 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
in Appendix C
Launch Code Composer on your computer
3 Make exercise_1_2 the active project simply by clicking on that project in theProject Explorer window
4 Launch the Debug mode by clicking the icon to load the program into the DSP
7Choose Answer: d
Trang 9Do 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
7 While keeping an eye on the main.c, Disassembly and Variables tabs, experiment
Trang 10with 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
10.Use an oscilloscope to observe the signal at the analog output of the CODEC.Does the amplitude of the signal change as you change the frequency?
a Yes
b No
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%
11.Click on the icon to halt the execution of code
12.A crucial part of debugging is to be able to know the value of a given variable at agiven moment in the process This can be done in most cases using the Expressions
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 11On 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
14.Another method to visualize a large array of data is to use the graphics displaytool
15.In the Tools menu, choose Graph, then Single Time In the dialog box, set theparameters as shown and click OK The Start Address is the location in memorywhere the table begins The sintbl variable contains that address
Which of the following best represents the resulting graph of the contents of thesintbl table?
a
100x1234
Trang 1216.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
17.It is possible to go deeper in the code by placing a breakpoint in the assembly codedirectly
The breakpoint which was placed below the “ //Breakpoint #01 ” identifier in the Ccode corresponds to a breakpoint automatically placed in the disassembly code at address
Trang 13Add 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 14on 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
20.Halt the program again ( ) and edit the PC register in the Registers tab (CoreRegisters) to this value: 0x023129
Run the program again ( ) Does it perform as intended?
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 15b 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 16shown The height of each block character can range from 0 to 8 pixels, but the bottomrow of pixels is always displayed to mark the position This means that the height of eachbar can range from 1 to 16 pixels
The height of each bar represents the relative magnitude of the output of thecorresponding frequency bin A bar 1 pixel high represents zero (the correspondingfrequency is absent) and a bar 16 pixels high represents the maximum displayedmagnitude for that frequency bin
7 Adjust the sine-wave generator to different frequencies and observe the displayedspectrum Start with the frequencies shown here
Observing Output in Code Composer
8 Set the frequency of the sine wave to 250 Hz (0010 0000b) In code Composer,pause the program using the Halt button If the Breakpoints window is notvisible, choose Breakpoints in the View menu This window should be empty, asshown
In the main.c file, find the four breakpoint comments, but do not set thebreakpoints yet:
double-Right-click on the line of the breakpoint in the Figure and select BreakpointProperties in order to edit the name Change the name of this breakpoint to Breakpoint
#01 and click on Edit Property
In the main.c file, find the comment //Breakpoint #02, set the breakpoint on thefollowing line and immediately rename it Do the same with //Breakpoint #03 and//Breakpoint #04
When you have finished, the Breakpoints window should resemble this Figure
In the Breakpoints window, use the checkboxes to deactivate all breakpointsexcept for Breakpoint #01, as shown here
Press the run button to start execution of the code Execution stops after thecomment //Breakpoint #01
The if statement a little above the comment //Breakpoint #01 tests the value of thevariable flag_update_display
67
Trang 17This variable is set to 1 when new time-domain data has been acquired from theCODEC The vector fft_x_data contains the acquired data
9 You can view the acquired time-domain data in Code Composer In the Toolsmenu, choose Graph, then Single Time Set the parameters as shown in this Figure.Since the start address is set to fft_x_data and since both the Acquisition BufferSize and the Display Data Size are set to 128, all 128 values in the vectorfft_x_data will be graphed
Here we see the line at which execution was halted and an example of the graph ofthe acquired signal in fft_x_data
The graph shows all 128 values contained in the vector fft_x_data The horizontalaxis shows the sample numbers and the vertical axis shows the sample numbers that rangefrom 0 to 127
The function used in this application to perform the FFT uses a complex valuedalgorithm The input vector for this function must consist of interleaved real andimaginary values (Refer to Arguments in the Table previously discussed.)
The data acquired by the CODEC, however, is real-valued; there are no imaginaryvalues The complex-valued FFT algorithm can still be used, however, simply by makingall the imaginary values equal to zero This is why every other sample in fft_x_data iszero
The 128 values in fft_x_data must therefore be interpreted as 64 complex values inthe interleaved Re-Im format: 64 real values (the data acquired by the CODEC)interleaved with 64 imaginary values which are all equal to zero
Our next Table shows how the contents in the vector fft_x_data should beinterpreted
10.In the toolbar of the graph window, click the graph properties button toredisplay the Graph Properties dialog box
You can graph just the real values in fft_x_data by setting Index Increment to 2and the Display Data Size to 64, as shown This graphs every other value in the vector,starting with the first real value Setting the Time Unit to ms shows time on the horizontalaxis
Our next Figure shows the graph with these new settings As expected, only thereal values, which were acquired by the CODEC, are graphed All imaginary values (theadded zeros) are skipped
11.Clicking in the Single Time graph window displays two red cursors as well as thevalues that these cursors represent You can use these cursors to measure the period
of one cycle of the waveform, as shown
Click in the graph window and carefully move horizontal cursor to the first sample
on the vertical axis and, while still holding down the mouse button, move the vertical
68
Trang 18cursor to the intersection of the horizontal cursor and the next cycle of the waveform.This displays the approximate period in milliseconds of the waveform
Considering the frequency of the sine wave, is the observed period what youwould expect?