Top Banner
2 - 2 - 1 32-Bit-DSP-Microcontroller 32-Bit-DSP-Microcontroller TMS320F2812 TMS320F2812 Module 2 : Program Development Tools
38

2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

Dec 23, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 11

32-Bit-DSP-Microcontroller32-Bit-DSP-MicrocontrollerTMS320F2812TMS320F2812

Module 2 : Program Development Tools

Page 2: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 22

HelpHelp CPU CPU WindowWindow

Memory windowMemory windowGraph Graph windowwindow

Project Manager:Project Manager:Source & object filesSource & object filesFile dependenciesFile dependenciesCompiler, Assembler Compiler, Assembler & Linker build options& Linker build options

Status Status windowwindow

Full C/C++ & Assembly Full C/C++ & Assembly Debugging:Debugging:C & ASM SourceC & ASM SourceMixed modeMixed modeDisassembly (patch)Disassembly (patch)Set Break PointsSet Break PointsSet probe PointsSet probe Points

Watch windowWatch windowProductive Editor:Productive Editor:Structure ExpansionStructure Expansion

Menus or IconsMenus or Icons

Code Composer Studio® IDE

Page 3: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 33

Code Composer Studio

• Code Composer Studio includes:– Integrated Edit/Debug GUI– Code Generation Tools– DSP/BIOS

AsmAsm LinkLink

EditEdit

DebugDebug

CompileCompile Probe InProbe In

Probe OutProbe OutGraphsGraphsProfilingProfiling

SIMSIM

eZdspeZdsp™™

EVMEVM

Third Third PartyParty

XDSXDS

DSPDSPBoardBoard

DSP/BIOSDSP/BIOSConfigConfigToolTool

DSP/BIOSDSP/BIOSLibrariesLibraries

lnk.cmdlnk.cmdBuildBuild

Page 4: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 44

Code Composer Studio: IDE

• Integrates: edit, code generation, and debug

• Single-click access using buttons

• Powerful graphing/profiling tools

• Automated tasks using GEL scripts

• Built-in access to BIOS functions

• Support TI or 3rd party plug-ins

Page 5: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 55

The CCS Project

• 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

Project (.pjt) files contain:Project (.pjt) files contain:

Page 6: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 66

Build Options GUI - Compiler

• 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

Page 7: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 77

Build Options GUI - Linker

• GUI has 2 categories for linking• Specifies various link options• “.\Debug\” indicates on

subfolder level below project (.pjt) location

Page 8: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 88

Default Build Configurations

• Add/Remove your own custom build configurations using Project Configurations

• Edit a configuration:1. Set it active2. Modify build options3. Save project

• For new projects, CCS automatically creates two build configurations:

– Debug (unoptimized)– Release (optimized)

• Use the drop-down menu to quickly select the build configuration

Page 9: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 99

eZdsp™ F2812 Hardware

Parallel Port/Parallel Port/JTAGJTAG

ControllerControllerInterface (P3)Interface (P3)

I/O Interface (P4/P8/P7)I/O Interface (P4/P8/P7)

ANALOGANALOGInterface (P5/P9)Interface (P5/P9)

SRAMSRAM64K x 1664K x 16

JTAG Interface (P1)JTAG Interface (P1) EXPANSIONEXPANSIONData & Address (P2)Data & Address (P2)

PowerPowerConnector (P6)Connector (P6)

+5V+5V

TMS320F2812 - DSP TMS320F2812 - DSP

Page 10: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1010

Connecting the eZdsp to your PC

Code Composer Studio – eZdspCode Composer Studio – eZdsp F2812 Configuration F2812 Configuration

eZdspeZdsp F2812 F2812

25 Conductor Cable25 Conductor Cable

To wall outletTo wall outlet

PowerPowerSupplySupply

25 pin male25 pin maleD-sub connectorD-sub connector(Plugs into parallel(Plugs into parallelport on PC)port on PC)

25 pin male25 pin maleD-sub connectorD-sub connector

25 pin female25 pin femaleD-sub connectorD-sub connector

Page 11: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1111

Lab Experiments - the Peripheral Adapter

eZdspeZdsp F2812 plus Zwickau Adapterboard F2812 plus Zwickau Adapterboard

8 x LED

8 x switch

2 x push- button

2 potentiometers

1 SPI DAC ( TLV 5617 )

1 SPI EEPROM ( M95080)

1 I2C Sensor ( DS 1621)

1 SCI - Transceiver (MAX

232)

1 CAN - Transceiver ( TJA 1054 )

1 CAN - Transceiver ( SN 65HVD230 )

1 Loudspeaker

Page 12: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1212

Learning by doing - Step by Step

Code Composer Studio® - The Basics

1. The Start-up - Window2. Create a F28x - project, based on C language3. Debug your program4. Watch your variables5. Perform a Single Step Debug6. Use Breakpoints7. What is a Probe Point for ?8. Other View Commands9. GEL - General Extension Language

Page 13: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1313

1. The Startup - Window

Working Area

Project-tree

Page 14: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1414

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 plain ASCII-text file and storesall set-ups and options of the project. This is very useful for a versionmanagement.

Page 15: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1515

• Write a C-Source Code :

File New Source File

unsigned int k;void main (void){unsigned int i;while(1)

{ for (i=0;i<100;i++)

k=i*i; }

}

2. Create a F28x - project (cont.)

File Save as : “lab1.c”

Page 16: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1616

2. Create a F28x - project (cont.)

Page 17: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1717

2. Create a F28x - project (cont.)

• Add your file to the project : Project Add files to project– Add: “lab1.c”

• Compile your source code : Project Compile File – active window will be compiled– in the event of syntax errors : modify your source code as needed

• Add the C-runtime-library to your project : Project Build Options Linker Library Search Path :

c:\ti\c2000\cgtools\lib Project Build Options Linker Include Libraries :

rts2800_ml.lib

• Add the stack- size of 0x400 Project Build Options Linker Stack Size : 0x400

Page 18: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1818

2. Create a F28x - project (cont.)

Close the build-window by ‘OK’

Page 19: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 1919

2. Create a F28x - project (cont.)

• Add the Linker - Command File to your project: Project Add Files to Project ..\cmd\EzDSP_RAM_lnk.cmd

• Finally : Build the code ( compile / assemble / link ) : Project Build

Page 20: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2020

Placing Sections in Memory

.ebss.ebss

.cinit.cinit

.text.text

MemoryMemory

M0SARAMM0SARAM(0x400)(0x400)

0x00 00000x00 0000

0x3D 80000x3D 8000

0x00 04000x00 0400 M1SARAMM1SARAM(0x400)(0x400)

FLASHFLASH(0x20000)(0x20000)

SectionsSections

.stack.stack

Page 21: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2121

Linking

LinkerLinker

namename.cmd.cmd

.map.map

.obj.obj .out.out

Memory descriptionMemory description How to place s/w into h/wHow to place s/w into h/w

Memory descriptionMemory description How to place s/w into h/wHow to place s/w into h/w

Page 22: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2222

Linker Command File

MEMORY{ PAGE 0: /* Program Space */ FLASH: org = 0x3D8000, len = 0x20000

PAGE 1: /* Data Space */ M0SARAM: org = 0x000000, len = 0x400 M1SARAM: org = 0x000400, len = 0x400}

SECTIONS{ .text: > FLASH PAGE 0 .ebss: > M0SARAM PAGE 1 .cinit: > FLASH PAGE 0

.stack: > M1SARAM PAGE 1}

Page 23: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2323

2. Create a F28x - project (cont.)

• Load the binary code into the DSP :File Load Program Debug\Lab1.out

– Note: a new binary code can be downloaded automatically into the target. This is done by Option Customize Program Load Options Load Program after Build. This setup will be stored for permanently.

• Run the program until label “main”

Debug Go main

Page 24: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2424

yellow arrow :current PC

2. Create a F28x - project (cont.)

Page 25: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2525

3. Debug your code !

• Perform a real time run : Debug Run (F5)

Note 1: the bottom left corner will be marked as : “DSP Running”. You’ll see no activity on the peripherals of the Adapter Board because our first example program does not use any of them !

Note 2: the yellow arrow is no longer visible – that’s another sign of a real time run.

• Stop the real time run : Debug Halt

• Reset the DSP :Debug Reset CPUDebug Restart

• Run again to main : Debug Go Main

Page 26: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2626

4. Watch your variables

• Open the Watch Window : View Watch Window

• The variable ‘i’ is already visible inside the “Watch Locals”-window .

• To see also the global ‘k’ we need to add this variable manually. This can be done inside window ‘Watch 1’. In the column ‘name’ we just enter ‘k’ and in the second line ‘i’.

– Note : another convenient way is to mark the variables inside the source code with the right mouse button and then select “Add to watch window”

• note : with the column ‘radix’ one can adjust the data format between decimal, hexadecimal, binary etc.

Page 27: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2727

Watch-Window

4. Watch your variables

Page 28: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2828

5. Perform a Single Step Debug

• Perform a single step trough the program : Debug Step Into ( or F8 )

• 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

Page 29: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 2929

Source Single Step

RunHaltRun to cursor

Source Step Over

Step Out

5. Perform a Single Step Debug

Assembly Single Step

Assembly Step Over

Page 30: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3030

6. Adding 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 )

• Reset the Program Debug Reset CPU Debug Restart

• Perform a real time run Debug Run ( or F5)

• DSP stops when reaching an active breakpoint • repeat ‘Run’ and watch your variables• remove the breakpoint ( Toggle again) when you’re done.

Page 31: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3131

Red dot :active

Breakpoint

Yellow arrow :Current PC

Toggle Breakpoint

Remove all Breakpoints

6. Adding a Breakpoint (cont. )

Page 32: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3232

7. Set a Probe Point

• Causes an update of a particular window at a specific point in your program.

• When a window is created it is updated at every breakpoint. However, you can change this so the window is updated only when the program reaches the connected Probe Point. When the window is updated, execution of the program is continued.

• To set a Probe - Point :– Click right mouse on the line ‘k = i*i;’ in the program first.c – select : ‘Toggle Probe Point ‘ ( indicated by a blue dot ) – select Debug Probe Points...– In the Probe Point Window click on the line ‘first.c line 13 -> no Connection’– in the ‘Connect to’ - selector select ‘Watch Window’– exit this dialog with the ‘Replace’ and ‘OK’ - Button

• Run the program and verify that the watch window is updated continuously.

Page 33: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3333

7. Set a Probe Point (cont.)

Page 34: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3434

8. Other View Commands

• The View menu includes more useful windows to monitor and control the DSP

View Registers Core View Registers Status

– click right mouse inside the new windows and select ‘Float in Main Window’

– double click on line ‘ACC’ and modify the value inside the Accumulator ACC

Page 35: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3535

8. Other View Commands (cont.)

• To view both the Assembler code and the C Source Code :

• click right mouse inside “Lab1.c” and select “Mixed Mode”

• The Assembler Instruction Code generated by the Compiler is added and printed in grey colour

• Single Step ( ‘Assembly Step Into’ ) is now possible on instruction level

– Perform : Debug Reset DSP Debug Restart Debug Go Main Debug Step Into (F8)

– You’ll see two arrows , a yellow one on C-lines and a green one for assembler instruction-lines

Page 36: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3636

Current C - line

Current Instruction

8. View C and Disassembly

Page 37: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.

2 - 2 - 3737

9. GEL - General Extension Language

• language similar to C • lets you create functions to extend Code Composer's features• to create GEL functions use the GEL grammar • load GEL-files into Code Composer

• With GEL, you can:– access actual/simulated target memory locations– add options to Code Composer’s GEL menu

• GEL is useful for automated testing and user workspace adjustment .

• GEL - files are ASCII with extension *.gel

Page 38: 2 - 1 32-Bit-DSP-MicrocontrollerTMS320F2812 Module 2 : Program Development Tools.