Intro to Code Composer Studio CCS

Document Sample
Intro to Code Composer Studio CCS Powered By Docstoc
					             Interrupts/Polling and Input/Output with the DSK Codec
In this lab you will do the following:
Part 1. Acquire a sinusoidal input using an interrupt-driven program.
Part 2. Acquire a sinusoidal input using polling.
Part 3. Produce an echo of an input signal.


## Answer the following:
1. What operating system are you using?
2. How much time does it take to complete the lab (do not include the time to write your


Build and Create the Project:

For the purposes of this lab, the following files will be called support files:

       C6xdsk.cmd, c6x11dsk.h, C6xdsk.h, c6xdskinit.c, c6xdskinit.h, c6xinterrupts.h,

       We basically discussed these files in class. They specifically set up interrupt 11 to
       correspond to an interrupt from the McBSP saying that it is ready to send data.

       vectors_11.asm is the vector table with a branch to the interrupt service routine for
       interrupt 11.

You will need to create a project and add the following files:

       loop_intr.c and the relevant support files (*.h files are not added – Scan All
       Dependencies instead)

       When the McBSP says that it is ready to send data, the interrupt service routine (ISR)
       is run. The interrupt service routine acquires a sample from the input and then sends
       this to the output. After the data is sent out, the McBSP sends an interrupt saying that
       is ready again to send another sample. Since the ISR runs in less than 0.125 ms and
       since the codec samples at a frequency of 8 kHz (T=0.125 ms), that means we output
       data at a frequency of 8kHz.

       This routine also stores data in a buffer of size 512 which is rewritten from the
       beginning after the end of the buffer is reached.


To generate the input signal for the lab, we will use Goldwave which has a function generator

Launch Goldwave and then open a New file which is a mono voice signal.
Then go to Tools > Expression evaluator. In the Expression block, type sin(2*pi*f*t). In the
f= block, type 1000. Then hit Start. After the Status is Finished, close the box. Go to View
> Zoom 1:1.

If the Device Controls window is not open, go to Window > Companion and select Device
Control. Hit the right-mouse button while in the Device Controls window and select
Properties. Check the box for Loop and set the number to 0. This creates an infinite loop.
When you are ready to run, you activate the loop by hitting the User Play button, the green
button with the smiley face (cute).


Now connect the output of the computer sound card (on the back of the computer) to the
input of the DSK board. Connect the output to the scope. Set the scope at around 500mV,
DC coupling, and Auto for the trigger mode (found by hitting the Trigger Menu on the

Running the program

Start the sine wave input using the Device Controls Window.
Load and run the loop_intr program.
On the scope, you may want to change the time scale by turning the know Sec/Div so that the
signal is easier to view.
Select Trigger Menu on the scope and Normal or Single for the mode. This should freeze or
stabilize the signal so that you can take measurements. If that does not work, you can always
hit Run/Stop to freeze the signal.
Select Cursors on the scope and Type Voltage and measure the peak-to-peak voltage. Find
the offset (in other words the signal is not centered at 0 but at an offset).
Select Type Time and determine the frequency of the signal.

Let’s also look at the output in the buffer. Go to View > Graph > Time/Frequency. For the
start address use the variable buffer. The acquisition buffer size is 512. Use a display data
size of 512. DSP Data Type is 16 bit signed integer and the sampling rate is 8kHz. Now
change the display data size to 128. What is the peak-to-peak amplitude?

Now go to View > Graph > Time/Frequency. Select Display Type of FFT Magnitude.
Acquisition Buffer Size and FFT Framesize should be 512. The FFT Order should be 9 since
2^9 = 512. The sampling rate is 8kHz and the data type is 16 bit signed integer. What is the
frequency of the signal.

## Answer the following:
3. Open up the vectors_11.asm file. When there is an interrupt from interrupt 11, to where
does program execution branch?
4. What is the peak-to-peak voltage of the output of the codec according to the scope?
5. What is the DC offset?
6. What is the frequency of the signal according to the scope?
7. What is the peak-to-peak amplitude according to the graph in CCS? If there is a 1 LSB
change in the signal sent to the codec, what approximately is the change in the output
voltage of the codec?
8. What is the frequency of the signal from the FFT?


You will need to create a project and add the following files:

         loop_poll.c, vectorsc.asm, and the support files except for vectors_11.asm

         loop_poll.c acquires data through polling and sends data out by polling.

Repeat what you did above in part I but this time using polling.

The input_sample function in the c6xdskinit.c file calls mcbsp_read, also in c6xdskinit.c. Go
to the function mcbsp_read. If you are polling, there is a test condition which must be
satisfied before a sample is acquired. Try to explain this condition. MCBSP0_SPCR refers
to the serial port control register (SPCR) contents. (The address for this register is defined in
the C6x11dsk.h file.)

## Answer the following:
9. What is the peak-to-peak voltage of the output of the codec according to the scope?
10. What is the offset?
11. What is the frequency of the signal according to the scope?
12. What is the peak-to-peak amplitude according to the graph in CCS? Based on this, what
is approximately the output voltage of the codec per 1000 bits sent to the DAC?
13. What is the frequency of the signal from the FFT?
14. Explain the test condition for acquiring data while polling.


You will need to create a project and add the following files:

         echo.c and the support files. Also, put the echo.gel file in the project folder.

The file echo.c creates an echo of the input by adding a de/amplified version of the delayed
input to the current input and using that as the output. The delayed input is created through
the use of a buffer.

GEL stands for general extension language. It is used to make a nice little interface to vary
parameters within a program.


For this section, we will use a voice file called THEFORCE.wav. Load this into Goldwave.


For this section, you need to disconnect the output from the scope and attach the speakers to
the output.

Running the program
Run TheForce file in Goldwave.
Load and run the echo program. You should hear a voice with echo from the speakers.

Go to File > Load Gel. Load the echo.gel program. Go to GEL > Echo Control > Amplitude.
Repeat for Delay. Amplitude changes the amplitude within the program and Delay changes
the buffer size within the program. The buffer size is Delay x 1000. Rerun the program and
change the amplitude and time delay.

Change the echo.c program so that now the output is stored in the buffer rather than the input.
This creates a fading echo.

## Answer the following:
15. What amplitude and buffer size do you like the best, i.e. to create the echo that you like?
16. What amplitude and buffer size do you like the best for a fading echo?

17. Did you run into any problems in this lab?

Shared By: