NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

Profiling on C28x Targets

From Texas Instruments Wiki
Jump to: navigation, search

Introduction[edit]

For a C28x target, profiling data collection is not enabled in Code Composer Studio by default.
This article describes how to enable profiling data collection if desired, and suggests solutions for profiling without using the Code Composer's data collection.

Profiling Data Collection[edit]

Code Composer Studio's profiling data collection is described in this wiki article. This resource is not enabled for the C28x based MCUs by default. This is because most profiling activities on C28x devices are for code in flash. The hardware function profiling is breakpoint based, so it is not very useful for code within flash due to limited hardware breakpoint resources.
If code is based in RAM, then the profiling data collection can be enabled and tried (see Enabling Profile Data Collection at the end of this article). It should be noted that this is not tested on C28x targets and is a use at your own risk feature.

Profiling Solutions for C28x Targets[edit]

Here is a list of other solutions that can be used to profile functions within Code Composer Studio:
Option1 - Profile Clock
The profile clock uses silicon resources to count cycles between two breakpoints.
When using the profile clock in flash, it is important to free-up as many hardware breakpoints as possible. On c28x you have two analysis resources available at one time. One resource can be used as a hardware breakpoint, watchpoint, or counter. The other one can only be used as a hardware breakpoint or watchpoint. In order to profile, you need to use the analysis counter which uses up one of your resources so now you only can set one hardware breakpoint. Code Composer Studio will by default set a breakpoint for C I/O (printf etc) and the end of program marker. When profiling, make sure the following options are unselected so the breakpoints will not be used up by these options:
  1. Program load options:
    • CCS v5: Open tools->Debugger options -> Program/Memory Load options
    • CCS v4: Open tools->Debugger options -> Generic Options

      Debug options.jpg

  2. Under Program/Memory Load: Uncheck "Halt at program termination"
  3. Under Program/Memory Load: Uncheck "Enable C I/O function use"

    Disable default bps.jpg
  4. Optional: Select "Remember my settings" at the bottom of the configuration screen.


To setup the profile clock:


  1. In the debug perspective go to
    • CCS V5: Run -> Clock -> Enable.
    • CCS V4: Target -> Clock -> Enable.

      EnableProfileClock.jpg

      This will add a clock icon and count to the status bar.

      Profile clock.jpg

  2. Run to a breakpoint at the start of the function.
  3. Double click on the clock - this will clear its value.
  4. Run to a breakpoint at the end of the function
  5. The clock will display the delta.
Option 2 - CPU Timer
Another option customers like to use is to start a CPU timer counting at the SYSCLKOUT frequency.
  1. Read the clock before the call
  2. Read the clock after the call
  3. Subtract the two to get a delta
Option 3 - GPIO Pin
Another option is to use a GPIO pin:
  1. Pull the pin low/high before the function
  2. Pull it high/low after the function
  3. Read the delta on a scope

Accessing the Profile Clock via Scripting[edit]

The following script may aid in accessing the profile clock through scripts in CCS 5.x.
  1. Modify the following script for the location of your project and the addresses where breakpoints should be set.
  2. Load the script through the Scripting Console. (click here to learn more)
  3. Loading the script will create a new item in the 'Scripts' menu
Please see the script comments for a description of what it is doing. It should be modified for the project specific symbols.
More information on DSS scripting can be found here:

Profiling in Sys/BIOS[edit]

SYS/BIOS provides a 'Timestamp_get32()' API that can be used to benchmark code. To use this API, you will need to modify your target code to include these APIs. This is similar to the CPU timer method mentioned above.
In your app.cfg:

<syntaxhighlight lang='c'> Timestamp = xdc.useModule('xdc.runtime.Timestamp'); </syntaxhighlight>

In the app.c file:

<syntaxhighlight lang ='c'>

  1. include <xdc/runtime/Timestamp.h>

UInt32 t0, t1;

t0 = Timestamp_get32();

algo();

t1 = Timestamp_get32();

time = t1 - t0; </syntaxhighlight>

The API function Timestamp_getFreq() can be used to get the frequency of the Timestamp counter.

Frequently Asked Questions[edit]

Q: Cycle counts for 'step-by-step' and 'run to line' do not match?[edit]

When single stepping, each instruction goes through the whole pipeline. And then on the next step, the next instruction will go through the whole pipeline, etc. There is no potential for a resource conflict between two instructions since each instruction goes all the way through the pipeline by itself.
If you run or run to line, however, there is the potential for pipeline stalls.
Consider the case where your code is in the same block as data. If you try to read data you can not fetch an opcode at the same time and there will be a stall. Same thing for trying to read and write on the same pipeline cycle.
There are other things that can stall the pipe like CPU register conflicts but these are less obvious to spot.
Refer to this wiki article for more information C28x Pipeline Conflicts.

Enabling Profile Data Collection[edit]

As mentioned previously, this functionality is disabled in Code Composer for the C28x by default. This is because the C28x has limited hardware breakpoints which are required when using this feature in flash. If you are executing from RAM, you may find it useful. Note: function profiling for C28x is not officially supported (untested).
To enable HW function profiling with CCSv4 for C28x:
  1. Browse to <INSTALL DIR>\ccsv4\DebugServer\bin\win32\SerializedProfileActivities
  2. Open 'ProfileFunctionsHW.prof_ini' in a text editor
  3. Under the list of ISA, add 'TMS320C28' to the list
  4. Save file and restart CCSv4
The 'ProfileFunctionsHW.prof_ini' should now look something like:
[Name]
Profile all Functions for CPU Cycles

[Events]
dataclass.pcdt.events.Cycles
dataclass.pcdt.events.CPU Cycles
dataclass.pcdt.events.cycle.Total

[EventClasses]
pcdt

[ISA]
TMS320C28
TMS320C56
TMS320C55
TMS320C621x
TMS320C641x
TMS320C671x
TMS470R1
TMS470R2
TMS470R3
TMS470Rd
TMS470Re

.....

Other Resources[edit]

To discuss technical questions, the E2E Community is a great resource. Visit e2e.ti.com.



Forums on the E2E site include:

and many more...

E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Profiling on C28x Targets here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article Profiling on C28x Targets here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article Profiling on C28x Targets here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article Profiling on C28x Targets here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article Profiling on C28x Targets here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Profiling on C28x Targets here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article Profiling on C28x Targets here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article Profiling on C28x Targets here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Profiling on C28x Targets here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity