EECS20: Introduction to Real-Time Digital Systems

Lab05: C50 Board/Architecture Introduction


EECS20: Introduction to Real-Time Digital Systems
©1996 Regents of the University of California.
By William T. Huang, K. H. Chiang, Brian L. Evans.
URL: http://www-inst.eecs.berkeley.edu/~ee20
News: ucb.class.ee20
Assigned: 26 Feb 97, Checkoff: 5 Mar 97, Writeup Due: 7 Mar 97

Introduction

In the previous four labs, you have generated music notes and experimented with sound effects using MATLAB. This lab introduces a faster way to do the same processing--using the digital signal processor (DSP). In this course, we will be using TMS320C50 ('C50) fixed-point DSP to implement real-time systems. You will get some hands-on experience with the 'C50 development environment before you learn about the 'C50 architecture and instructions. A list of the acronyms and abbreviations we will be using in the laboratory are given at the end of the lab.

TMS320C5x DSP Starter Kit

The TMS320C5x DSP Starter Kit ('C5x DSK) is a stand-alone application board that lets you experiment with and use TMS3205x DSPs for real-time signal processing. Figure 2-2 on page 2-5 of TMS320C5x DSP Starter Kit User's Guide (available on the book shelf in room 117, Cory Hall) illustrates the components on the 'C5x DSK Board. The on-board analog interface circuit (AIC) converts analog voltage signals to and from some sequence of fixed point numbers processed by the DSP. The RCA jacks allow you to connect a microphone or function generator as inputs, and a speaker, earphones, or an oscilloscope as outputs. The DSK is connected to the PC through a RS-232 cable, so you can load your program into the DSP and monitor the status of the DSP. When you use the DSK, please make sure that all its I/O and power cables are connected correctly.

We will use two pieces of software in our DSK exercises. The DSK assembler assembles your assembly program into a .dsk file ready to be loaded onto the DSK. The DSK debugger allows you to load the .dsk files onto the DSK and to monitor the status of the DSP.

Now, you should complete the following walkthrough exercise:

A Quick Walkthrough

  1. Prepare a 3.5" diskette formatted for PC.

  2. Copy the program sawtooth.asm onto the diskette.

  3. Connect the DSK RCA output jack to the oscilloscope. Plug the DSK to power and turn on the oscilloscope.

  4. Run the DSK assembler. At the DOS prompt, type:

  5. Check your directory. Make sure the file sawtooth.dsk is created.

  6. Run the DSK debugger. At the DOS prompt, type:

  7. If, after a while, the debugger screen does not come up, check the DSK connections and start from step 6 again.

  8. Press the L key to load. Press the D key to select DSK executable.

  9. Type a:\sawtooth.dsk.

  10. Press the Enter key twice.

  11. Press the X key to execute. Press the G key so the debugger will let the program go without interruption.

  12. Press the "Auto Scale" button on the upper right corner of the oscilloscope control panel, and observe the waveform on the screen.

  13. If the program breaks down after a while, press the R key to reset and you have to load the DSK executable again before you execute the program. You may stop the program anytime by pressing the Esc key.

  14. When the program is not running, you may press the Q key to quit, and press the Y key to confirm.

  15. Please unplug the DSK power and turn off the oscilloscope before you leave the station.

The basic pattern of the above procedure will be used repeatedly in your experiments with the DSK.

Repeat the walkthrough exercise again. This time, connect the RCA output jack to an earphone or a speaker. Is the sound more interesting to listen to than a single tone?

Inside the 'C50 DSP

Familiarize yourself with the TMS320C5x DSP Starter Kit User's Guide. Chapter 6 of the user's guide teach you how to use the DSK debugger. Using the 'C50 DSK Debugger, let's see how the 'C50 DSP work.

  1. Run the debugger and execute the file sawtooth.dsk.

  2. Stop the execution after the sawtooth waveform is generated.

  3. Look at the register window on the right of the debugger screen. Locate the field for PC (Program Counter).

  4. Type XS several times to step through several instructions until the value of PC reads "0a11".

  5. Look at the reverse assembly window on the upper left corner of the debugger screen. Search through the text file sawtooth.asm and find the line begins with the label "LOOP". Compare this line with the first line in the reverse assembly window. Then, compare the three subsequent lines. These four lines are the main loop of our program.

  6. The PC value reads "0a11" which is the address of the first line in the main loop. Type XS again, PC value reads "0a12" and the second line of the main loop is highlighted. This means that the first line has been executed and the DSP is about to execute the second line. Type XS again, we execute the second line and move on to the third line.

  7. The address of the fourth line is "0a14". Single step (Type XS) to the fourth line. What should happen to the PC value if you single step again? Should the PC value read "0a15"? Try it.

  8. The PC value reads "0a11" again. Look at the fourth line again. The mnemonic B stands for the branch instruction. The branch instruction explicitly tells the DSP the line to be excuted next. The flow of the program then branches away from its normal behavior of executing lines one after the other.

  9. Look at the line after line "0a14" in the reverse assembly window. Its address is "0a16" instead of "0a15". The branch instruction actually use the memory assessed as "0a15" to store its operand. The value of the operand stored at "0a15" is "0a11". To what does the address 0a11 correspond? What is the code doing?

  10. This loop and other instructions are stored in the program memory. Every 16 bits forms an instruction word. The program memory is divided into many 16-bit blocks, each with its own address.

  11. Make sure the PC value reads "0a11" again. Locate the ACC field in the register window and read its value. Single step the DSP to execute ADD #80h. Read ACC value again. What happens to it? ACC stands for accumulator, the temporary storage for the results of most DSP operations such as addition and multiplication. In this case, hex number 80h is added to the previous ACC value and the result is stored back into the accumulator. Note that ACC stores a 32-bit number. Why do you think that the accumulator is 32 bits long? Look at Figure 3-12 on page 3-23 in TMS3205x User's Guide (the thick one). Both the data bus and program bus are only 16-bit wide.

  12. Unlike the branch instruction, ADD can carry 8-bit information about its operand. When "#" is used, the 8 bits carry the actual value of the number to be added. Then, it is called short immediate mode. For example, this mode can be used to add +1 or -1 to a number. What is the largest value we can use to replace 80h and still use the short immediate mode?

  13. Now, the PC value should read "0a12". Locate the DXR field in the register window and read its value. Single step the DSP to execute SACL DXR,3. Read DXR value again. What happens to it? DXR stands for data transmit register. The values stored in DXR will eventually be converted to analog signals output from the RCA jack on the DSK. SACL is the mnemonic for "Store Low Accumulator With Shift". Low accumulator means the lower 16 bits of the ACC value. Together with the operands, this instruction tells the DSP to shift the ACC value left three bits and store the lower 16 bits to DXR. Note that the ACC value is not changed by this instruction. Convince yourself that the DXR value is incremented by the value 80h shifted to left by 3 bits.

  14. Read the reverse assembly window again. You cannot find the symbol DXR. Instead, you find the address 21h in its place. Many registers of 'C50 are mapped to the data memory address space, i.e. are assigned specific data memory addresses. The hex number 21h, however, is not a complete address. Read page 3-11 and 3-12 in TMS320C5x User's Guide (the thick one) about direct addressing mode. Check the value of DP in the register window. What is the complete address of the DXR?

  15. Execute the instruction IDLE. This instruction put the DSP to sleep (to save power) until some event wakes it up. Other portion of the sawtooth program has set such event to occur at a 7.7 kHz frequency. Once the DSP wakes up, it moves on to execute the next instruction. What is the highest frequency sinusoid we can generate by writing one sample value to the DXR once every awakening?

Now, you have single-stepped through the main loop of the sawtooth program. Can you explain why the program generate a sawtooth waveform?

Some Simple Fixed Point Arithmetic

'C50 is a fixed point processor. Although we can always implement floating point arithmetic in software, that usually is not performed on a fixed-point processor. Instead, we can rephrase our problems to fit the numbers we can use. 1.414V is the same as 1414mV. Of course, we have to be very careful in tracking what each number represents. When we add two numbers, we want to make sure that they are based on the same scale just like we match the decimal points when we add decimal numbers. Similary, we have to keep track of multiplications. In the following poly.asm example, we will use each 16-bit word to represent a value between -1.0 and 1.0. Each representable value is 2-15 apart from the nearest representable values. When we multiply two words, we should shift the product right 15 bits, so the lower 16-bit of the result reprents a number between -1.0 and 1.0.

Now, read poly.asm to see how we can compute y = a * x + b. Before you run this program on the debugger, you should learn more a few more 'C50 instructions first.

Single-step through the program and see how values are loaded, shifted, multiplied and accumulated. The data memory window on the lower left corner of the debugger screen should display the data memory starting from address 1000h. The result is stored at 1000h when the program enters the infinite loop.

Hint: Storing the higher bits in a 32 bit accumulator into a 16-bit data word is equivalent to a right-shift by 16 bits.

Writeup

  1. What is the period of the sawtooth waveform in terms of the number of samples? Please show your work.

  2. By following the example of poly.asm, write a program to compute y = a * x2 + b * x + c for any set of {a,b,c,x: |x| < 1} such that |y| < 1.
    Please comment your program carefully.


Glossary

ACC
Accumulator register that stores intermediate results
AIC
Analog Interface Circuit that allows analog devices to be connected to the C50 DSK board
ALU
Arithmetic Logic Unit that adds, shifts, and performs logical operations.
C50
Texas Instruments TMS 320C50 DSP processor (16-bit, ?? MHz)
DP
Data Memory Page Pointer that points to the current 128-byte page of data memory
DSK
DSP Starter Kit
DSP
Digital Signal Processor, a special-purpose microprocessor
DXR
Data Transmit Register
I/O
Input/output
RCA
A cable connector standard
SACH
Shift Accumulator and Store High Word Result, a C50 instruction
SACL
Shift Accumulator and Store Low Word Result, a C50 instruction


Tze-yau William Ng Huang
Sun Feb 20 00:00:00 PST 1996