Nothing Special   »   [go: up one dir, main page]

DSP Lab 5 Handout

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

International Islamic University

Islamabad

Digital Signal Processing LAB

Experiment No. 5: Introduction to CCS and DSP Kit

Name: __________________________________________

Roll No.: ________________________________________

Lab conducted on: ________________________________

Report submitted on:______________________________

Marks Obtained: ___________________________________

Remarks: _________________________________________

Instructor’s Signature:_______________________________
Digital Signal Processing LAB

1.1 What is a Microprocessor?


Microprocessor is a silicon chip, designed to perform arithmetic and logic operations through its programs.
Typical microprocessor operations include adding, subtracting, comparing two numbers, and fetching
numbers from one area to another. These operations are the result of a set of instructions that are part of the
microprocessor design. Typical layout of a microprocessor is as in Figure:

In this layout, the Central Processing Unit (CPU) is the basic logical structure that accomplishes instructions
given by the program. Arithmetic Logic Unit (ALU) is the logical structure that accomplishes arithmetic
operations like addition and subtraction. Memory is the structure that the data and the program are stored
in. Common microprocessors do not have very large memory space inside the chip. Therefore, the main
data and program is stored outside the microprocessor. Instruction registers are small memory blocks. They
handle processes that the CPU can execute. The program sets the instruction registers in an order to execute
each process required one at a time. The size of the instruction register defines the bit processing capability
of the microprocessor. For example if the size of the register is 32-bit, then it is a 32-bit processor. Data
registers are small memory blocks used by the CPU to store the data. Data and address busses are the
highways that the data and instructions flow over. They also connect the CPU and the external peripheral
units.
Microprocessors need regulated DC power supply in order to work. Typical processors work with 5V DC
supply. As the silicon technology improves, these devices started working with lower power ratings.
Therefore, nowadays there are processors working with 3.3V, 1.8V or lower DC voltage values.
Clock is the synchronization pulse of the processor. Instructions are executed in one or more clock pulses.
Clock also provides the synchronization between the processing units of the processor. The speed of the
processor is related to the clock pulse. The processor speeds are categorized in Million Instructions per
Second (MIPS). This means how many instructions are processed in a second.
Reset circuitry is the most important part of a microprocessor system. If the microprocessor is locked in an
unexpected infinite loop, the only way to recover the system is to apply reset to the processor. Reset brings
the processor to the initial state that is defined in the reset vector inside processor’s memory.

International Islamic University, Islamabad. 2


Digital Signal Processing LAB

1.2 What is a Microcontroller?


Microprocessors can only perform data manipulation and computation. To interact with the outside world,
there should be some peripherals connected to the microprocessor. Microcontrollers are silicon chips that
contain both the microprocessor and peripherals. Typical layout of a microcontroller is as in Figure:

Microcontrollers may contain all or some of the peripherals according to their usage area. For example, to
process an audio or a video signal, the microcontroller with an Analog to Digital Converter (ADC) and
Digital to Analog Converter (DAC) is needed. Serial Peripheral Interface (SPI), RS232 Serial
Communication Interface (SCI), I2C (two wire communication protocol) or JTAG (A fast real-time
communication protocol) interfaces will be needed to communicate with another processor or computer.
The setup and usage of these peripheral devices are arranged by the control, status, and data registers. For
example, to define the sampling rate of the ADC, the necessary bits in the ADC control register are set.

1.3 What is a Digital Signal Processor (DSP)?


Digital Signal Processor (DSP) is a microcontroller designed specifically for signal processing applications.
This is achieved as follows. Commonly used operations in signal processing applications are convolution,
filtering, and frequency-time domain conversions. These operations need recursive multiplication and
additions. In other words, they need multiply and accumulate (MAC) operations. Standard microprocessors
execute the multiplication operation as a recursive addition operation. This means for a standard
microprocessor, the MAC operation is processed by excessive number of addition operations. This takes
time. However, DSPs contain special MAC units that can execute the same operation in a single machine
cycle. For example, a 150 MIPS DSP can process approximately 32 million data samples per second. For
a standard 150 MIPS microprocessor, this reduces to 2 million data samples per second.
Like microcontrollers, DSPs are equipped with different peripheral devices according to their usage area.
The DSP we are using throughout the book, TMS320C6713, does not contain any ADC or DAC but it
contains SPI and I2C interfaces. Therefore, its development kit, TMS320C6713 DSK, contains an AIC23
codec chip working as an ADC and DAC interface. It communicates with the DSP over the SPI. Typical
layout of a DSP is in Figure:

International Islamic University, Islamabad. 3


Digital Signal Processing LAB

1.4 TMS320C6713 DSP Features


Texas Instrument TMS320C6713 DSP has the following properties:
32 bit instruction cycle.
Typical 225 MHz, up to 300 MHz clock frequency.
2400 MIPS / 1800 MFLOPS instruction processing.
4xALU and 2x32-Bit MAC functional unit.
4KB Level1 program cache, 4KB Level1 data cache, 256KB Level2 data cache.
32 bit external memory interface up to 512 MB addressable external memory space.
2xI2C ports, 2xMCBSP (SPI) ports, 2x32-Bit timers.

1.5 TMS320C6713 Development Kit Features


We will not use the DSP processor alone. Instead, we will use the development kit for the mentioned DSP.
This kit has the following properties:
A Texas Instruments TMS320C6713 DSP operating at 225 MHz
An AIC23 stereo codec.
16 MB synchronous DRAM.
512 KB non-volatile Flash memory (256 KB usable in default configuration).
4 user accessible LEDs and DIP switches
Software board configuration through registers implemented in Complex Programmable Logic
Device (CPLD).
Configurable boot options.
Standard expansion connectors for daughter card usage.
JTAG emulation through on-board JTAG emulator with USB host interface or external emulator.
Single voltage power supply (+5V).
The functional block diagram of the software development kit TMS320C6713 DSK is given in Figure:

International Islamic University, Islamabad. 4


Digital Signal Processing LAB

1.6 The Programming Language and the Number System


We use the C programming language to program the C6713 DSK. Therefore, it is utmost important to have
a basic C programming knowledge. Although it is possible to code the same card with assembly language,
it is not advisable to use it at beginner’s level.
One of the most confusing parts of C programming the C6713 DSK is the number system. TMS320C6000
DSP has several data representations. We provide their properties in Table.
This table is obtained from "TMS320C6000 Optimizing Compiler v 7.0 User's Guide". Please refer to this
document for more and detailed information.

International Islamic University, Islamabad. 5


Digital Signal Processing LAB

1.7 Code Composer Studio V 3.3


The coding platform for DSPs is the Code Composer Studio (CCS). Here we explore CCS V3.3 properties.

1.8 CCS Basic Setup


Code Composer Studio (CCS) is the programming, building, and debugging interface of Texas Instruments
DSPs. CCS communicates with the C6713 DSK board over embedded JTAG interface and can exchange
real-time data with the DSK board. Before starting the CCS V3.3, we have to select the platform that the
CCS will use from the setup interface. To run the setup interface, click on the CCS Setup icon
1. Open CCS using Run as Administrator
2. Select C6713 Simulator (Simulator Mode) or C6713 DSK (Kit Mode) and CONNECT to kit from
DEBUG.

International Islamic University, Islamabad. 6


Digital Signal Processing LAB

After selecting operating mode CCS will restart and following window will appear.

3. Go to PROJECT and click on NEW to create a new project following window will appear.

Fill up this dialog box and click FINISH.


New project has been created in CCS with the name given in recently filled dialog box. Now project can
be seen in CCS. Click on plus (+) sign to see folders and files in selected project. At this stage this is a
blank project with no file in it.
Now different files will be added to the project which will be used by the project to execute required task.
Given figure shows how a blank project window will look like.

International Islamic University, Islamabad. 7


Digital Signal Processing LAB

4. Then go to PROJECT and click on ADD FILES TO THE PROJECT and select C6713dsk.cmd file
(provided with software or easily downloadable from internet).
5. Following same procedure add one more file from “C:\CCStudio_v3.3\C6000\cgtools\lib” named
rts6700.lib
6. Now add source file (programmed in C). To add source file go to FILE click on NEW and then
select SOURCE FILE from the list. Now a window will appear, write your C code in that window
and save source file (e.g. anyname.c).
7. Add this saved source file to the project following same procedure for adding files to the project.

International Islamic University, Islamabad. 8


Digital Signal Processing LAB

8. Now go to PROJECT and click on BUILD. If there are no errors (warnings can be ignored) message
will appear BUILD COMPLETE.
9. This process will create file named “anyname.out” in directory where project was saved. To load
this file Go to FILE then click on LOAD PROGRAM go to DEBUG folder in project’s directory
open file with “.out” extension.
10. This process will load project on to the Simulator/Kit. Now go to DEBUG and click on RUN.
Output of the program can be seen in CCS window.

If you are working on more than one projects or running a project more than once then you should follow
following steps before running
11. Go to DEBUG click on RESET CPU then after resetting CPU go to DEBUG and click on
RESTART and then again go to DEBUG and click on GO MAIN. Now you can run it by clicking
RUN in DEBUG.

2.1 Program to find greatest in three numbers


#include<stdio.h>
int main() {
int a, b, c;
printf("\nEnter value of a, b & c : ");
scanf("%d %d %d", &a, &b, &c);
if ((a > b) && (a > c))
printf("\na is greatest");
if ((b > c) && (b > a))
printf("\nb is greatest");
if ((c > a) && (c > b))
printf("\nc is greatest");
return(0);
}

International Islamic University, Islamabad. 9


Digital Signal Processing LAB

2.2 Program to reverse order of a given number


#include<stdio.h>
int main() {
int num, rem, rev = 0;
printf("\nEnter any no to be reversed : ");
scanf("%d", &num);
while (num >= 1) {
rem = num % 10;
rev = rev * 10 + rem;
num = num / 10;
printf("\ %d ",rev);
}

2.3 Addition of all elements of an array


#include<stdio.h>
int main() {
int i, arr[50], sum, num;
printf("\nEnter no of elements (e.g. 5) :");
scanf("%d", &num);
//Reading values into Array
printf("\nEnter the values (e.g. 1 2 3 4 5 :");
for (i = 0; i < num; i++)
scanf("%d", &arr[i]);
//Computation of total
sum = 0;
for (i = 0; i < num; i++)
sum = sum + arr[i];
//Printing of all elements of array
for (i = 0; i < num; i++)
printf("\na[%d]=%d", i, arr[i]);
//Printing of total
printf("\nSum=%d", sum);
return (0);
}

2.4 Add n Numbers


#include <stdio.h>
int main()
{
int n, sum = 0, c, value;
printf("Enter the number of integers you want to add\n");
scanf("%d", &n);
printf("Enter %d integers\n",n);
for (c = 1; c <= n; c++)
{
scanf("%d",&value);
sum = sum + value;
}

International Islamic University, Islamabad. 10


Digital Signal Processing LAB

printf("Sum of entered integers = %d\n",sum);


return 0;
}

2.5 Convert Decimal to Binary


#include <stdio.h>
int main()
{
int n, c, k;
printf("Enter an integer in decimal number system\n");
scanf("%d", &n);
printf("%d in binary number system is:\n", n);
for (c = 31; c >= 0; c--)
{
k = n >> c;
if (k & 1)
printf("1");
else
printf("0");
}
printf("\n");
return 0;
}

2.6 Adding a watch Window


To see or change the values in variables, you can use the watch window. To add a variable to the watch
window, right-click on the variable and select “Add to watch window”
Note: Only global variables can be added to watch window as in below given example
#include <stdio.h>
int c[5];
void main(void)
{
int a[5]={1,2,3,4,5};
int b[5]={1,2,3,4,5};
int i;
for(i=0;i<5;i++)
{
c[i]=a[i]+b[i];
printf("\n %d",c[i]);
}
}

In the said program c variable has been added to watch list.

International Islamic University, Islamabad. 11


Digital Signal Processing LAB

You can see the values and changes in the watch window at the bottom right of the CCS V3.3 screen.
Following these steps to run this program > Build > Load Program > Run > Following will be the
output.

2.7 Plotting Arrays


To see an array in a graph, go to "View > Graph > Time/Frequency...". On the pop up window, fill:
1. Start Address: Name of the array (to be plotted).
2. Acquisition Buffer Size: Size of the array.
3. Display Data Size: Size of the data to be displayed on the graph.
4. DSP Data Type: Type of the array (integer or float).
5. Sampling Rate: Sampling rate of the signal in the array.

International Islamic University, Islamabad. 12


Digital Signal Processing LAB

2.8 Working with DIP Switches and LEDs


C6713 DSK has four user accessible DIP switches and LEDs. To reach these peripheral devices, you
should include two header files “dsk6713_dip.h” and "dsk6713_led.h" to your code. For the CCS V3.3
you should apply the following procedure to locate these files. Select “Project > Build options >
compiler”. Select the "processor" under the compiler tab. Include "C:\code composer studio setup
folder\C6000\dsk6713\include" to search path, as in Figure

International Islamic University, Islamabad. 13


Digital Signal Processing LAB

You should also add the "dsk6713bsl.lib" file which is under "C:\code composer studio setup folder
\C6000\dsk6713\lib" by “Add Files to Project”
Now, we are ready to reach DIP switches and LEDs on the C6713 DSK. The following code is an
example of DIP switch and LED application.
/***********************************************************/
/* Read the status of the DIP switches and control LEDs*/
/***********************************************************/
/* All header files starting with dsk6713 belong to the board support library
*/
#include<dsk6713.h> /* General functions */
#include<dsk6713_dip.h> /* Functions for DIP */
#include<dsk6713_led.h> /* Functions for LED */
void main()
{
DSK6713_init();
DSK6713_DIP_init();/*Initialize DIP switches */
DSK6713_LED_init(); /*Initialize LEDs*/
while(1){
/*DSK6713_DIP_get(‘switch number’); Retrieve the DIP switch value */
if(DSK6713_DIP_get(1)==1){
/* DSK6713_LED_on(‘LED number’); Set the LED */
DSK6713_LED_on(1);
}else{
/* DSK6713_LED_off(‘LED number’); Clear the LED */
DSK6713_LED_off(1);
}
}
}

2.9 Home Assignment


1. Design and implement a function of C in CCS which computes arithmetic operations (Addition,
Subtraction and multiplication) and display its output. (Note: User should be able to select
arithmetic operation and Function should be able to take input values from user)
2. Create a project in CCS V3.3 (in the simulation mode). Create a new C source code file. Your
code should calculate and save the first 10 elements of the Fibonacci series in an array. Save
and add this file to your project folder. Build and Run your project. Observe the graph of the
Fibonacci array by using the graph property of CCS V3.3.
3. Create a project in CCS V3.3. Include all necessary files to your project. Create a new C source
code file. This code should set the LED on the C6713 DSK board corresponding to the switch
being pressed. Add this file to your project.

International Islamic University, Islamabad. 14

You might also like