TMS320F2812-Program Development Tools
TMS320F2812-Program Development Tools
Introduction
The objective of this module is to understand the basic functions of the Code Composer Studio Integrated Design Environment for the C2000 - Family of Texas Instruments Digital Signal Processors. This involves understanding the basic structure of a project in C and Assembler coded source files, along with the basic operation of the C-Compiler, Assembler and Linker
Status window
Watch window
Graph window
Memory window
2-2
2-1
Module Topics
Module Topics
Program Development Tools .....................................................................................................................2-1 Introduction .............................................................................................................................................2-1 Code Composer Studio IDE.....................................................................................................................2-1 Module Topics..........................................................................................................................................2-2 The Software Flow ...................................................................................................................................2-3 Code Composer Studio - Basics...............................................................................................................2-4 Lab Hardware Setup ................................................................................................................................2-7 Code Composer Studio Step by Step .....................................................................................................2-9 Create a project..................................................................................................................................2-10 Setup Build Options...........................................................................................................................2-12 Linker Command File........................................................................................................................2-13 Download code into DSP ..................................................................................................................2-15 Lab 1: beginners project.......................................................................................................................2-23 Objective ...........................................................................................................................................2-23 Procedure...........................................................................................................................................2-23 Open Files, Create Project File..........................................................................................................2-23
2-2
Asm
Link
Debug EVM
Edit
You can use Code Composer Studio with a Simulator (running on the Host PC) or you can connect a real DSP system and test the software on a real target. For this tutorial, we will rely on the eZdsp (TMS320F2812eZdsp Spectrum Digital Inc.) as our target and some additional hardware. Here the word target means the physical processor we are using, in this case a DSP. The next slides will show you some basic features of Code Composer Studio and the hardware setup for lab exercises that follow.
2-3
Integrates: edit, code generation, Integrates: and debug Single-click access using buttons SinglePowerful graphing/profiling tools Automated tasks using GEL scripts Built-in access to BIOS functions BuiltSupport TI or 3rd party plug-ins plug2-4
The CCS Project Project (.pjt) files contain: (.pjt) Source files (by reference)
Source (C, assembly) Libraries DSP/BIOS configuration Linker command files
Project settings:
Build Options (compiler and assembler) Build configurations DSP/BIOS Linker
2-5
2-4
GUI has 8 pages of categories for code generation tools Controls many aspects of the build process, such as: Optimization level Target device Compiler/assembly/link options
2-6
GUI has 2 categories for linking Specifies various link options .\Debug\ indicates .\ Debug\ on subfolder level below project (.pjt) (.pjt) location
2-7
2-5
2-8
2-6
2-7
To be able to practice with all the peripheral units of the DSP and some real process hardware, weve added an adapter board, which fits underneath the eZdspF2812. The Zwickau Adapter Board provides: 8 LEDs for digital output (GPIO B7B0) 8 switches (GPIO B15B8) and 2 push buttons (GPIO D1, D6) for digital input 2 potentiometers (ADCINA0, ADCINB0) for analog input 1 loudspeaker for analogue output via PWM - Digisound F/PWC04A 1 dual SPI Digital to Analogue Converter (DAC) - Texas Instruments TLV5617A 1 SPI EEPROM 1024 x 8 Bit - ST Microelectronics M95080 1 CAN Transceiver - Texas Instruments SN 65HVD230 (high speed) 1 CAN Transceiver - Philips TJA 1054 (low speed) 1 I2C Temperature Sensor Dallas Semiconductor DS1621 1 SCI-A RS 232 Transceiver Texas Instruments MAX232D 2 dual OpAmps Texas Instruments TLV 2462 analogue inputs
1 SPI EEPROM ( M95080) 8 x switch 1 CAN - Transceiver ( SN 65HVD230 ) 8 x LED 1 CAN - Transceiver ( TJA 1054 )
1 Loudspeaker
2-8
1.
Projecttree
Working Area
2 - 13
The step-by-step approach for Lab1 will show how to do the following: Open Code Composer Studio Create a F28x Project, based on C Compile, Link, Download and Debug this test program Watch Variables Real time run versus single-step test Use Breakpoints and Probe Points Look into essential parts of the DSP during Debug
Before we start to go into the procedure for Lab1, lets discuss the steps using some additional slides:
2-9
Create a project
2. Create a F28x - project
Project New give your project a name : Lab1, select a target and a suitable location of your hard disk:
Note : the project file (Lab1.pjt) is a simple text file (ASCII) and stores all set-ups and options of the project. This is very useful for a version management.
2 - 14
The first task is to create a project. This is quite similar to most of todays design environments with one exception: we have to define the correct target, in our case TMS320C28xx. The project itself generates a subdirectory with the same name as the project. Ask your instructor for the correct location to store your project.
File Save as : lab1.c ( use the same path as for the project, e.g. C:\C28x\Lab1)
2 - 15
2 - 10
Next, write the source code for your first application. The program from the slide above is one of the simplest tasks for a processor. It consists of an endless loop, which counts variable i from 0 to 99, calculates the current product of i * i and stores it temporarily in k. It seems to be an affront to bother a sophisticated Digital Signal Processor with such a simple task! Anyway, we want to gain hands-on experience of this DSP and our simple program is an easy way for us to evaluate the basic commands of Code Composer Studio. Your screen should now look like this:
2 - 16
Your source code file is now stored on the PCs hard disk but it is not yet part of the project. Why does Code Composer Studio not add this file to our project automatically? Answer: If this were an automatic procedure, then all the files that we touch during the design phase of the project would be added to the project, whether we wanted or not. Imagine you open another code file, just to look for a portion of code that you used in the past; this file would become part of your project. To add a file to your project, you will have to use an explicit procedure. This is not only valid for source code files, but also for all other files that we will need to generate the DSPs machine code. The following slide explains the next steps for the lab exercise:
2 - 11
When youve done everything correctly, the build options window should look like this:
2 - 12
2 - 19
2 - 13
0x3D 8000
FLASH (0x20000)
2 - 20
Linking
Memory description Memory description How to place s/w into h/w How to place s/w into h/w
.map
2 - 21
The procedure of linking connects one or more object files (*.obj) into an output file (*.out). This output file contains not only the absolute machine code for the DSP, but also information used to debug, to flash the DSP and for more JTAG based tasks. Do NEVER take the length of this output file as the length of your code! To extract the usage of resources we always use the MAP file (*.map).
2 - 14
Program Space */ 0x3D8000, len = 0x20000 Data Space */ 0x000000, len = 0x400 0x000400, len = 0x400
0 1 0 1
2 - 22
2 - 23
2 - 15
After Debug Go main, a yellow arrow shows the current position of the Program Counter (PC). This register points always the next instruction to be executed.
2 - 24
When we start to test our first program, there is no hardware activity to be seen. Why not? Well, our first program does not use any peripheral units of the DSP. Go through the steps, shown on the next slide.
Note 2:
2 - 16
To watch the programs variables, we can use a dedicated window called the Watch Window. This is probably the most used window during the test phase of a software project.
note : with the column radix one can adjust the data format between decimal, hexadecimal, binary etc.
2 - 26
WatchWindow
2 - 27
2 - 17
Another useful part of a debug session is the ability to debug the code in portions and to run the program for a few instructions. This can be done using a group of singe-step commands:
Watch the current PC ( yellow arrow) and the numerical values of i and k in Watch Window while you single step through the code ! There are more debug - commands available, see next slide
2 - 28
2 - 29
2 - 18
When youd like to run the code through a portion of your program that you have tested before, a Breakpoint is very useful. After the run command, the JTAG debugger stops automatically when it hits a line that is marked with a breakpoint.
6. Add a breakpoint
Set a breakpoint:
Place the Cursor in Lab1.c on line : k = i * i; Click right mouse and select Toggle Breakpoint the line is marked with a red dot ( = active breakpoint ) Note : most Code Composer Studio Commands are also available through buttons or trough Command -Keys ( see manual, or help )
2 - 31
2 - 19
A slightly different tool to stop the execution is a Probe Point. While the Break Point forces the DSP to halt permanently, the Probe Point is only a temporary stop point. During the stop status, the DSP and the JTAG-emulator exchange information. At the end, the DSP resumes the execution of the code.
Run the program and verify that the watch window is updated continuously.
2 - 32
NOTE: There is a more advanced method to interact with the DSP in real time, called Real Time Debug. We will skip this option for the time being and use this feature during later chapters.
2 - 20
2 - 33
When you are more familiar with the F2812 and with the tools, you might want to verify the efficiency of the C compiler or to optimize your code at the Assembler Language level.
2 - 34
2 - 21
Current C - line
Current Instruction
2 - 35
The General Extension Language (GEL) is a high-level script language. Based on a *.gel file one can expand the features of Code Composer Studio or perform recurrent steps automatically.
2 - 22
Save this file by clicking File 3. Add the Source Code Files:
4. Add the C-runtime library to your project by clicking: Project Build OpLinker Library Search Path: c:\ti\c2000\cgtools\lib. Then Add tions Build Options Linker Include Librarthe library by clicking: Project ies: rts2800_ml.lib
2 - 23
5. Verify that in Project Build Options Run-time-Autoinitialisation [-c] 6. Set the stack size to 0x400: Project
Build Options
Test
10. Reset the DSP by clicking on Restart Debug Reset CPU, followed by Debug
11. Run the program until the first line of your C-code by clicking: Debug Go main. Verify that in the working area the source code Lab1.c is highlighted and that the yellow arrow for the current Program Counter is placed on the line void main (void). 12. Perform a real time run by clicking: Debug Run
13. Verify the note at the bottom left corner of the screen: DSP Running to mark a real time run. Because we are doing nothing with peripherals so far, there is no other visible activity. 14. Halt the program by clicking: Debug Halt, reset the DSP (Debug Reset CPU, followed by Debug Restart) and go again until main (Debug Go main) 15. Open the Watch Window to watch your variables. Click: View Watch Window. Look into the window Watch locals. Once you are in main, you
2 - 24 DSP28 - Program Development Tools
should see variable i. Variable k is a global one. To see this variable we have to add it to the window Watch 1. Just enter the name of variable k into the first column Name. Use line 2 to enter variable i as well. Exercise also with the Radix column. 16. Perform a single-step through your program by clicking: Debug (or use function Key F8). Repeat F8 and watch your variables. Step Into
17. Place a Breakpoint in the Lab1.c window at line k = i * i;. Do this by placing the cursor on this line, click right mouse and select: Toggle Breakpoint. The line is marked with a red dot to show an active breakpoint. Perform a realtime run by Debug Run (or F5). The program will stop execution when it reaches the active breakpoint. Remove the breakpoint after this step (click right mouse and Toggle Breakpoint). 18. Set a Probe Point. Click right mouse on the line k=i*i;. Select Toggle Probe Point. A blue dot in front of the line indicates an active Probe-Point. From the menu-bar select Debug Probe Points.... In the dialog window, click on the line Lab1.c line 13 No Connection. Change the connect toselector to Watch Window, click on Replace and OK. Run the program again (F5). You will see that the probe point updates the watch window each time the program passes the probe point. 19. Have a look into the DSP-Registers: View Registers CPU Register and Registers Status Register. Right mouse click inside these windows View and select Float in Main Window. Double click on the line ACC in the CPU-Register and select Edit Register. Modify the value inside the Accumulator. 20. You might want to use the workspace environment in further sessions. For this purpose, it is useful to store the current workspace. To do so, click: File Workspace Save Workspace and save it as Lab1.wks 21. Delete the active probe by clicking on the button Remove all Probe Points, close the project by Clicking Project Close Project and close all open windows that you do not need any further. End of Exercise Lab1
2 - 25
2 - 26