You are here

Percepio Tracealyzer and PSoC 4200M | Cypress Semiconductor

Percepio Tracealyzer and PSoC 4200M

[re-printed from by Alan Hawse]

As you have probably noticed, I have spent a significant amount of time in the last few months doing FreeRTOS projects.  One thing that I have been continuously frustrated about is a lack of analysis tools.  How much memory am I using?  How much stack and heap are free?  How long are tasks taking?  How do you get the priorities set right?  And on and on.  A couple of weeks ago I got an email from the guys at Percepio asking me if I wanted to try out the Percepio Tracealyzer.  I said yes… but that I was really busy and it was going to take a while for me to get to it.  So now I have… and this is the first article about the Percepio Tracealyzer.  Unfortunately the story involves me burning myself with a soldering iron but I suppose that isn’t their fault.

In this series of article’s I will instrument the FreeRTOS projects that I have been showing you with the Percepio Tracealyzer Recorder Library, then run the tool to see what is going on.  In this specific Article I will show you how to get the most basic Tracelyzer functionality going on a PSoC4200M.

Percepio Tracealyzer

The way that Percepio Tracealzer works is that you install a bit of code into your project called the Tracealyzer Recorder Library.   In streaming mode, the code creates a new task in FreeRTOS called “TzCtrl” which interacts with the FreeRTOS kernel to record all of the running task information into a communication link (e.g UART, SPI, JLINK RTT, etc.)  In snapshot mode, the kernel information is just written to an SRAM buffer inside of the PSoC.

This is the architecture picture from the Percepio website:

Percepio Tracealyzer architecture


Updating CY8CKIT-044 PSoC4200M Development Kit

To make the Percepio Tracealyzer work you need to turn the “Snapshot or streaming” line from the picture above into a real connection.  In snapshot mode there are two ways (I think) that you can do it.

  1. You can stop the processor with the debugger, then write the region of memory with the trace buffer into an “.hex” or a “.bin” file.  Then read that file into Percepio Tracealyzer.  Unfortunately the debugger in PSoC Creator cannot create binary output files of regions of memory like that… so plan 1 is out the window
  2. You can attach a Segger JLINK to the PSoC via SWD.  Then, Tracelyzer knows how to talk to the JLink to read the memory.  This is what I am going to do for this Article.

One feature that is very cool about the Snapshot methodology is that Tracelyzer can search the output file and find the trace buffer.  The trace buffer data structure is marked by something that Tracealyzer can find.

When our very good devkit team team in India built the CY8CKIT-044 (which I have used and written about quite a bit), they installed a built in debugger/programmer called “KitProg“.  But they also understood that someone might want to connect some third part debugger like the JLINK.  So… they put the footprint for a 10-pin Arm debugging port onto the board. (see it in the lower left).  Actually if you look at the board, you can see two 10-pin footprints, the one at the top is connected to the PSoC5 (which serves as the KitProg).

PSoC Pioneer CY8CKIT-044 with footprint for 10-pin debugging header


Before I can use a JLINK I needed to do this … which unfortunately ended with me burning myself with the soldering iron… bad Alan.

PSoC Pioneer CY8CKIT-044 with soldered programming header


Tracealyzer Snapshot Mode on Blinking LED Project

In a previous article I talked about the organization of PSoC Creator projects, specifically how to handle the situation where you want to include .h/.c files into your project but you don’t want to modify them.  This is exactly what I will do with the Percepio Tracelyzer Recorder Library.  The library has some files which I will want to leave intact and I will just make references to them in my project including trcKernelPort.h, trcPortDefines.h etc.  And there are some files which I will want to modify, which I will copy out of the Trace Recorder Library into my project for editing trcConfig.h, trcSnapShotConfig.h and trcStreamingConfig.h

To start the first Percepio Tracelyzer example I will use the basic “Snapshot Mode”.  There is good documentation on the Percepio Tracelyzer documentation website.  I will start by copying the PSoC Creator Workspace from the FreeRTOS articles from GitHub.  It has 9 projects in it, starting with the blinking led, going to a more complicated multi-thread project.  The next step is to download the FreeRTOS Tracelyzer library from the Perceio website into a parallel directory called “TraceRecorder”.

Make a new folder for the non-changing include files called “TraceRecorder” (for the files that I don’t want to change)

Create folder for Percepio Tracealyzer TraceRecorder library in PSoC Creator


Next I will add the files that I don’t want to change to the project so that I can see them (meaning they are just referenced by PSoC Creator)

Open the "Add Existing Item" dialog in PSoC Creator


They reside in the directory TraceRecorder/include

Find the TraceRecorder folder and include the header files


Once I have the unchanging .h’s into my project, I need to add their directory to the include path.  To do this right-click on the project and select “Build Settings …”

PSoC Creator Project Configuration - Add External Files


Then click “Compiler” and then the “…” on the “Additional Include Directories” line

PSoC Creator Project Configuration - Compiler Options


Navigate until you get to TraceRecoder/include then press “Select Folder”

PSoC Creator Project Configuration - Update include path


Now your include path should look like this:

PSoC Creator Project Configuration - Include Path


Next, I want to copy the configuration files in the Windows Explorer to my project directory so that they become a changeable part of they project.  They reside in TraceRecorder/config (I just did a Ctrl-C to copy)

PSoC Creator Project Configuration - Add Trace Recorder Library


You want to paste them into your project directory

PSoC Creator Project Configuration - Add External Files


Then you need to add them to the project so that you can easily edit them by right clicking on the “Header Files” folder and selecting “Add–>Existing Item”

PSoC Creator Project Configuration - Add External Files


Then selecting them out of your project directory.

PSoC Creator Project Configuration - Add External Files


Now we need to add references to all of the .c files.  Start by making a new folder for the c-files called “TraceRecorder”

PSoC Creator Project Configuration - Add TraceRecorder


Then “Add–>Existing Item…”

PSoC Creator Project Configuration - Add External Files


Select the files from the TraceRecorder directory

PSoC Creator Project Configuration - Add TraceRecorder Files


Now your project should look like this

PSoC Creator Project Configuration - Project Configuration


Your project now has all of the necessary body parts so you next will modify the source files.  Start with modifying FreeRTOSConfig.h to include the TraceRecorder Library stuff.

/* Integrates the Tracealyzer recorder with FreeRTOS */
#if ( configUSE_TRACE_FACILITY == 1 )
#include "trcRecorder.h"


Then modify the trcConfig.h so that it has access to all of the CMSIS header files.

* Include of processor header file
* Here you may need to include the header file for your processor. This is
* required at least for the ARM Cortex-M port, that uses the ARM CMSIS API.
* Try that in case of build problems. Otherwise, remove the #error line below.
//#error "Trace Recorder: Please include your processor's header file here and remove this line."
#include <project.h>


Then tell the TraceRecorder that we are using an Arm Cortex-M

* Configuration Macro: TRC_CFG_HARDWARE_PORT
* Specify what hardware port to use (i.e., the "timestamping driver").
* All ARM Cortex-M MCUs are supported by "TRC_HARDWARE_PORT_ARM_Cortex_M".
* This port uses the DWT cycle counter for Cortex-M3/M4/M7 devices, which is
* available on most such devices. In case your device don't have DWT support,
* you will get an error message opening the trace. In that case, you may
* force the recorder to use SysTick timestamping instead, using this define:
* For ARM Cortex-M0/M0+ devices, SysTick mode is used automatically.
* See trcHardwarePort.h for available ports and information on how to
* define your own port, if not already present.


Now, you need to modify the project’s stack and heap size setup

PSoC Creator Project Configuration - Design Wide Resources


The default snapshot buffer is to big to fit into PSoC SRAM, so I change the size to 400 records

* Macro which should be defined as an integer value.
* This defines the capacity of the event buffer, i.e., the number of records
* it may store. Most events use one record (4 byte), although some events
* require multiple 4-byte records. You should adjust this to the amount of RAM
* available in the target system.
* Default value is 1000, which means that 4000 bytes is allocated for the
* event buffer.


Finally modify main to start the Trace Recorder (vTraceEnable on line 40)

int main(void)
    CyGlobalIntEnable; /* Enable global interrupts. */
    /* Create LED task, which will blink the RED LED */
        LED_Task,       /* Task function */
        "LED Blink",    /* Task name (string) */
        200,            /* Task stack, allocated from heap */
        0,              /* No param passed to task function */
        1,              /* Low priority */
        0 );            /* Not using the task handle */
    while(1); // get rid of the stupid warning

Testing the Output

After all of the setup is done you can build and program the development kit.

PSoC Creator - Program Project


Plug in the Segger J-Link

CY8CKIT-044 + Segger JLINK


Start Tracealyzer then setup the J-Link (click on J-Link Settings…)

Percepio Tracealyzer


Select “Select Device…”

Percepio Tracealyzer - JLINK Settings


Filter the list to “cypress” then choose the “CY8C4247xxx” (which is the chip that is on the C8CKIT-044)

Percepio Tracealyzer - JLINK Settings Select Device


Then Select “Jink->Read Trace”

Percepio Tracealyzer - Read Trace


Accept the defaults (this window only is only brought up the first time)

Percepio Tracealyzer - JLINK Memory Region


Then you will end up with a screen like this.  Each stripe of white/gray is 1 second in time.  The yellow line is where the startup occurred.  The red lines are where the “LED Blink” task was running.  This seems to make sense as you get a tiny red line 2x/second (remember in the source code we have a 500ms delay so that makes sense).

Percepio Tracealyzer - Console


Next I press the reset button on the devkit and re-run the trace.  Then I click on the second red line and the window on the right gives me information about that task.  You can see that the task ran for 53uS and took 23uS to start (time taken up in the FreeRTOS scheduler and Percepio Tracealyzer Recorder Library)

Percepio Tracealyzer - Console



Obviously the snapshot mode is limited by the size of the RAM buffer that you allocate but it saves you the hardware resources and timing constraints that are required to stream FreeRTOS data.  In the next several articles I will show you how to:

  • Use Segger JLINK RTT streaming
  • Make a streaming port
  • Use some of the other screens in the Percepio Tracealyzer

As always you can find all of these projects on the IotExpert GitHub site or




chensolo2017_2665226's picture

Nike Air Max Shoes
Nike Air Max Shoes Outlet
Nike Air Max Shoes Online
Cheap Michael Kors Handbags
Cheap Coach Bags
Cheap Coach Bags sale
Coach Handbags Outlet
Cheap Crossbody Bags
Cheap Coach Handbags sale

Colin Cooper's picture

The installment entitled "UNITED STATE Flag", 2016 by cheap moncler outlet Thom Browne, includes 28 special edition jackets created by the stylist with premium products and great information, having the American flag as their usual style, collectively forms a mosaic on one wall surface of the NYC front runner shop

renukachouhan2015_2765426's picture

Engineering as a subject combines mathematics, logic and science to find solutions to our daily life problems. Over the last few decades, engineering as a profession has seen vast expansion.
CGC campus
MBA private college in punjab
MBA with best placement in chandigarh
BBA College in Punjab
BCA college Punjab

renukachouhan2015_2765426's picture

The Fairdeal Group of Companies is a fast-growing group with the ambition of helping people across Kenya build their dream homes and offices.
Furniture in Kenya
Visitors Chairs dealers
Dealers in Recliner Sofa sets
Orthopedic Chairs dealers
Dealers in household accessories

renukachouhan2015_2765426's picture

Today, SRSG has emerged as one of the leading full-service player offering an array of products and services for system integration, broadcast consultancy, IT infrastructure services, maintenance services and digital archiving services for the broadcast industry.
Apple service center Guwahati
Apple product reseller in Kolkata
Apple iphone 7 dealers in mumbai
ipad dealers in Delhi
Mac pro dealers in Guwahati

renukachouhan2015_2765426's picture

DPS are committed to provide our students with a sound knowledge base with emphasis on building strong fundamentals in the principles of education, moral values and strong character and concrete the same by the way of continuous training with psychological methods.
Best School in rajasthan
Best CBSE Boarding School in NCR
Admission in Best CBSE School Rajasthan
Top CBSE boarding school in Rajasthan

renukachouhan2015_2765426's picture

Moonlight Films and Theatre Studio operates under the Moonlight Films and Theatre Society , a non-profit association whose goals are to spread knowledge of and interest in theatrical and media arts through education.
Acting classes in Delhi
Weekend Filmmaking


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.