EE265 Lab 2: Working with Hardware

Winter 2007-2008
Instructor: Teresa Meng


I. Purpose:

This lab introduces real-time programming on the C5509 EVM board. Hardware-related issues, real-time programming concepts, constraints, and limitations will be discussed. We will take a closer look at the EVM board by generating a waveform and observing the output. The waveform that is generated will also be fed back to the input of the EVM board to be digitized and analyzed. This effectively measures the distortion introduced by the Analog Interface Circuitry (AIC) on the EVM board. This lab will attempt to relate these experiments to what you learned from the lecture on analog interface and signal reconstruction. Finally, this lab will introduce some experiments on sampling theory and quantization to give you an idea of how they affect the signals.

II. Introduction:

A. Real-Time Processing

The main purpose of this lab is to introduce real-time programming on the TI C5509 evaluation module (EVM) board. The method we introduce here will be used in the rest of this lab course. In order to do real-time programming, we must be able to acquire real-time inputs and generate real-time outputs. In the lab exercises we will do, we want to use analog signals (such as an audio source) as our input and we would like to generate analog signals (audio signal) as our output. The C5509 itself does not have any analog inputs or outputs, so it can only deal with digital input and outputs. This means that any inputs must be converted to digital form before being passed to the C5509. Also, any output from the C5509 can only be digital, so some external hardware must be needed to convert the digital output to analog form. This means that the analog interfacing is actually handled by hardware on the EVM board.

 

This process ensures that the application is not notified until all required conditions are met, so the input and output pipes are effectively synchronized.

 

B. Analog Interface

The C5509 EVM board uses the AIC23B. Detailed information on the AIC is given in TLV320 AIC23B Data Sheet. You will not need most of the information given in the data sheet as the data sheet is intended for the board designers.

 

III. Readings:

Section 2.2, "Pipe or PIP Module"

Section 3.1, "About the Example"

Section 3.3.2 "Audio Sampling Rate"

IV. Lab Exercises:

This lab will take you step by step through setting up a real-time DSP code capable of processing audio-band signals. Once the framework for handling real-time data is setup, you will then implement a waveform generator to generate a sine wave to the output of the DSP. You will also write a waveform recorder to record signals and see the effect of the sampling/quantization process on their spectrum. Finally, you will play with different sampling rates and quantization schemes to see for yourself what kind of effects they introduce.

A. Setup

Although the DSP/BIOS can assist you in configuring the processor, the interrupts, and the serial ports, the DSP/BIOS still requires a fair amount of setup work in order to get it working correctly. This section goes through the setup step by step. We could have provided you an entire project template with all of this done for you, but it is important for you to understand what goes on behind the scene since you will be repeating the same procedure in later labs. The following sections describe how to set up the DSP/BIOS to read data to/from the analog interface chip, and how to configure the various program elements that are used for the rest of the lab.

 

Setting up the Project

Follow the procedure given in lab 1 to start CCS.

Create a new project in the lab2/audio directory and call it audio.

The assembly template is provided in audio_tmpl.zip. First, download and decompress these files to your lab2/audio directory. Do not put the files in an "audio_tmpl" subfolder.

Add the following source files to the project. Select Project->Add Files to Project... to add source files. If you don't see the source files listed, change the field Files of type: to the appropriate type. For example, for .s55 (linear assembly) codes, set the type as Asm Source Files (*.a*,*.s*).

Notice that the automatically generated audiocfg* files are added to your source code when you add audio.cdb.

Select Project->Scan All Dependencies. What this does is it updates the include folder to reflect any header files that you have included in your source codes. If you expand the include folder by clicking on the plus next to the Include folder, you will see a very long list of files. Most of this is from DSP/BIOS. Remark: From here on for the sake of conciseness, the term "expand" will be used to denote the action of clicking on the "plus" symbol next to the item to be expanded.

Completing the DSP/BIOS Configuration

We need to finish configuring the DSP/BIOS. Double click on the audio.cdb file (located under the DSP/BIOS Config folder).

 

 

 

 

B. Digital Audio Loop-back

This exercise will be the first to use IO in this lab, so we will merely verify their use. An audio source is generated on the host computer and this is connected to the input of the EVM board. The loop-back is done digitally by copying the data from the receive serial port to the transmit serial port. You can check the functionality of this loop-back by listening to the output of the EVM board. A better way to check the functionality is to verify numerically that the input samples are copied to the output (the source (src) buffer frame gets copied to the destination (dst) buffer frame).

C. Sine Wave Generator

In this portion of the lab, you will write a sine wave generator to output a pure digital sine wave from the EVM board. This section is intended to exercise your assembly programming skills with a simple exercise of copying data from the data memory into the data transmit buffer, pointed to by dst. A template for the assembly routine is provided for you but you must complete the code and generate a sine wave at the output of the EVM.

1. Setup

extern Void sinegen_proc_init(Void);
extern Void sinegen_proc(Void);
sinegen_proc_init();

Note that there is no underscore, "_", preceding the function name, sinegen_proc_init, but in sinegen_proc.s55, this function does have the underscore. This is simply the convention used to call C functions from assembly, but the underscore is not needed in C.

In the processBuffer () function, replace the for loop with the following statement:

sinegen_proc();

So rather than copying the data from the src buffer to the dst buffer in the C code, you are calling a function (which in this case is written in assembly), sinegen_proc(), to process the src and dst buffers.

2. Coding

3. Debugging with the CCS Graphing Feature

·         One of the most helpful debugging tools that we have available is the graphing feature of Code Composer Studio. This allows us to graphically plot out the values in region of memory (which can be very helpful for sinewave generation). Here is a brief description of how to graph the dst buffer:

o        Select View->Graph->Time/Frequency. A Graph Property dialog box will pop up. Change the following settings:

§         Graph Title - dst buffer. This is the label you have chosen to identify the graph window.

§         Start Address - dst. This is the label you have chosen for starting address of your data buffer.

§         Acquisition Buffer Size - 192. This is the size of the data buffer. 

§         Display Data Size - 96. This specifies the portion of the data buffer you would like to have plotted. The number specified here must be smaller than the acquisition buffer size.

§         DSP Data Type - 16-bit signed integer. This is the default type for digitized samples.

§         Click on OK to close this dialog box. The data in your dst pipe frame will be plotted with respect to time.

o        This will allow you to view the frame pointed to by dst. Keep in mind that dst switches between input frames, so the graph will actually show you different frames at different times.

o        The receive pipe can be viewed by graphing src.

 

4. Profiling

 


D. Audio Recorder

Once you have completed and tested your sine wave generator, you will implement an audio recorder. You will then analyze the audio samples using the CCS graphing tool to view the time and frequency spectrum of the samples. You will also perform some simple experiments to analyze the physical signals.

1. Coding Specifications

 

2. Debugging using CCS Features

·         Graphing:
As described above, the graphing feature of CCS can be one of the most helpful debugging tools that we have available. You can use the graphing feature to plot the values directly, or you can also make other plots (such as the FFT of the values). The following steps will guide you through the process of plotting the recorded signal directly and also plotting its FFT magnitude:

o        To test your code, connect an audio source and start the music, as described previously.

o        Compile, reset DSP, load the program onto the EVM, and run the program.

o        Stop the program shortly (after few seconds - to be sure that the buffer is filled with data samples).

o        Select View->Graph->Time/Frequency. A Graph Property dialog box will pop up. Change the following settings:

§         Graph Title - Amplitude vs. Time

§         Start Address - recordData. This is the label you have chosen for starting address of your data buffer.

§         Acquisition Buffer Size - 1024. This is the size of the data buffer.

§         Index Increment - 2. This is because the buffer format is stereo, L/R interleaved format.

§         Display Data Size - 512. This specifies the portion of the data buffer you would like to have plotted. The number specified here must be smaller than the acquisition buffer size.

§         DSP Data Type - 16-bit signed integer. This is the default type for digitized samples.

o        Click on OK to close this dialog box. The data in your record buffer will be plotted with respect to time.

 

 

3. Verification using MATLAB

Although CCS has many useful debugging features, it cannot help you with all types of analysis that you may wish to perform. For example,