<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tracealyzer &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/tools/tracelyzer/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Thu, 31 Aug 2017 12:24:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://iotexpert.com/wp-content/uploads/2017/01/cropped-Avatar-32x32.jpg</url>
	<title>Tracealyzer &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>FreeRTOS PSoC Template Project</title>
		<link>https://iotexpert.com/freertos-psoc-template-project/</link>
					<comments>https://iotexpert.com/freertos-psoc-template-project/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 31 Aug 2017 12:24:28 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[FreeRTOS]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[PSoC Creator]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=4097</guid>

					<description><![CDATA[Summary In the last article I showed you clever FreeRTOS PSoC Component&#8230; and the talked about some of the issues that I had with it.  In this article I will talk about a self-contained FreeRTOS PSoC Template project that includes everything for FreeRTOS and Tracealyzer all in one project.  My idea was that when I [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last <a href="https://iotexpert.com/2017/08/29/freertos-psoc-component/">article</a> I showed you clever FreeRTOS PSoC Component&#8230; and the talked about some of the issues that I had with it.  In this article I will talk about a self-contained FreeRTOS PSoC Template project that includes everything for FreeRTOS and Tracealyzer all in one project.  My idea was that when I start a new project I will just make a copy of the template project, rename it, then move on.</p>
<p>My FreeRTOS PSoC Template has</p>
<ul>
<li>FreeRTOS with the files in in the same directory (i.e. not referenced externally)</li>
<li>Tracealyzer with the files in the same directory &amp; all of the streamports including RTT and the UART DMA</li>
<li>All of the files organized into PSoC Creator folders</li>
<li>A template main.c</li>
<li>All of the build settings configured</li>
</ul>
<p>This project is checked into <a href="https://github.com/iotexpert/PSoC-FreeRTOS-Template" target="_blank" rel="noopener">GitHub</a> and you can find it git@<span>github.com:iotexpert/PSoC-FreeRTOS-Template.git</span></p>
<h1>Building the FreeRTOS PSoC Template</h1>
<p>I started the process by creating a blank PSoC project called &#8220;FreeRTOS_Template&#8221;.  I then went into the Windows Explorer and copied the entire FreeRTOS source directory into the FreeRTOS PSoC Template Project directory.  Then I copied the Percepio TraceRecorder library into the FreeRTOS PSoC Template project.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM.png"><img fetchpriority="high" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM.png" alt="FreeRTOS PSoC Template Directory Structure" width="660" height="613" class="alignnone wp-image-4099 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM.png 660w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM-600x557.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.23.00-AM-300x279.png 300w" sizes="(max-width: 660px) 100vw, 660px" /></a></p>
<p>By having both of the source directories in my project it isolated this project from changes in the FreeRTOS or the TraceRecorder.  Obviously that is a double edged sword.  The next thing that I did was use the Windows Explorer to copy FreeRTOSConfig.h, trcConfig.h, trcSnapshotConfig.h and trcStreamingConfig.h into the project.   Once all of the files were in my project directory is was time to fix up the PSoC Creator Project.</p>
<p>To do this I created a folder called &#8220;FreeRTOS_Source&#8221; in the &#8220;Header Files&#8221; and &#8220;Source Files&#8221; folders in my template project.  You can do this by right clicking and selecting &#8220;Add-&gt;New Folder&#8221;.  Then I added all of the appropriate .h and .c files from FreeRTOS source directory.  This gives me the following project view:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.29.53-AM.png"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.29.53-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Header Files" width="243" height="296" class="alignnone wp-image-4101 size-full" /></a></p>
<p>And Source Files (notice that I also added heap_4.c which I generally use for memory management)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.30.04-AM.png"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.30.04-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Source Files" width="238" height="219" class="alignnone wp-image-4100 size-full" /></a></p>
<p>Then I add the configuration files FreeRTOSConfig.h, trcConfig.h, trcSnapshotConfig.h, trcStreamingConfig.h and trcStreamingport.h.  Next I do the same thing for the TraceRecorder library which makes my project look like this:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM.png" alt="" width="328" height="526" class="alignnone size-full wp-image-4102" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM.png 328w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.33.16-AM-187x300.png 187w" sizes="auto, (max-width: 328px) 100vw, 328px" /></a></p>
<p>Then I modify the build settings to add the include directories:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM.png" alt="FreeRTOS PSoC Template Build Settings" width="754" height="493" class="alignnone wp-image-4104 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM.png 754w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM-600x392.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.39-AM-300x196.png 300w" sizes="auto, (max-width: 754px) 100vw, 754px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Include Path" width="352" height="311" class="alignnone wp-image-4103 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM.png 352w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.34.49-AM-300x265.png 300w" sizes="auto, (max-width: 352px) 100vw, 352px" /></a></p>
<p>Now you can modify the FreeRTOSConfig.h to include all of the Tracealyzer stuff:</p>
<pre class="start-line:89 lang:c decode:true ">/* A header file that defines trace macro can be included here. */
#if ( configUSE_TRACE_FACILITY == 1 )
#include "trcRecorder.h"
#endif

#endif /* FREERTOS_CONFIG_H */</pre>
<p>Then I setup a new tab in the schematic to contain the DMA UART Streamport.  You can read all about the UART DMA Streamport in this <a href="https://iotexpert.com/2017/08/08/percepio-tracealyzer-a-psoc-dma-streamport/" target="_blank" rel="noopener">article</a>.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM.png" alt="FreeRTOS PSoC Template PSoC Creator Streamport Schematic" width="983" height="1004" class="alignnone wp-image-4105 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM.png 983w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM-600x613.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM-294x300.png 294w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.37.44-AM-768x784.png 768w" sizes="auto, (max-width: 983px) 100vw, 983px" /></a></p>
<p>By putting that part of the stream port on a separate schematic page I can now do a right click and disable the page when I am not using the Tracealyzer streamport.  Disabling a page of the schematic completely removes everything from the build.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM.png" alt="PSoC Creator Schematic Disable Settings" width="329" height="160" class="alignnone wp-image-4106 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM.png 329w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-31-at-7.40.39-AM-300x146.png 300w" sizes="auto, (max-width: 329px) 100vw, 329px" /></a></p>
<p>Next I create files called FreeRTOS_Start.h/.c to put in the startup code:</p>
<pre class="lang:c decode:true ">#include &lt;project.h&gt;
#include "FreeRTOS.h"

extern void xPortPendSVHandler(void);
extern void xPortSysTickHandler(void);
extern void vPortSVCHandler(void);

#define CORTEX_INTERRUPT_BASE          (16)
void FreeRTOS_Start()
{
    /* Handler for Cortex Supervisor Call (SVC, formerly SWI) - address 11 */
    CyIntSetSysVector( CORTEX_INTERRUPT_BASE + SVCall_IRQn,
        (cyisraddress)vPortSVCHandler );
    
    /* Handler for Cortex PendSV Call - address 14 */
	CyIntSetSysVector( CORTEX_INTERRUPT_BASE + PendSV_IRQn,
        (cyisraddress)xPortPendSVHandler );    
    
    /* Handler for Cortex SYSTICK - address 15 */
	CyIntSetSysVector( CORTEX_INTERRUPT_BASE + SysTick_IRQn,
        (cyisraddress)xPortSysTickHandler );
}
</pre>
<p>Finally I make a template main.c that starts everything and has a simple ledTask and instructions for changing Memory Management scheme and the TraceRecorder.</p>
<pre class="lang:c decode:true ">// This template has heap_4.c included in the project.  If you want a 
// different heap scheme then remove heap_4 from the project and add 
// the other scheme from FreeRTOS/Source/portable/memmag

// TraceRecorder
// There are methods
// 1. Snapshot mode
// 2. Streaming UART/DMA
// 3. Streaming JLINK RTT
//
// To use method 1: 
// - in FreeRTOSConfig.h make this line be 1 (currently line 45)
//#define configUSE_TRACE_FACILITY                1
// - in trcConfig.h configure the TRC_CFG_RECORDER 
// #define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
//
// To use method 2:
// - in FreeRTOSConfig.h make this line be 1 (currently line 45)
//#define configUSE_TRACE_FACILITY                1
// - in trcConfig.h configure the TRC_CFG_RECORDER
//#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING
//
// This project currently has the PSoC UART Streaming Port
// add the TraceRecorder/streamports/PSoC_Serial/trcStreamingPort.c to the project
// add the TraceRecorder/streamports/PSoC_Serial/include/trcStreamingPort.h
// add the TraceRecorder/streamports/PSoC_Serial/include to the compiler include directories
// Enable the Trace_DMA schematic sheet and make sure UART pins are assigned correctly
// This port depends on the UART being named UART and the DMA being named "DMA"
//
// To use method 3: JLINK RTT
// Remove the previous streamport files from the project
// Remove the Streamport include path
// add the TraceRecorder/streamports/JLink_RTT/Segger_RTT.c to the project
// add the TraceRecorder/streamports/JLink_RTT/Segger_RTT_Printf.c to the project
// add the TraceRecorder/streamports/JLink_RTT/include/trcStreamingPort.h
// add the TraceRecorder/streamports/JLink_RTT/include/Segger_RTT.h
// add the TraceRecorder/streamports/JLink_RTT/include/Segger_RTT_Conf.h
// add the TraceRecorder/streamports/JLink_RTT/include to the compiler include directories


#include "project.h"
#include "FreeRTOS.h"
#include "timers.h"

// An example Task
void ledTask(void *arg)
{
    (void)arg;
    while(1)
    {
        RED_Write(~RED_Read());
        vTaskDelay(500);  
    }
}

int main(void)
{
    CyGlobalIntEnable;
    FreeRTOS_Start();
    
    #if ( configUSE_TRACE_FACILITY == 1 )
    vTraceEnable(TRC_START);
    #endif
    
    xTaskCreate(ledTask,"LED Task",configMINIMAL_STACK_SIZE,0,1,0);
    vTaskStartScheduler();  // Will never return
    while(1);               // Eliminate compiler warning
}
</pre>
<p>&nbsp;</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Topic</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/02/23/psoc4-freertos-port/" target="_blank" rel="noopener noreferrer">FreeRTOS: A PSoC4 FreeRTOS Port</a></td>
<td >An introduction to making FreeRTOS work on PSoC 4</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/23/freertos-psoc-examples/" target="_blank" rel="noopener noreferrer">FreeRTOS PSoC Examples</a></td>
<td >Using multiple tasks in FreeRTOS</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/25/psoc-freertos-queue-example/" target="_blank" rel="noopener noreferrer">FreeRTOS Queue Example</a></td>
<td >Using a queue to communicate between tasks</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/30/psoc-6-freertos-first-example/" target="_blank" rel="noopener noreferrer">PSoC 6 FreeRTOS - The First Example</a></td>
<td >Booting FreeRTOS on PSoC 6</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/01/psoc-freertos-binary-semaphore/" target="_blank" rel="noopener noreferrer">FreeRTOS Binary Semaphore</a></td>
<td >An first example of a binary semaphore</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/08/psoc-freertos-binary-semaphore-part-2/">FreeRTOS Binary Semaphore (Part 2)</td>
<td >Removing polling in the UART Task</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/20/psoc-freertos-counting-semaphore/" target="_blank" rel="noopener">FreeRTOS Counting Semaphore</a></td>
<td >An example using a counting semaphore</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/22/psoc-freertos-sharing-the-i2c-bus/" target="_blank" rel="noopener">PSoC FreeRTOS</a></td>
<td >Reading I2C Sensors with a shared I2C Bus</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/22/psoc-freertos-task-notify/" target="_blank" rel="noopener">PSoC FreeRTOS Task Notify</a></td>
<td >A light weight scheme to replace Semaphores</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/24/psoc-freertos-task-notification-value/" target="_blank" rel="noopener">PSoC FreeRTOS Task Notification Values</a></td>
<td >A very light weight method to transfer one word of information into a task</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/freertos-psoc-template-project/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>FreeRTOS PSoC Component</title>
		<link>https://iotexpert.com/freertos-psoc-component/</link>
					<comments>https://iotexpert.com/freertos-psoc-component/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 29 Aug 2017 10:00:22 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[FreeRTOS]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=4068</guid>

					<description><![CDATA[Summary This weekend I found myself down a rabbit hole, beating my head on the wall trying to make a USB driver work properly inside of Parallels &#38; Windows 10 on my Mac (which I still don&#8217;t have quite right).  While going through that excruciating process I ended up creating 3-4-5 different FreeRTOS PSoC projects, [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>This weekend I found myself down a rabbit hole, beating my head on the wall trying to make a USB driver work properly inside of Parallels &amp; Windows 10 on my Mac (which I still don&#8217;t have quite right).  While going through that excruciating process I ended up creating 3-4-5 different FreeRTOS PSoC projects, which although not difficult, is still a bit of a pain as it requires 1/2 dozen step.  After reflecting on it a while I decided that I needed something easier.  The obvious thing to do was to build a FreeRTOS PSoC Component, which I did, but eventually abandoned (Ill talk about that process in the next section).  After the component idea was abandoned I decided to just make a template project that could be used to start a FreeRTOS PSoC Project (the next Article).</p>
<p>In this article I will show you:</p>
<ul>
<li>An example project using a clever FreeRTOS PSoC Component that I found on GitHub built by <a href="http://www.e2forlife.com" target="_blank" rel="noopener">E2ForLife</a></li>
<li>A discussion of the implementation details of that FreeRTOS PSoC Component</li>
<li>A discussion of problems with that implementation which lead me to build a template project.</li>
</ul>
<h1>FreeRTOS PSoC Component Example Project</h1>
<p>When I first started looking at FreeRTOS I wasn&#8217;t totally sure where to start.  When I googled FreeRTOS PSoC, one of the first hits was this <a href="https://github.com/e2forlife/PSoC-FreeRTOS" target="_blank" rel="noopener">repo</a> which contains a PSoC Component that was built by &#8220;E2ForLife&#8221;.  I really liked the idea of a component based FreeRTOS implementation, as all you would need to do is place the components&#8230; and then away you go.  The more that I looked at the component the more that I liked what E2ForLife had done.  When I cloned his repo, there was &#8220;nothing&#8221; in it, but it turns out there is another branch called &#8220;Implement-PSoC5&#8221; which makes me think that he was partially done (he hasn&#8217;t been changed since August 2015)</p>
<p>First, his example project.  When you look at the schematic you see a nice looking FreeRTOS PSoC Symbol (obviously E2ForLife draws way better than me).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.07-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.07-AM.png" alt="FreeRTOS PSoC Component" width="696" height="572" class="alignnone wp-image-4072 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.07-AM.png 696w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.07-AM-600x493.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.07-AM-300x247.png 300w" sizes="auto, (max-width: 696px) 100vw, 696px" /></a></p>
<p>When you double click the component you see all of the stuff that is normally in FreeRTOSConfig.h which you can set using the GUI instead of the FreeRTOSConfig.h</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.23-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.23-AM-1024x975.png" alt="FreeRTOS PSoC Component Configuration" width="1024" height="975" class="alignnone wp-image-4071 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.23-AM-1024x975.png 1024w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.23-AM-600x571.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.23-AM-300x286.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.23-AM-768x731.png 768w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-8.20.23-AM.png 1294w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>When you &#8220;Generate Application&#8221; you can see that he setup all of the FreeRTOS files to come into the Generated Source automatically (though with different names)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-9.43.13-AM.png"></a><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-9.43.13-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-9.43.13-AM.png" alt="FreeRTOS PSoC Component API" width="283" height="672" class="alignnone wp-image-4075 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-9.43.13-AM.png 283w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-9.43.13-AM-126x300.png 126w" sizes="auto, (max-width: 283px) 100vw, 283px" /></a></p>
<p>And his FreeRTOS PSoC Component example project is straight forward</p>
<pre class="lang:c decode:true ">#include &lt;project.h&gt;

xTaskHandle redTask;
xTaskHandle blueTask;
xTaskHandle greenTask;

void vRedTask( void* pvParameters);
void vGreenTask( void* pvParameters);
void vBlueTask( void* pvParameters);

int main()
{
    CyGlobalIntEnable; /* Enable global interrupts. */

	xTaskCreate(vRedTask,"red",80,NULL,3,&amp;redTask);
	xTaskCreate(vGreenTask,"green",80,NULL,3,&amp;greenTask);

	FreeRTOS_Start();
	
    for(;;);
}

void vRedTask( void* pvParameters)
{
	for(;;) {
		vTaskDelay( 125/portTICK_RATE_MS );
		RED_Write( ~RED_Read() );
	}
}

void vGreenTask( void* pvParameters)
{
	for(;;) {
		vTaskDelay( 219/portTICK_RATE_MS );
		GREEN_Write( ~GREEN_Read() );
	}
}
</pre>
<p>He built a function called &#8220;FreeRTOS_Start()&#8221; which installs the interrupt vectors then starts up the scheduler.</p>
<pre class="lang:c decode:true ">uint8 FreeRTOS_initVar = 0;

/* ------------------------------------------------------------------------ */
void FreeRTOS_Init( void )
{
    /* Handler for Cortex Supervisor Call (SVC, formerly SWI) - address 11 */
    CyIntSetSysVector( CORTEX_INTERRUPT_BASE + SVCall_IRQn,
        (cyisraddress)vPortSVCHandler );
    
    /* Handler for Cortex PendSV Call - address 14 */
	CyIntSetSysVector( CORTEX_INTERRUPT_BASE + PendSV_IRQn,
        (cyisraddress)xPortPendSVHandler );    
    
    /* Handler for Cortex SYSTICK - address 15 */
	CyIntSetSysVector( CORTEX_INTERRUPT_BASE + SysTick_IRQn,
        (cyisraddress)xPortSysTickHandler );
	
	FreeRTOS_initVar = 1;
}
/* ------------------------------------------------------------------------ */
void FreeRTOS_Enable( void )
{
	/* start the scheduler so the tasks will start executing */
	vTaskStartScheduler();	
}
/* ------------------------------------------------------------------------ */
void FreeRTOS_Start( void )
{
	if (FreeRTOS_initVar == 0) {
		FreeRTOS_Init();
	}
	FreeRTOS_Enable();
	
	/*
	 * After the scheduler starts in Enable(), the code should never get to
	 * this location.
	 */
	for (;;);
}
</pre>
<p>And when you run the FreeRTOS PSoC Component project you get the nice blinking LED (Red and Green)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/IMG_4852.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/IMG_4852-1024x768.jpg" alt="CY8CKIT-042" width="1024" height="768" class="alignnone wp-image-4076 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/08/IMG_4852-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/08/IMG_4852-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/08/IMG_4852-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>FreeRTOS PSoC Component</h1>
<p>After downloading the project, then opening it I first wanted to look at the components.  You can do this by clicking the &#8220;Components&#8221; tab in the workspace explorer.  It looks like he created (or was planning to create) several other components in addition to the &#8220;FreeRTOS&#8221;.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.04.59-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.04.59-AM.png" alt="FreeRTOS PSoC Component" width="367" height="369" class="alignnone wp-image-4082 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.04.59-AM.png 367w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.04.59-AM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.04.59-AM-150x150.png 150w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.04.59-AM-298x300.png 298w" sizes="auto, (max-width: 367px) 100vw, 367px" /></a></p>
<p>When you double click on the &#8220;FreeRTOS_v8_2.cysym&#8221; you will get an editable view of the symbol.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.10.04-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.10.04-AM.png" alt="FreeRTOS PSoC Component Symbol" width="351" height="328" class="alignnone wp-image-4083 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.10.04-AM.png 351w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.10.04-AM-300x280.png 300w" sizes="auto, (max-width: 351px) 100vw, 351px" /></a></p>
<p>When you right click on the blank part of the canvas, PSoC Creator will bring up this menu.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.54-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.54-AM.png" alt="PSoC Creator Configuration " width="191" height="173" class="alignnone wp-image-4084 size-full" /></a></p>
<p>On the properties menu you can configure which tab the component belongs to in the Component Catalog.  In this case he created a tab called &#8220;Community&#8221; which looks like this in the actual Component Catalog.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.14.31-AM.png"></a><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.14.31-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.14.31-AM.png" alt="PSoC Creator Component Catalog" width="276" height="201" class="alignnone wp-image-4086 size-full" /></a></p>
<p>To make that happen he setup the &#8220;Doc.CatalogPlacement&#8221; to be &#8220;Community/Operating System/FreeRTOS&#8221; (on the properties menu)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.09-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.09-AM-1024x687.png" alt="FreeRTOS PSoC Component Parameter Configuration" width="1024" height="687" class="alignnone wp-image-4085 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.09-AM-1024x687.png 1024w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.09-AM-600x402.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.09-AM-300x201.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.09-AM-768x515.png 768w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.11.09-AM.png 1045w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The next thing that he did was add a whole bunch of Symbol Parameters which will let the user change the setup of FreeRTOS. Each  of these parameters show up as an editable field on the component customers (in the schematic).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.29-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.29-AM.png" alt="FreeRTOS PSoC Parameter" width="988" height="656" class="alignnone wp-image-4079 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.29-AM.png 988w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.29-AM-600x398.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.29-AM-300x199.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.29-AM-768x510.png 768w" sizes="auto, (max-width: 988px) 100vw, 988px" /></a></p>
<p>In the picture above you can see that he created two new &#8220;enumerated&#8221; datatypes called &#8220;FreeRTOS_CheckStackOverFlowType&#8221; &#8220;FreeRTOS_MemMangType&#8221;.  In the picture below you can see the legal values for that type.  This lets him restrict the things that the user of the component can select when he places it in his schematic.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.05-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.05-AM.png" alt="FreeRTOS PSoC Component Configuration" width="927" height="590" class="alignnone wp-image-4080 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.05-AM.png 927w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.05-AM-600x382.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.05-AM-300x191.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.03.05-AM-768x489.png 768w" sizes="auto, (max-width: 927px) 100vw, 927px" /></a></p>
<p>Here is what the component looks like when the user actually uses it.  You can see the legal fields (from above) and the legal values for those fields (from above)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.21.36-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.21.36-AM.png" alt="FreeRTOS PSoC Component Configuration" width="781" height="690" class="alignnone wp-image-4087 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.21.36-AM.png 781w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.21.36-AM-600x530.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.21.36-AM-300x265.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-11.21.36-AM-768x679.png 768w" sizes="auto, (max-width: 781px) 100vw, 781px" /></a></p>
<p>The next thing that he did was copy all of the FreeRTOS files into component API.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-12.32.09-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-12.32.09-PM.png" alt="FreeRTOS PSoC Component API" width="304" height="574" class="alignnone wp-image-4090 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-12.32.09-PM.png 304w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-28-at-12.32.09-PM-159x300.png 159w" sizes="auto, (max-width: 304px) 100vw, 304px" /></a></p>
<p>If you remember each FreeRTOS project needs to have a file called &#8220;FreeRTOSConfig.h&#8221;.  But, that file doesn&#8217;t appear to exist in the list above.  How is that?  Remember that when PSoC Creator builds a project it copies the API into your generated source directory, but it renames each of the files to be INSTANCE_NAME_filename.  In this example, &#8220;Config.h&#8221; will become &#8220;FreeRTOS_Config.h&#8221; (FreeRTOS is the instance name in the schematic)</p>
<p>In FreeRTOS each of the features of the RTOS turn into a #define that is 0 or 1.  When the component was created he modified &#8220;Config.h&#8221; so that each of the parameters on the component set values for the #defines in the &#8220;Config.h&#8221; file.  And there is a bunch of them so that must have taken a good bit of work.  Here is an example of a section of his &#8220;Config.h&#8221;.  Each place you see the back-tick $parameter back-tick PSoC Creator will substitute the value of the parameter (I am typing back-tick because WordPress interprets the actual symbol to mean something special and I don&#8217;t know how to get it into the text)</p>
<pre class="lang:c decode:true ">#if CY_PSOC4
    
    /* Port-dependent settings - not user-editable */
    #define configCPU_CLOCK_HZ          ( ( unsigned long ) CYDEV_BCLK__SYSCLK__HZ )
        
    /* Application settings - user editable */
    #define configMAX_PRIORITIES		( `$MAX_PRIORITIES` )
    #define configTOTAL_HEAP_SIZE		( `$TOTAL_HEAP_SIZE` )
    
#elif CY_PSOC5
    
    /* Device settings - not user-editable */
    #define configCPU_CLOCK_HZ			( ( unsigned long ) BCLK__BUS_CLK__HZ )
        
    /* Application settings - user editable */
    #define configMAX_PRIORITIES        ( `$MAX_PRIORITIES` )
    #define configTOTAL_HEAP_SIZE		( `$TOTAL_HEAP_SIZE` ) 
    
#else
    
    #error "This FreeRTOSConfig.h file is for PSoC 4 and PSoC 5LP devices only"
    
#endif

#define configUSE_PREEMPTION			`$USE_PREEMPTION`
#define configUSE_IDLE_HOOK				`$USE_IDLE_HOOK`
#define configUSE_TICK_HOOK				`$USE_TICK_HOOK`
#define configTICK_RATE_HZ				( ( portTickType ) `$TICK_RATE_HZ` )</pre>
<p>Because each filename changes name, he had to go fix all of the #includes to look like this example from croutine.c (this was a bunch of work)</p>
<pre class="lang:c decode:true ">/* PSoC Component Customizations */

#include "`$INSTANCE_NAME`.h"
#include "`$INSTANCE_NAME`_task.h"
#include "`$INSTANCE_NAME`_croutine.h"</pre>
<p>He also wanted to be able to have all of the <a href="http://www.freertos.org/a00111.html" target="_blank" rel="noopener">FreeRTOS memory management schemes</a> included in the project at one time.  To solve this problem he put an #if around all of the code in heap_1, heap_2 &#8230; that adds and removes the appropriate memory manager.</p>
<pre class="lang:c decode:true ">#if (`$MemManager` == 2)

.
.
.
.
.

#endif</pre>
<h1>A FreeRTOS PSoC Template Project</h1>
<p>When I started working on FreeRTOS I knew that I wanted to use V9.0.  But the component was setup for V8.2.  So I launched into the process of converting the component.  This turned out to be a colossal pain in the ass because of the massive number of &#8220;small&#8221; changes.  In addition I didn&#8217;t really like having to change the names of key files (even the stupidly named semphr.h).  Moreover, the source code as a component debate was raging wildly inside of Cypress and in general is on the way out.  So I decided to implement this as a template project instead of a component.</p>
<p>All that being said, what <a href="http://www.e2forlife.com" target="_blank" rel="noopener">E2ForLife</a> did I continue to think was really clever.</p>
<p><span><p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Topic</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/02/23/psoc4-freertos-port/" target="_blank" rel="noopener noreferrer">FreeRTOS: A PSoC4 FreeRTOS Port</a></td>
<td >An introduction to making FreeRTOS work on PSoC 4</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/23/freertos-psoc-examples/" target="_blank" rel="noopener noreferrer">FreeRTOS PSoC Examples</a></td>
<td >Using multiple tasks in FreeRTOS</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/25/psoc-freertos-queue-example/" target="_blank" rel="noopener noreferrer">FreeRTOS Queue Example</a></td>
<td >Using a queue to communicate between tasks</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/05/30/psoc-6-freertos-first-example/" target="_blank" rel="noopener noreferrer">PSoC 6 FreeRTOS - The First Example</a></td>
<td >Booting FreeRTOS on PSoC 6</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/01/psoc-freertos-binary-semaphore/" target="_blank" rel="noopener noreferrer">FreeRTOS Binary Semaphore</a></td>
<td >An first example of a binary semaphore</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/08/psoc-freertos-binary-semaphore-part-2/">FreeRTOS Binary Semaphore (Part 2)</td>
<td >Removing polling in the UART Task</a></td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/20/psoc-freertos-counting-semaphore/" target="_blank" rel="noopener">FreeRTOS Counting Semaphore</a></td>
<td >An example using a counting semaphore</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/06/22/psoc-freertos-sharing-the-i2c-bus/" target="_blank" rel="noopener">PSoC FreeRTOS</a></td>
<td >Reading I2C Sensors with a shared I2C Bus</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/22/psoc-freertos-task-notify/" target="_blank" rel="noopener">PSoC FreeRTOS Task Notify</a></td>
<td >A light weight scheme to replace Semaphores</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/24/psoc-freertos-task-notification-value/" target="_blank" rel="noopener">PSoC FreeRTOS Task Notification Values</a></td>
<td >A very light weight method to transfer one word of information into a task</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/freertos-psoc-component/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Percepio Tracealyzer &#8211; Running on PSoC6</title>
		<link>https://iotexpert.com/percepio-tracealyzer-on-psoc6/</link>
					<comments>https://iotexpert.com/percepio-tracealyzer-on-psoc6/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 15 Aug 2017 09:40:59 +0000</pubDate>
				<category><![CDATA[CY8CKIT-062-BLE]]></category>
		<category><![CDATA[PSoC 6]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3989</guid>

					<description><![CDATA[Summary I have been having an excellent experience with Percepio Tracealyzer on PSoC4, so now, the next question is, &#8220;Will it work on PSoC6?&#8221;  The answer is yes, but it takes a few gyrations.  In the next two Articles I will show you how to use Tracealyzer on PSoC6 with: JLINK and Snapshot mode JLINK [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>I have been having an excellent experience with <a href="https://percepio.com/tz/" target="_blank" rel="noopener">Percepio Tracealyzer</a> on PSoC4, so now, the next question is, &#8220;Will it work on PSoC6?&#8221;  The answer is yes, but it takes a few gyrations.  In the next two Articles I will show you how to use Tracealyzer on PSoC6 with:</p>
<ol>
<li>JLINK and Snapshot mode</li>
<li>JLINK and Segger RTT in Streaming Mode</li>
<li>A PSoC6 DMA &#8211;&gt; UART Streaming Mode</li>
</ol>
<p>In order to make these work you need to</p>
<ol>
<li>Make a new project and integrate the Trace Recorder Library</li>
<li>Modify trcConfig.h</li>
<li>Install the JLINK</li>
<li>Build the project &amp; test</li>
</ol>
<h1>Create a new PSoC6 project &amp; Integrate the Trace Recorder Library</h1>
<p>The process of integrating the TraceRecorder library is very similar to PSoC 4.  You need to add the include directories into your project.  Right click the project and pick &#8220;Build Settings&#8230;&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.59-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.59-AM.png" alt="" width="431" height="553" class="alignnone size-full wp-image-4003" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.59-AM.png 431w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.59-AM-234x300.png 234w" sizes="auto, (max-width: 431px) 100vw, 431px" /></a></p>
<p>Click on the &#8220;Additional Include Directories&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.20-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.20-AM.png" alt="" width="785" height="682" class="alignnone size-large wp-image-4004" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.20-AM.png 785w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.20-AM-600x521.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.20-AM-300x261.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.20-AM-768x667.png 768w" sizes="auto, (max-width: 785px) 100vw, 785px" /></a></p>
<p>Then add the two TraceRecorder include directory and the StreamPort include directory.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.04-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.04-AM.png" alt="" width="354" height="314" class="alignnone size-large wp-image-4005" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.04-AM.png 354w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.21.04-AM-300x266.png 300w" sizes="auto, (max-width: 354px) 100vw, 354px" /></a></p>
<p>Next you should copy the configuration header files into your project so that you can edit them.  You can copy-paste them in Windows Explorer from &#8220;TraceRecorder/config&#8221; into your project</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.29.53-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.29.53-AM.png" alt="" width="949" height="743" class="alignnone size-full wp-image-4007" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.29.53-AM.png 949w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.29.53-AM-600x470.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.29.53-AM-300x235.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.29.53-AM-768x601.png 768w" sizes="auto, (max-width: 949px) 100vw, 949px" /></a></p>
<p>Next add the TraceRecoder .c and .h files into your project by right clicking &#8220;Add &#8211;&gt;Existing Item..&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.27.54-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.27.54-AM.png" alt="" width="450" height="247" class="alignnone size-full wp-image-4006" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.27.54-AM.png 450w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.27.54-AM-300x165.png 300w" sizes="auto, (max-width: 450px) 100vw, 450px" /></a></p>
<p>You need the .c and .h files from</p>
<ul>
<li>yourproject/{trcConfig.h, trcSnapshotConfig.h, trcStreamingConfig.h}</li>
<li>TraceRecorder/*.c</li>
<li>TraceRecorder/include/*.h</li>
<li>TraceRecorder/streamports/Jlink_RTT/include/*.h</li>
<li>TraceRecorder/streamports/Jlink_RTT/*.c</li>
</ul>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-12.50.29-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-12.50.29-PM.png" alt="" width="864" height="736" class="alignnone size-full wp-image-4015" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-12.50.29-PM.png 864w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-12.50.29-PM-600x511.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-12.50.29-PM-300x256.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-12.50.29-PM-768x654.png 768w" sizes="auto, (max-width: 864px) 100vw, 864px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.45-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.45-AM.png" alt="" width="729" height="471" class="alignnone size-full wp-image-4009" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.45-AM.png 729w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.45-AM-600x388.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.45-AM-300x194.png 300w" sizes="auto, (max-width: 729px) 100vw, 729px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.37-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.37-AM.png" alt="" width="727" height="466" class="alignnone size-large wp-image-4012" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.37-AM.png 727w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.37-AM-600x385.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.37-AM-300x192.png 300w" sizes="auto, (max-width: 727px) 100vw, 727px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.15-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.15-AM.png" alt="" width="724" height="468" class="alignnone size-large wp-image-4010" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.15-AM.png 724w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.15-AM-600x388.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.41.15-AM-300x194.png 300w" sizes="auto, (max-width: 724px) 100vw, 724px" /></a> <a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.56-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.56-AM.png" alt="" width="725" height="468" class="alignnone size-large wp-image-4011" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.56-AM.png 725w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.56-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.56-AM-300x194.png 300w" sizes="auto, (max-width: 725px) 100vw, 725px" /></a>  <a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.21-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.21-AM.png" alt="" width="732" height="468" class="alignnone size-large wp-image-4013" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.21-AM.png 732w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.21-AM-600x384.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-13-at-11.40.21-AM-300x192.png 300w" sizes="auto, (max-width: 732px) 100vw, 732px" /></a></p>
<h1>Modify FreeRTOSConfig.h &amp; trcConfig.h</h1>
<p>The next step is to modify FreeRTOSConfig.h to include the trace recorder header.   Copy this block of code into the bottom for FreeRTOSConfig.h</p>
<pre class="start-line:207 lang:c decode:true">#if ( configUSE_TRACE_FACILITY == 1 )
#include "trcRecorder.h"
#endif
</pre>
<p>Update the FreeRTOSConfig.h to turn on tracing.</p>
<pre class="start-line:121 lang:c decode:true ">#define configUSE_TRACE_FACILITY                1</pre>
<p>Then modify trcConfig.h to include the CMSIS Core headers.</p>
<pre class="start-line:57 lang:c decode:true">/******************************************************************************
 * 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 "cy8c6347bzi_bld53.h"</pre>
<p>The first time that I did this, I tried just #include &lt;project.h&gt; but if you do that you will end up with hundreds of errors and hours and hours of trying to figure out what is going on.  It turns out that the FreeRTOS is picky about the order in which files are included.  And when PSoC Creator makes the project.h it assumes that the order of includes doesn&#8217;t matter.  I fixed this by just including the &#8220;cy8c6347bzi_bld53.h&#8221; header which just? has the CMSIS files.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-3.40.38-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-3.40.38-PM-1024x238.png" alt="" width="1024" height="238" class="alignnone size-large wp-image-3991" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-3.40.38-PM-1024x238.png 1024w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-3.40.38-PM-600x139.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-3.40.38-PM-300x70.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-3.40.38-PM-768x178.png 768w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-3.40.38-PM.png 1176w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After fixing that mess, I modify the trcConfig to specify that I am using a Cortex-M processor (actually two of them)</p>
<pre class="start-line:67 EnlighterJSRAW" data-enlighter-language="c" ">/*******************************************************************************
 * 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:
 *
 * #define TRC_CFG_ARM_CM_USE_SYSTICK
 *
 * 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.
 ******************************************************************************/
//#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_ARM_Cortex_M</pre>
<p>Ill start the project just using Snapshot mode</p>
<pre class="start-line:87 EnlighterJSRAW" data-enlighter-language="c"">/*******************************************************************************
 * Configuration Macro: TRC_CFG_RECORDER_MODE
 *
 * Specify what recording mode to use. Snapshot means that the data is saved in
 * an internal RAM buffer, for later upload. Streaming means that the data is
 * transferred continuously to the host PC. 
 *
 * For more information, see http://percepio.com/2016/10/05/rtos-tracing/
 * and the Tracealyzer User Manual.
 *
 * Values:
 * TRC_RECORDER_MODE_SNAPSHOT
 * TRC_RECORDER_MODE_STREAMING
 ******************************************************************************/
#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
//#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING</pre>
<p>To start the testing I created a really simple, single task blinked led program in main_cm4.c. The only thing that you have to add is the &#8220;vTraceEnable(TRC_START)&#8221; to turn on the TraceRecorder.</p>
<pre class="lang:c decode:true">#include "project.h"

void ledTask(void *arg)
{
    (void)arg;
    while(1)
    {
        Cy_GPIO_Inv(RED_PORT,RED_NUM);
        vTaskDelay(500);
    }
}

int main(void)
{
    __enable_irq(); /* Enable global interrupts. */

    vTraceEnable(TRC_START);
    xTaskCreate(ledTask,"LED Task",configMINIMAL_STACK_SIZE,0,1,0);
    vTaskStartScheduler();
}</pre>
<h1>Testing Percepio Tracealyzer</h1>
<p>To start with I setup snapshot mode.  I wasn&#8217;t sure exactly what the memory map was for the new PSoC6.  But I did know that PSoC Creator copied in a linker file (actually 3 linker files) and that if I looked in the file I would find the memory map.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.12.18-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.12.18-PM.png" alt="" width="344" height="433" class="alignnone size-full wp-image-3996" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.12.18-PM.png 344w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.12.18-PM-238x300.png 238w" sizes="auto, (max-width: 344px) 100vw, 344px" /></a></p>
<p>When I opened the GCC linker file &#8220;cy8c6xx7_cm4_dual.ld&#8221; I found the memory map for the chip.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">MEMORY
{
    flash       (rx)    : ORIGIN = 0x10080000, LENGTH = 0x80000
    wflash            (rx)    : ORIGIN = 0x14000000, LENGTH = 0x8000          /*  32 KB */
    sflash_user_data  (rx)    : ORIGIN = 0x16000800, LENGTH = 0x800
    sflash_nar        (rx)    : ORIGIN = 0x16001A00, LENGTH = 0x200
    sflash_public_key (rx)    : ORIGIN = 0x16005A00, LENGTH = 0xC00
    sflash_toc_2      (rx)    : ORIGIN = 0x16007C00, LENGTH = 0x400
    xip               (rx)    : ORIGIN = 0x18000000, LENGTH = 0x8000000       /* 128 MB */
    efuse             (r)     : ORIGIN = 0x90700000, LENGTH = 0x100000        /*   1 MB */
    ram   (rwx) : ORIGIN = 0x08024000, LENGTH = 0x23800
}</pre>
<p>To make read the Percepio Tracealyzer snapshot you need to select &#8220;JLink -&gt; Read Trace (Snapshot)&#8221;.  When you do that, it asks you where the RAM is on that device.  I simply copy from the linker file the start and length of the RAM</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.03.07-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.03.07-PM.png" alt="" width="309" height="180" class="alignnone size-full wp-image-3994" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.03.07-PM.png 309w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.03.07-PM-300x175.png 300w" sizes="auto, (max-width: 309px) 100vw, 309px" /></a></p>
<p>After that I get the trace.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.07.05-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.07.05-PM.png" alt="" width="807" height="757" class="alignnone size-full wp-image-3999" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.07.05-PM.png 807w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.07.05-PM-600x563.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.07.05-PM-300x281.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.07.05-PM-768x720.png 768w" sizes="auto, (max-width: 807px) 100vw, 807px" /></a></p>
<p>The next thing to do is modify the trcConfig.h to switch to streaming mode:</p>
<pre class="start-line:87 EnlighterJSRAW" data-enlighter-language="c"">/*******************************************************************************
 * Configuration Macro: TRC_CFG_RECORDER_MODE
 *
 * Specify what recording mode to use. Snapshot means that the data is saved in
 * an internal RAM buffer, for later upload. Streaming means that the data is
 * transferred continuously to the host PC. 
 *
 * For more information, see http://percepio.com/2016/10/05/rtos-tracing/
 * and the Tracealyzer User Manual.
 *
 * Values:
 * TRC_RECORDER_MODE_SNAPSHOT
 * TRC_RECORDER_MODE_STREAMING
 ******************************************************************************/
//#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING</pre>
<p>After I reprogram my CY8CKIT-062 BLE, then &#8220;File-&gt;Connect to Target System&#8221; I end up with a nice stream of data.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.20.38-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.20.38-PM.png" alt="" width="586" height="302" class="alignnone size-large wp-image-4001" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.20.38-PM.png 586w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.20.38-PM-300x155.png 300w" sizes="auto, (max-width: 586px) 100vw, 586px" /></a></p>
<p>And when I look at the stream it says that things are working just as expected.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.21.14-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.21.14-PM.png" alt="" width="802" height="758" class="alignnone size-full wp-image-4000" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.21.14-PM.png 802w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.21.14-PM-600x567.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.21.14-PM-300x284.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-12-at-4.21.14-PM-768x726.png 768w" sizes="auto, (max-width: 802px) 100vw, 802px" /></a></p>
<p>Im not sure what its next.  Maybe I will make a DMA/UART version so as not to require the JLKINK.</p>
<p><span><p>As always you can find all of these projects on the <a href="https://github.com/iotexpert/PSoC-Tracelyzer" target="_blank" rel="noopener">IotExpert GitHub</a> site or git@github.com:iotexpert/PSoC-Tracelyzer.git</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Article</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/07/18/percepio-tracelyzer-psoc-4200m/">Percepio Tracealyzer &amp; PSoC</a></td>
<td >An Introduction to Percepio Tracealyzer on the Cypress PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/07/25/perception-tracelyzer-rtt-streamport-psoc4200m/">Percepio Tracealyzer RTT Streamport - PSoC4200M</a></td>
<td >Make the JLINK RTT Library work with Tracealyzer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/01/percepio-tracelyzer-psoc-uart-streamport/">Percepio Tracealyzer PSoC UART Streamport</a></td>
<td >Creating a UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/03/psoc-tracelyzer-streampoint/">Percepio Tracealyzer - Analyzing the PSoC Tracealyzer Streamport</a></td>
<td >Figure out what is broken in the UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/08/percepio-tracelyzer-a-psoc-dma-streamport/">Percepio Tracealyzer - Using PSoC DMA to Fix the UART Streamport</a></td>
<td >Implementing PSoC DMA to improve the CPU Utilization</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/15/percepio-tracealyzer-on-psoc6/">Percepio Tracealyzer - Running on PSoC6</a></td>
<td >Porting the Percepio Tracealyzer to PSoC6</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/percepio-tracealyzer-on-psoc6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Percepio Tracealyzer: A PSoC DMA Streamport</title>
		<link>https://iotexpert.com/percepio-tracealyzer-a-psoc-dma-streamport/</link>
					<comments>https://iotexpert.com/percepio-tracealyzer-a-psoc-dma-streamport/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 08 Aug 2017 10:00:04 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3961</guid>

					<description><![CDATA[Summary In the last Article I analyzed the performance problems of my firmware based PSoC Tracealyzer Streamport &#8230; which was terrible.  Although it has been a long time since I used the PSoC4M DMA engine, I knew that it would solve my problem.  In this article Ill show how to use the PSoC DMA, then [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last <a href="https://iotexpert.com/2017/08/03/psoc-tracelyzer-streampoint/" target="_blank" rel="noopener">Article</a> I analyzed the performance problems of my firmware based PSoC <a href="https://percepio.com/tz/freertostrace/" target="_blank" rel="noopener">Tracealyzer</a> Streamport &#8230; which was terrible.  Although it has been a long time since I used the <a href="http://www.cypress.com/documentation/datasheets/psocr-4-psoc-4200m-family-datasheet-programmable-system-chip-psocr-ja" target="_blank" rel="noopener">PSoC4M</a> DMA engine, I knew that it would solve my problem.  In this article Ill show how to use the PSoC <a href="http://www.cypress.com/documentation/component-datasheets/direct-memory-access-dma" target="_blank" rel="noopener">DMA</a>, then Ill build and analyze a PSoC DMA Streamport for Tracealyzer.</p>
<h1>PSoC4 UART DMA</h1>
<p>The DMA block that shows up in the PSoC4200M, PSoC 4200L and PSoC4BLE is pretty amazing.  It can do a bunch of stuff.  Here is a snapshot that I took out of the <a href="http://www.cypress.com/file/159196/download" target="_blank" rel="noopener">TRM</a>.  This block sits on the main AHB bus inside of the PSoC.  It can act as a master (see the block that says Master I/F) and read and write any of things in the ARM address space including the Flash, SRAM, and all of the peripherals.  It has an incoming trigger which can get the transfers going and when it is done it can trigger an interrupt or another DMA channel.  The Slave I/F allows the CPU to program the block.  The device has 8-channels with each channel having 2 descriptors (so it can ping pong).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.06.25-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.06.25-AM-1024x574.png" alt="PSoC4 DMA" width="1024" height="574" class="alignnone wp-image-3972 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.06.25-AM-1024x574.png 1024w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.06.25-AM-600x336.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.06.25-AM-300x168.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.06.25-AM-768x430.png 768w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.06.25-AM.png 1342w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Before I tried to make the PSoC DMA Streamport I started by looking at the example projects by pressing &#8220;File-&gt;Code Example&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.38.52-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.38.52-AM.png" alt="PSoC Creator Example" width="201" height="398" class="alignnone wp-image-3974 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.38.52-AM.png 201w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.38.52-AM-152x300.png 152w" sizes="auto, (max-width: 201px) 100vw, 201px" /></a></p>
<p>Then filtering for DMA</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.39.17-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.39.17-AM.png" alt="PSoC Creator Example Project - DMA" width="635" height="476" class="alignnone wp-image-3973 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.39.17-AM.png 635w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.39.17-AM-600x450.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.39.17-AM-300x225.png 300w" sizes="auto, (max-width: 635px) 100vw, 635px" /></a></p>
<p>Finally creating project.  This project uses two DMA channels, one for the UART receive and one for the UART Transfer.  It lets you type characters into the UART, it saves them in one of the RAM buffers, then when you have typed 8, it DMAs them back into the Transmit channel of the UART.  This example ping-pings back and forth between two RAM buffers.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.41.07-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.41.07-AM.png" alt="PSoC Creator DMA Example" width="883" height="671" class="alignnone wp-image-3975 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.41.07-AM.png 883w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.41.07-AM-600x456.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.41.07-AM-300x228.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.41.07-AM-768x584.png 768w" sizes="auto, (max-width: 883px) 100vw, 883px" /></a></p>
<p>I decided that it would be best to build a bare metal DMA project called &#8220;test-uart&#8221; to prove that I understood.  This project will DMA transfer an array of characters to the UART when the user presses the switch on the board or a &#8220;s&#8221; on the keyboard.  The first thing to do is build the schematic with a UART, a DMA block,  two output pins, and input pin and an interrupt.</p>
<h1><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.48.55-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.48.55-AM.png" alt="PSoC DMA Streamport" width="579" height="434" class="alignnone wp-image-3969 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.48.55-AM.png 579w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.48.55-AM-300x225.png 300w" sizes="auto, (max-width: 579px) 100vw, 579px" /></a></h1>
<p>Place an SCB UART. then configure it (change the name, but accept all of the defaults)</p>
<h1><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.10-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.10-AM.png" alt="PSoC Creator UART" width="776" height="761" class="alignnone wp-image-3968 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.10-AM.png 776w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.10-AM-600x588.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.10-AM-300x294.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.10-AM-768x753.png 768w" sizes="auto, (max-width: 776px) 100vw, 776px" /></a></h1>
<p>Then click on the advanced tab.  Turn on the DMA for Transfer (TX Output) and set the &#8220;FIFO Level&#8221; to 7.  This will cause the UART to assert DMA signal anytime the transmit FIFO has less than 7 bytes.  In  other words &#8230; FEED ME!!!</p>
<h1><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.30-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.30-AM.png" alt="" width="778" height="770" class="alignnone size-large wp-image-3967" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.30-AM.png 778w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.30-AM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.30-AM-600x594.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.30-AM-300x297.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.49.30-AM-768x760.png 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></a></h1>
<p>After configuring the UART, Set the PINs</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.02.09-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.02.09-AM.png" alt="PSoC DMA Streamport Pin Assignment" width="952" height="615" class="alignnone wp-image-3971 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.02.09-AM.png 952w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.02.09-AM-600x388.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.02.09-AM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.02.09-AM-768x496.png 768w" sizes="auto, (max-width: 952px) 100vw, 952px" /></a></p>
<p>Next configure the DMA.  The memory array that I have will be &#8220;uint8_t&#8221; aka &#8220;char&#8221;.  So the input needs to be &#8220;bytes&#8221;.  The UART FIFO hold Words&#8230; aka 4 bytes.  So I need to configure the transfers to do &#8220;Byte to Word&#8221;.  After the DMA transfer is done, I setup the DMA to create an interrupt (so that I can reset everything in the CPU) and to invalidate the descriptor.</p>
<h1><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.51.43-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.51.43-AM.png" alt="PSoC DMA Streamport" width="633" height="473" class="alignnone wp-image-3966 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.51.43-AM.png 633w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.51.43-AM-600x448.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-8.51.43-AM-300x224.png 300w" sizes="auto, (max-width: 633px) 100vw, 633px" /></a></h1>
<p>In the firmware works by</p>
<ul>
<li>Turning on the UART</li>
<li>Enabling the DMA</li>
<li>Setting up the channel with the address of the buffer that I am going to write to (aka the TX FIFO) and asking for an interrupt</li>
</ul>
<p>Then looping:</p>
<ul>
<li>When the User presses &#8220;s&#8221; or the switch, I set myFlag to be 1.</li>
<li>If it is 1 and the channel is inactive, then initialize the &#8220;source&#8221; address, setup the number of transfer elements to be the number in my array, validate the descriptor, and turn on the channel.</li>
</ul>
<p>When the channel turns on, the Tx fifo will be empty so it will assert the Tx Out, which will make the DMA keep triggering and copying 1 byte at a time into the FIFO.  While this is happening, the UART will try to empty the fifo by sending the bytes.  Finally when the DMA reaches the end of the RAM buffer, it will stop, and at some point the TX FIFO will finish emptying.  The DMA will trigger the interrupt to toggle the BLUE LED.  And the whole process can start again.</p>
<pre class="lang:c decode:true ">#include "project.h"
#include &lt;stdio.h&gt;

// A flag to trigger the DMA
volatile int myFlag=0;
  
static const char myArray[]="asdf1234asdfadsfasdfadsfqwerasdfqwerqwer9\n";

CY_ISR(sw_handler)
{
    myFlag = 1;
    SW_ClearInterrupt();
}

// This is called TWICE at the end of the DMA transaction
CY_ISR(myDMA)
{
    BLUE_Write(~BLUE_Read());
}
int main(void)
{
    CyIntEnable(CYDMA_INTR_NUMBER);
    CyGlobalIntEnable; /* Enable global interrupts. */

    char c;
    
    UART_Start();
    UART_UartPutString("Started\n");
  
    isr_1_StartEx(sw_handler);
  
    CyDmaEnable();
    
    DMA_Init();
    DMA_SetDstAddress(0, (void *)UART_TX_FIFO_WR_PTR);
    DMA_SetInterruptCallback(myDMA);

    while(1)
    {
        c = UART_UartGetChar();
        switch(c)
        {       
            case 's':
                myFlag = 1;
            break;
        }
        
        // This turns on the DMA so that the string will go to the UART.
        if(myFlag &amp;&amp; CyDmaGetActiveChannels() == 0)
        {
            DMA_SetSrcAddress(0, (void *)myArray);
            DMA_SetNumDataElements(0,strlen(myArray)-1);
            DMA_ValidateDescriptor(0);
            DMA_ChEnable();
            myFlag=0;
        }
    }
}
</pre>
<h1>PSoC DMA Streamport</h1>
<p>Now that I understand how to use the DMA, I can create the PSoC DMA Streamport by copying the project &#8220;1-BlionkingLED_UART_TRACE&#8221; project and calling it &#8220;1-BlinkingLED_UART_TRCE_DMA&#8221;.  Next, add the DMA and modify the UART.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.58.55-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.58.55-AM.png" alt="PSoC DMA Streamport" width="383" height="270" class="alignnone wp-image-3980 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.58.55-AM.png 383w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.58.55-AM-300x211.png 300w" sizes="auto, (max-width: 383px) 100vw, 383px" /></a></p>
<p>Configure the UART</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.06-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.06-AM.png" alt="PSoC DMA Streamport - UART Configuration" width="777" height="764" class="alignnone wp-image-3979 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.06-AM.png 777w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.06-AM-600x590.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.06-AM-300x295.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.06-AM-768x755.png 768w" sizes="auto, (max-width: 777px) 100vw, 777px" /></a></p>
<p>Turn on the UART DMA and set the level to 7</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.15-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.15-AM.png" alt="" width="779" height="771" class="alignnone size-large wp-image-3978" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.15-AM.png 779w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.15-AM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.15-AM-600x594.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.15-AM-300x297.png 300w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.15-AM-768x760.png 768w" sizes="auto, (max-width: 779px) 100vw, 779px" /></a></p>
<p>Configure the DMA Block</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.26-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.26-AM.png" alt="PSoC DMA Streamport Configuration" width="629" height="472" class="alignnone wp-image-3977 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.26-AM.png 629w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.26-AM-600x450.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.26-AM-300x225.png 300w" sizes="auto, (max-width: 629px) 100vw, 629px" /></a></p>
<p>Make byte transfers and byte &#8211;&gt; word.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.34-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.34-AM.png" alt="PSoC DMA Streamport - DMA Configuration" width="628" height="472" class="alignnone wp-image-3976 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.34-AM.png 628w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.34-AM-600x451.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-9.59.34-AM-300x225.png 300w" sizes="auto, (max-width: 628px) 100vw, 628px" /></a></p>
<p>Finally modify the trcStreamingPort.c &#8211; AKA the PSoC DMA Streamport file.  Specifically you need to fix up the PSoC_Transmit to send out the data when the TraceRecorder buffer is full.</p>
<ul>
<li>If the DMA is busy&#8230; then wait until the previous transaction is done.</li>
<li>Then setup the DMA and let it rip.</li>
</ul>
<pre class="start-line:23 lang:c decode:true">int32_t PSoC_Transmit(void* data, uint32_t size, int32_t *numOfBytesSent )
{
    
    while( CyDmaGetActiveChannels()&amp; DMA_CHANNEL_MASK);
    DMA_SetSrcAddress(0, (void *)data);
    DMA_SetNumDataElements(0,size);
    DMA_ValidateDescriptor(0);
    DMA_ChEnable();

    *numOfBytesSent=size;
    
    return 0; // Doesnt matter what you return... i dont think that it is checked
}
</pre>
<p>The only other thing that needs to happen is configure the DMA in main.c</p>
<pre class="start-line:44 lang:c decode:true " title="main.c">    CyDmaEnable();
    DMA_Init();
    DMA_SetDstAddress(0, (void *)UART_TX_FIFO_WR_PTR);
</pre>
<h1>Testing the PSoC DMA Streamport</h1>
<p>Now when I startup the Tracealyzer, here is what I get:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-11.17.40-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-11.17.40-AM.png" alt="PSoC DMA Streamport - New CPU Load" width="691" height="321" class="alignnone wp-image-3983 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-11.17.40-AM.png 691w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-11.17.40-AM-600x279.png 600w, https://iotexpert.com/wp-content/uploads/2017/08/Screen-Shot-2017-08-05-at-11.17.40-AM-300x139.png 300w" sizes="auto, (max-width: 691px) 100vw, 691px" /></a></p>
<p>It looks like I solved my problem because that is way way better than:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM.png" alt="PSoC DMA Streamport - Terrible Performance" width="596" height="359" class="alignnone wp-image-3925 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM.png 596w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM-300x181.png 300w" sizes="auto, (max-width: 596px) 100vw, 596px" /></a></p>
<p><span><p>As always you can find all of these projects on the <a href="https://github.com/iotexpert/PSoC-Tracelyzer" target="_blank" rel="noopener">IotExpert GitHub</a> site or git@github.com:iotexpert/PSoC-Tracelyzer.git</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Article</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/07/18/percepio-tracelyzer-psoc-4200m/">Percepio Tracealyzer &amp; PSoC</a></td>
<td >An Introduction to Percepio Tracealyzer on the Cypress PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/07/25/perception-tracelyzer-rtt-streamport-psoc4200m/">Percepio Tracealyzer RTT Streamport - PSoC4200M</a></td>
<td >Make the JLINK RTT Library work with Tracealyzer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/01/percepio-tracelyzer-psoc-uart-streamport/">Percepio Tracealyzer PSoC UART Streamport</a></td>
<td >Creating a UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/03/psoc-tracelyzer-streampoint/">Percepio Tracealyzer - Analyzing the PSoC Tracealyzer Streamport</a></td>
<td >Figure out what is broken in the UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/08/percepio-tracelyzer-a-psoc-dma-streamport/">Percepio Tracealyzer - Using PSoC DMA to Fix the UART Streamport</a></td>
<td >Implementing PSoC DMA to improve the CPU Utilization</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/15/percepio-tracealyzer-on-psoc6/">Percepio Tracealyzer - Running on PSoC6</a></td>
<td >Porting the Percepio Tracealyzer to PSoC6</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/percepio-tracealyzer-a-psoc-dma-streamport/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Percepio Tracealyzer &#8211; Analyzing the PSoC Tracealyzer Streamport</title>
		<link>https://iotexpert.com/psoc-tracealyzer-streampoint/</link>
					<comments>https://iotexpert.com/psoc-tracealyzer-streampoint/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Thu, 03 Aug 2017 10:00:37 +0000</pubDate>
				<category><![CDATA[FreeRTOS]]></category>
		<category><![CDATA[Saleae Logic]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3945</guid>

					<description><![CDATA[Summary In the previous article I showed you how to make a PSoC Tracealyzer Streamport using the SCB based UART on a PSoC 4200M.  It didn&#8217;t take long for me to realize that 115200 baud was not going to cut it.   That realization lead me to figure out that the KitProg on the CY8CKIT-044 [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the previous article I showed you how to make a PSoC Tracealyzer Streamport using the SCB based UART on a PSoC 4200M.  It didn&#8217;t take long for me to realize that 115200 baud was not going to cut it.   That realization lead me to figure out that the KitProg on the CY8CKIT-044 was limited to 115200, which I worked around by using the Cypress USB Serial Bridge that I got from the CY8CKIT-049.  But when I look at the CPU graph I found out that it took 50% of the CPU to support streaming the data.  So now what?  In this Article lets analyze the data, both old school with a logic analyzer, and new school with PSoC Tracealyzer.</p>
<h1>Analyzing the PSoC Tracealyzer Data</h1>
<p>While I was capturing the streaming data from PSoC Tracealyzer I could see that the CPU was burning about 50% of the time just running the TzCntrl and blinking LED thread.  That isn&#8217;t good.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.19.43-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.19.43-PM.png" alt="PSoC Tracelyzer" width="597" height="332" class="alignnone wp-image-3923 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.19.43-PM.png 597w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.19.43-PM-300x167.png 300w" sizes="auto, (max-width: 597px) 100vw, 597px" /></a></p>
<p>When you look at the PSoC Tracealyzer trace viewing you can see the problem is the TzCtrl task.  This task is running for 83 milliseconds and using 57.6% of the CPU.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM.png" alt="PSoC Tracelyzer - analyzing the CPU Usage" width="778" height="849" class="alignnone wp-image-3922 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM.png 778w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM-600x655.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM-275x300.png 275w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM-768x838.png 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></a></p>
<p>If you look at the data transmit function called &#8220;PSoC_Transmit&#8221;, there isn&#8217;t much going on.  Just a call to UART_SpiUartPutArray.  But if you look at the UART documentation you will find that SpiUartPutArray is a blocking function, meaning it doesn&#8217;t return until it is done.  If you calculate the time to transfer a block of 1024 bytes at 8bits/byte and 230400 baud you will find that just sending the data takes 35ms.</p>
<pre class="start-line:25 lang:c decode:true">int32_t PSoC_Transmit(void* data, uint32_t size, int32_t *numOfBytesSent )
{
    timing_Write(1);
    UART_SpiUartPutArray((uint8_t *)data,size);
    *numOfBytesSent=size;
    timing_Write(0);
    return 0; // Doesnt matter what you return... i dont think that it is checked
}</pre>
<p>I was not very sure why the task was taking 83 milliseconds to run when the data transfer was only taking 40ms.  To figure this out I added a toggle pin to the data write routine, just to make sure.  What I found is the data write routine is getting called about every 70ms takes ~30ms to run.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.28.03-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.28.03-PM.png" alt="Old school with Salae Logic" width="764" height="143" class="alignnone wp-image-3947 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.28.03-PM.png 764w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.28.03-PM-600x112.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.28.03-PM-300x56.png 300w" sizes="auto, (max-width: 764px) 100vw, 764px" /></a></p>
<p>How is that possible, the calculation says that it should take 35ms.  It turns out that I configured the UART to have a 64 byte buffer.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.33.30-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.33.30-PM.png" alt="PSoC Creator SCB Configuration" width="497" height="195" class="alignnone wp-image-3948 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.33.30-PM.png 497w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-12.33.30-PM-300x118.png 300w" sizes="auto, (max-width: 497px) 100vw, 497px" /></a></p>
<p>When you remove the 64 bytes from the calculation you end up with 32ish milliseconds.  The other thing that this chart shows is that the TzCntrl task is calling the PSoC_Transmit function more frequently that I thought, at least twice per cycle.  You can also see from the plot that function is taking 30/70=42.8% of the CPU by itself.  Not good, but we are starting to understand what is going on.</p>
<p>As I typed this part of the Article I realized that toggling a GPIO probably wasn&#8217;t the best way to figure out what was happening.  In fact, that is the whole point of Tracealyzer, that is analyzing the performance of your program.  When I looked at the Tracealyzer documentation (I always hate doing that), I found a nice function called vTracePrintf.  I added a &#8220;toggle&#8221; aka printing a 0 and printing a 1 into trace channel 0.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">int32_t PSoC_Transmit(void* data, uint32_t size, int32_t *numOfBytesSent )
{
    timing_Write(1);
    vTracePrintF(0,"1");
    UART_SpiUartPutArray((uint8_t *)data,size);
    vTracePrintF(0,"0");
    timing_Write(0);
    *numOfBytesSent=size;
    
    return 0; // Doesnt matter what you return... i dont think that it is checked
}</pre>
<p>After running another trace, look what I get.  You can see the &#8220;1&#8221; printing at the start and the 0 printing at the end.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.13-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.13-PM.png" alt="PSoC Tracelyzer - Analyzing the CPU Usage with vTaskPrintF" width="640" height="822" class="alignnone wp-image-3952 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.13-PM.png 640w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.13-PM-600x771.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.13-PM-234x300.png 234w" sizes="auto, (max-width: 640px) 100vw, 640px" /></a></p>
<p>Even better, when I double clicked on the &#8220;[Default Channel] 0&#8221; it took me to this nice screen which shows when the events occurred.  The one that I clicked on started at 8.136.039 and ended at 8.176.176, in other words it took about 40ms</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.45-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.45-PM.png" alt="PSoC Tracelyzer - User Events from Tracelyzer" width="634" height="454" class="alignnone wp-image-3951 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.45-PM.png 634w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.45-PM-600x430.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.19.45-PM-300x215.png 300w" sizes="auto, (max-width: 634px) 100vw, 634px" /></a></p>
<p>After hand calculating the time, I realized that once again I should have done something even more obvious, let the ARM calculate the time.  the vTracePrintf will let you specify the output format, in this case a %d</p>
<pre class="start-line:26 EnlighterJSRAW" data-enlighter-language="c" ">int32_t PSoC_Transmit(void* data, uint32_t size, int32_t *numOfBytesSent )
{
    TickType_t time;
    
    timing_Write(1);
    
    time = xTaskGetTickCount();
    UART_SpiUartPutArray((uint8_t *)data,size);
    time = xTaskGetTickCount() - time;
    vTracePrintF(0,"%d",time);
    timing_Write(0);
    *numOfBytesSent=size;
    
    return 0; // Doesnt matter what you return... i dont think that it is checked
}</pre>
<p>When you look at the trace, you need to click on the &#8220;User Events&#8221; to see the print outs from the trace.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.33.32-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.33.32-PM.png" alt="PSoC Tracelyzer - CPU Usage" width="694" height="908" class="alignnone wp-image-3955 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.33.32-PM.png 694w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.33.32-PM-600x785.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-30-at-1.33.32-PM-229x300.png 229w" sizes="auto, (max-width: 694px) 100vw, 694px" /></a></p>
<p>Now that we have a pretty good feel for what is going on, how do we fix it?  Simple, use the PSoC DMA take the CPU mostly out of the UART transmission path, which is the topic of the next Article.</p>
<p><span><p>As always you can find all of these projects on the <a href="https://github.com/iotexpert/PSoC-Tracelyzer" target="_blank" rel="noopener">IotExpert GitHub</a> site or git@github.com:iotexpert/PSoC-Tracelyzer.git</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Article</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/07/18/percepio-tracelyzer-psoc-4200m/">Percepio Tracealyzer &amp; PSoC</a></td>
<td >An Introduction to Percepio Tracealyzer on the Cypress PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/07/25/perception-tracelyzer-rtt-streamport-psoc4200m/">Percepio Tracealyzer RTT Streamport - PSoC4200M</a></td>
<td >Make the JLINK RTT Library work with Tracealyzer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/01/percepio-tracelyzer-psoc-uart-streamport/">Percepio Tracealyzer PSoC UART Streamport</a></td>
<td >Creating a UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/03/psoc-tracelyzer-streampoint/">Percepio Tracealyzer - Analyzing the PSoC Tracealyzer Streamport</a></td>
<td >Figure out what is broken in the UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/08/percepio-tracelyzer-a-psoc-dma-streamport/">Percepio Tracealyzer - Using PSoC DMA to Fix the UART Streamport</a></td>
<td >Implementing PSoC DMA to improve the CPU Utilization</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/15/percepio-tracealyzer-on-psoc6/">Percepio Tracealyzer - Running on PSoC6</a></td>
<td >Porting the Percepio Tracealyzer to PSoC6</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/psoc-tracealyzer-streampoint/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Percepio Tracealyzer PSoC UART Streamport</title>
		<link>https://iotexpert.com/percepio-tracealyzer-psoc-uart-streamport/</link>
					<comments>https://iotexpert.com/percepio-tracealyzer-psoc-uart-streamport/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 01 Aug 2017 10:20:35 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3920</guid>

					<description><![CDATA[Summary In the last Article I showed you how to use the JLINK RTT Streamport to make Tracealyzer work.  When I did that port I didn&#8217;t really like having to use a JLink, it seemed like a pain to have another box.  I knew that it was possible to make a UART based Streamport.  So, [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last <a href="https://iotexpert.com/2017/07/25/perception-tracelyzer-rtt-streamport-psoc4200m/" target="_blank" rel="noopener">Article</a> I showed you how to use the JLINK RTT Streamport to make <a href="https://percepio.com/tz/" target="_blank" rel="noopener">Tracealyzer</a> work.  When I did that port I didn&#8217;t really like having to use a JLink, it seemed like a pain to have another box.  I knew that it was possible to make a UART based Streamport.  So, that is what I am going to do, create a Tracealyzer PSoC Streamport.  This Article is going to be broken up into two parts.  In Part 1 I will show you a software based port and the problems that it creates.  In Part 2 I will show you how to use DMA to hopefully (as I haven&#8217;t done the work yet) make it work much better.  I was hoping this morning when I started working on this Article that it would only take me a couple of hours, but that did not turn out to be the case as I ran into a PSoC Creator bug which made it hard to figure out what was going on.</p>
<h1>Cypress USB Serial Bridge &amp; CY8CKIT-049</h1>
<p>If you remember from the last article, the Tracealyzer needs to stream about 20KBs.  That is a big B as in Bytes.  Which means that a 115200 Kbs (aka 14.4 KBs) UART probably won&#8217;t do the trick.  That is OK as the PSoC SCB UART can run at up to 921600 aka 115.2 KBs.  The problem is the Kitprog bridge on my development kit is limited to 115200 (I&#8217;m not sure why)  I didn&#8217;t realize that limitation this morning when I started working on this problem.  But it turns out that the <a href="http://www.cypress.com/documentation/development-kitsboards/psoc-4-cy8ckit-049-4xxx-prototyping-kits" target="_blank" rel="noopener">CY8CKIT-049</a> has a Cypress <a href="http://www.cypress.com/products/usb-serial-bridge-controller" target="_blank" rel="noopener">USB Serial Bridge.</a>which is used to boatload the PSoC4200.  And&#8230; it is designed to break off the kit.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/CY8CKit-049_full_img.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/CY8CKit-049_full_img.jpg" alt="CY8CKIT-049" width="942" height="250" class="alignnone wp-image-3928 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/CY8CKit-049_full_img.jpg 942w, https://iotexpert.com/wp-content/uploads/2017/07/CY8CKit-049_full_img-600x159.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/07/CY8CKit-049_full_img-300x80.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/07/CY8CKit-049_full_img-768x204.jpg 768w" sizes="auto, (max-width: 942px) 100vw, 942px" /></a></p>
<p>So I broke it off and gave it to my lab assistant to solder (he isn&#8217;t normally that grumpy, but he stayed up all night at a birthday party)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4689-2.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4689-2-768x1024.jpg" alt="Nicholas the Lab Tech" width="768" height="1024" class="alignnone wp-image-3929 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4689-2-768x1024.jpg 768w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4689-2-600x800.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4689-2-225x300.jpg 225w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4689-2-scaled.jpg 1920w" sizes="auto, (max-width: 768px) 100vw, 768px" /></a></p>
<p>Now I have two wires which I can use to talk to the CY8CKIT-044 UART.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4686.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4686-e1501358940465-1024x768.jpg" alt="Cypress USB Serial Bridge" width="1024" height="768" class="alignnone wp-image-3926 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4686-e1501358940465-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4686-e1501358940465-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4686-e1501358940465-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4686-e1501358940465-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After I got the wires on the bridge, I installed the USB Serial Configuration Utility and set the chip up to be 921600 baud.  To do this, run the utility.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.39-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.39-PM.png" alt="USB Serial Configuration Utility" width="524" height="526" class="alignnone wp-image-3933 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.39-PM.png 524w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.39-PM-300x300.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.39-PM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.39-PM-150x150.png 150w" sizes="auto, (max-width: 524px) 100vw, 524px" /></a></p>
<p>Connect to your bridge, in this case the CY7C65211-24LTXI</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.49-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.49-PM.png" alt="USB Serial Configuration Utility" width="518" height="496" class="alignnone wp-image-3932 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.49-PM.png 518w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.10.49-PM-300x287.png 300w" sizes="auto, (max-width: 518px) 100vw, 518px" /></a></p>
<p>Then pick the SCB (which stands for Serial Communication Block)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.12-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.12-PM.png" alt="USB Serial Configuration Utility" width="523" height="525" class="alignnone wp-image-3931 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.12-PM.png 523w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.12-PM-300x300.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.12-PM-100x100.png 100w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.12-PM-150x150.png 150w" sizes="auto, (max-width: 523px) 100vw, 523px" /></a></p>
<p>Click the configure, then set the baud to 921600.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.32-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.32-PM.png" alt="USB Serial Configuration Utility" width="448" height="348" class="alignnone wp-image-3930 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.32-PM.png 448w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-4.11.32-PM-300x233.png 300w" sizes="auto, (max-width: 448px) 100vw, 448px" /></a></p>
<p>Now, I wire the two kits together (the Jlink is just sitting there)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4685.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4685-1024x768.jpg" alt="Percepio Tracelyzer PSoC Setup" width="1024" height="768" class="alignnone wp-image-3927 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4685-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4685-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4685-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4685-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Creating a Tracealyzer PSoC UART Streamport</h1>
<p>The first thing to do is modify the previous project to also have a UART.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.51.36-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.51.36-PM.png" alt="PSoC Creator" width="986" height="763" class="alignnone wp-image-3935 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.51.36-PM.png 986w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.51.36-PM-600x464.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.51.36-PM-300x232.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.51.36-PM-768x594.png 768w" sizes="auto, (max-width: 986px) 100vw, 986px" /></a></p>
<p>Then connect the UART to Pins P3[0] &amp; P3[1]</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.52.58-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.52.58-PM.png" alt="PSoC Creator" width="433" height="130" class="alignnone wp-image-3936 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.52.58-PM.png 433w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-5.52.58-PM-300x90.png 300w" sizes="auto, (max-width: 433px) 100vw, 433px" /></a></p>
<p>To make the Tracealyzer PSoC Streamport work I make a copy of the TraceRecorder/streamports/USB_CDC and called it PSoC_UART.  After I cut all all of the ST USB crap, I realized that all I need to provide is a</p>
<ul>
<li>A function to receive bytes &#8230; called PSoC_Receive</li>
<li>A function to transmit bytes&#8230; called PSoC_Transmit</li>
</ul>
<p>Next you need to modify these 10 CPP Macros to support the Tracealyzer PSoC Streamport.   (I only had to modify INIT, READ and SEND)</p>
<ul>
<li>TRC_STREAM_PORT_ALLOCATE_FIELDS</li>
<li>TRC_STREAM_PORT_MALLOC</li>
<li>TRC_STREAM_PORT_INIT</li>
<li>TRC_STREAM_PORT_ALLOCATE_EVENT</li>
<li>TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT</li>
<li>TRC_STREAM_PORT_COMMIT_EVENT</li>
<li>TRC_STREAM_PORT_READ_DATA</li>
<li>TRC_STREAM_PORT_PERIODIC_SEND_DATA</li>
<li>TRC_STREAM_PORT_ON_TRACE_BEGIN</li>
<li>TRC_STREAM_PORT_ON_TRACE_END</li>
</ul>
<p>In addition I provide function prototypes for PSoC_Receive and PSoC_Transmit which are called by TRC_STREAM_PORT_READ_DATA and TRC_STREAM_PORT_PERIODIC_SEND_DATA</p>
<pre class="start-line:47 lang:c decode:true">// An Adaption of the Percepio CDC Library to PSoC SCB UART
#include &lt;project.h&gt;

#ifndef TRC_STREAMING_PORT_H
#define TRC_STREAMING_PORT_H

#ifdef __cplusplus
extern "C" {
#endif

/*******************************************************************************
 * Implement the below macros to define your own stream port. If your transfer 
 * method uses RTOS functions, you should not send the data directly but use 
 * the recorder's internal buffer to store the trace data, for later transfer by
 * the TzCtrl task. Check the predefined stream ports for examples on how to use 
 * the internal buffer (e.g., TCP/IP, UART or USB CDC).
 *
 * Read more at http://percepio.com/2016/10/05/rtos-tracing/  
 ******************************************************************************/

int32_t PSoC_Receive(void *data, uint32_t size, int32_t *numOfBytesReceived);
int32_t PSoC_Transmit(void *data, uint32_t size, int32_t *numOfBytesSent );

#if TRC_RECORDER_BUFFER_ALLOCATION == TRC_RECORDER_BUFFER_ALLOCATION_STATIC
#define TRC_STREAM_PORT_ALLOCATE_FIELDS() static char _TzTraceData[TRC_CFG_PAGED_EVENT_BUFFER_PAGE_COUNT * TRC_CFG_PAGED_EVENT_BUFFER_PAGE_SIZE];       /* Static allocation. */
#define TRC_STREAM_PORT_MALLOC() /* Static allocation. Not used. */
#else
#define TRC_STREAM_PORT_ALLOCATE_FIELDS() static char* _TzTraceData = NULL;     /* Dynamic allocation. */
#define TRC_STREAM_PORT_MALLOC() _TzTraceData = TRC_PORT_MALLOC(TRC_PAGED_EVENT_BUFFER_PAGE_COUNT * TRC_PAGED_EVENT_BUFFER_PAGE_SIZE);
#endif

#define TRC_STREAM_PORT_INIT() \
        UART_Start(); \
        TRC_STREAM_PORT_MALLOC(); /*Dynamic allocation or empty if static */

#define TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) _type* _ptrData; _ptrData = (_type*)prvPagedEventBufferGetWritePointer(_size);
#define TRC_STREAM_PORT_ALLOCATE_DYNAMIC_EVENT(_type, _ptrData, _size) TRC_STREAM_PORT_ALLOCATE_EVENT(_type, _ptrData, _size) /* We do the same thing as for non-dynamic event sizes */
#define TRC_STREAM_PORT_COMMIT_EVENT(_ptrData, _size) /* Not needed since we write immediately into the buffer received above by TRC_STREAM_PORT_ALLOCATE_EVENT, and the TRC_STREAM_PORT_PERIODIC_SEND_DATA defined below will take care of the actual trace transfer. */
#define TRC_STREAM_PORT_READ_DATA(_ptrData, _size, _ptrBytesRead) PSoC_Receive(_ptrData, _size, _ptrBytesRead);
#define TRC_STREAM_PORT_PERIODIC_SEND_DATA(_ptrBytesSent) prvPagedEventBufferTransfer(PSoC_Transmit, _ptrBytesSent);
#define TRC_STREAM_PORT_ON_TRACE_BEGIN() { prvPagedEventBufferInit(_TzTraceData); }
#define TRC_STREAM_PORT_ON_TRACE_END() /* Do nothing */

#ifdef __cplusplus
}
#endif

#endif /* TRC_STREAMING_PORT_H */
</pre>
<p>The last thing to make this work is provide the C function to read and write the UART by modifying trcStreamingPort.c</p>
<pre class="lang:c decode:true">// An adataption of the Percepio USB_CDC Port to PSoC Serial
#include "trcRecorder.h"

#if (TRC_USE_TRACEALYZER_RECORDER == 1)
#if(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)

#include "stdint.h"

int32_t PSoC_Receive(void *data, uint32_t size, int32_t *numOfBytesReceived)
{
  
    uint8_t *myData= (uint8_t *)data;
    
    *numOfBytesReceived = 0;
    while( (*numOfBytesReceived &lt; (int32_t)size) &amp;&amp; UART_SpiUartGetRxBufferSize())
    {
            myData[*numOfBytesReceived] = UART_SpiUartReadRxData();
            *numOfBytesReceived += 1;
    }
	return 0; // Doesnt matter what you return... i dont think that it is checked
}

int32_t PSoC_Transmit(void* data, uint32_t size, int32_t *numOfBytesSent )
{
    UART_SpiUartPutArray((uint8_t *)data,size);
    *numOfBytesSent=size;
    
    return 0; // Doesnt matter what you return... i dont think that it is checked
}

#endif	/*(TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)*/
#endif  /*(TRC_USE_TRACEALYZER_RECORDER == 1)*/
</pre>
<p>There at two things that are a bit goofy.</p>
<ul>
<li>The return values for both of these function is not used by the calling functions&#8230; and is not defined what it means.</li>
<li>The 3rd parameter of both functions is defined as int32_t, but in the TraceRecorder library it is defined as int.  This makes a warning, which I got rid of by fixing the bug in the Percepio code.</li>
</ul>
<h1>Testing</h1>
<p>To test this you need to change the Tracealyzer settings from JLink to Serial and fix the COM port and baud rate.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-6.17.13-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-6.17.13-PM.png" alt="Percepio Tracelyzer PSoC Setup" width="557" height="442" class="alignnone wp-image-3938 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-6.17.13-PM.png 557w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-6.17.13-PM-300x238.png 300w" sizes="auto, (max-width: 557px) 100vw, 557px" /></a></p>
<p>When I built this code originally, I tried 115200 baud.  But it didn&#8217;t work at all (it locked up FreeRTOS).  Then I tried 921600 which locked up the Tracealyzer.  I am running Tracealyzer and PSoC Creator on a Mac in a VMWare Fusion Windows 7 box and I am pretty sure that there is a USB bridging problem (I am going to try it on a Windows box).  After grinding for a while I found out that both 230400 and 460800 both worked but both showed something very funny, look at the data:</p>
<p>230400 Baud</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.49-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.49-PM.png" alt="Percepio Tracelyzer PSoC - Streaming Data" width="594" height="326" class="alignnone wp-image-3921 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.49-PM.png 594w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.49-PM-300x165.png 300w" sizes="auto, (max-width: 594px) 100vw, 594px" /></a> <a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM.png" alt="Percepio Tracelyzer PSoC - Streaming Data" width="778" height="849" class="alignnone wp-image-3922 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM.png 778w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM-600x655.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM-275x300.png 275w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.20.29-PM-768x838.png 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></a></p>
<p>460800 Baud</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM.png" alt="Percepio Tracelyzer PSoC - Streaming Data" width="596" height="359" class="alignnone wp-image-3925 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM.png 596w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.23.31-PM-300x181.png 300w" sizes="auto, (max-width: 596px) 100vw, 596px" /></a></p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.24.02-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.24.02-PM.png" alt="Percepio Tracelyzer PSoC - Streaming Data" width="776" height="848" class="alignnone wp-image-3924 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.24.02-PM.png 776w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.24.02-PM-600x656.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.24.02-PM-275x300.png 275w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-29-at-3.24.02-PM-768x839.png 768w" sizes="auto, (max-width: 776px) 100vw, 776px" /></a></p>
<p>I knew that my implementation of the Percepio Tracealyzer PSoC Streamport would be demanding on the CPU, but I did not predict that it would take 30-50% of the CPU.  This is definitely a problem as the JLink RTT Streamport only takes 0.4% of the CPU.  To fix this I am going to try using the PSoC4200M DMA to automatically transfer the buffers to the UART.  Hopefully that will make my Tracealyzer PSoC streamport better.  But that is for the next Article.</p>
<p><span><p>As always you can find all of these projects on the <a href="https://github.com/iotexpert/PSoC-Tracelyzer" target="_blank" rel="noopener">IotExpert GitHub</a> site or git@github.com:iotexpert/PSoC-Tracelyzer.git</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Article</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/07/18/percepio-tracelyzer-psoc-4200m/">Percepio Tracealyzer &amp; PSoC</a></td>
<td >An Introduction to Percepio Tracealyzer on the Cypress PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/07/25/perception-tracelyzer-rtt-streamport-psoc4200m/">Percepio Tracealyzer RTT Streamport - PSoC4200M</a></td>
<td >Make the JLINK RTT Library work with Tracealyzer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/01/percepio-tracelyzer-psoc-uart-streamport/">Percepio Tracealyzer PSoC UART Streamport</a></td>
<td >Creating a UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/03/psoc-tracelyzer-streampoint/">Percepio Tracealyzer - Analyzing the PSoC Tracealyzer Streamport</a></td>
<td >Figure out what is broken in the UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/08/percepio-tracelyzer-a-psoc-dma-streamport/">Percepio Tracealyzer - Using PSoC DMA to Fix the UART Streamport</a></td>
<td >Implementing PSoC DMA to improve the CPU Utilization</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/15/percepio-tracealyzer-on-psoc6/">Percepio Tracealyzer - Running on PSoC6</a></td>
<td >Porting the Percepio Tracealyzer to PSoC6</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/percepio-tracealyzer-psoc-uart-streamport/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Percepio Tracealyzer RTT Streamport &#8211; PSoC4200M</title>
		<link>https://iotexpert.com/percepio-tracealyzer-rtt-streamport-psoc4200m/</link>
					<comments>https://iotexpert.com/percepio-tracealyzer-rtt-streamport-psoc4200m/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 25 Jul 2017 10:00:50 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3895</guid>

					<description><![CDATA[Summary In the last article I showed you how to install the Percepio Tracealyzer into your PSoC FreeRTOS project using snapshot mode.   This mode is very convenient as it has little CPU impact and does not require a communication interface.  But your trace it is limited in record time by how much RAM you [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>In the last <a href="https://iotexpert.com/2017/07/18/percepio-tracelyzer-psoc-4200m/">article</a> I showed you how to install the <a href="https://percepio.com" target="_blank" rel="noopener">Percepio</a> <a href="https://percepio.com/tz/" target="_blank" rel="noopener">Tracealyzer</a> into your PSoC FreeRTOS project using snapshot mode.   This mode is very convenient as it has little CPU impact and does not require a communication interface.  But your trace it is limited in record time by how much RAM you are willing to dedicate to the trace.   For me, this was not very much because I am using a small PSoC with limited RAM.  In this article I am going to show you how to use the <a href="https://www.segger.com/products/debug-probes/j-link/" target="_blank" rel="noopener">Segger JLink</a> RTT library to support the Tracealyzer RTT Streamport.  With this library built in, the RTOS events will be sent in real-time to the Pecepio Tracealyzer for analysis.</p>
<h1>JLink Real Time Transfer (RTT) Library</h1>
<p>The engineers at Segger had a great idea.  Really great.  Given that they had direct access to the memory of the ARM M0 (for programming) that could be read and written without CPU intervention via the Coresite Debug Access Port, wouldn&#8217;t it be nice if there was a simple way to &#8220;send&#8221; and &#8220;receive&#8221; data without using another communication peripheral on the device.</p>
<p>So they built the <a href="https://www.segger.com/products/debug-probes/j-link/technology/real-time-transfer/general-information/" target="_blank" rel="noopener">Segger Real Time Transfer (RTT) Library</a> which works with their JLink.  Here is a picture which I got from their website.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/J-Link-RTT_800x.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/J-Link-RTT_800x.png" alt="Segger JLink RTT" width="800" height="333" class="alignnone wp-image-3913 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/J-Link-RTT_800x.png 800w, https://iotexpert.com/wp-content/uploads/2017/07/J-Link-RTT_800x-600x250.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/J-Link-RTT_800x-300x125.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/J-Link-RTT_800x-768x320.png 768w" sizes="auto, (max-width: 800px) 100vw, 800px" /></a></p>
<p>I will talk more about this library in a future article.</p>
<h1>Installing the Percepio Tracealyzer RTT Streamport</h1>
<p>I decided to use a copy of the blinking led project (called 1-BlinkingLED) to start the new project.  To copy the project just use CTRL-C and CTRL-V then rename the project to 1-BlinkingLED_RTT.</p>
<p>To make all of this work you need to add the streaming include files for the Tracealyzer RTT Streamport by right clicking &#8220;Add&#8211;&gt;Exiting Item&#8230;&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.05.44-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.05.44-PM.png" alt="PSoC Creator Add Existing" width="430" height="227" class="alignnone wp-image-3910 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.05.44-PM.png 430w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.05.44-PM-300x158.png 300w" sizes="auto, (max-width: 430px) 100vw, 430px" /></a></p>
<p>Then selecting &#8220;TraceRecorder&#8211;&gt;streamports&#8211;&gt;Jlink_RTT_include&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.57.43-PM.png"></a><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.57.43-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.57.43-PM.png" alt="PSoC Creator Add Existing" width="686" height="651" class="alignnone wp-image-3900 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.57.43-PM.png 686w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.57.43-PM-600x569.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.57.43-PM-300x285.png 300w" sizes="auto, (max-width: 686px) 100vw, 686px" /></a></p>
<p>Next you need to update the include path for the project by right clicking on the project and selecting &#8220;Build Settings&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.07.37-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.07.37-PM.png" alt="PSoC Creator Change Build Settings" width="418" height="580" class="alignnone wp-image-3911 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.07.37-PM.png 418w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-2.07.37-PM-216x300.png 216w" sizes="auto, (max-width: 418px) 100vw, 418px" /></a></p>
<p>Then add the path to the TraceRecorder\streamports\JLink_RTT\include</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.59.21-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.59.21-PM.png" alt="PSoC Creator Update Include Path for Tracelyzer RTT Streamport" width="719" height="498" class="alignnone wp-image-3899 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.59.21-PM.png 719w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.59.21-PM-600x416.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.59.21-PM-300x208.png 300w" sizes="auto, (max-width: 719px) 100vw, 719px" /></a> <a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-12.57.43-PM.png"></a></p>
<p>Next, add the .c files for the RTT library.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.00.10-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.00.10-PM.png" alt="PSoC Creator - Add Tracelyzer RTT Streamport Library" width="688" height="653" class="alignnone wp-image-3898 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.00.10-PM.png 688w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.00.10-PM-600x569.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.00.10-PM-300x285.png 300w" sizes="auto, (max-width: 688px) 100vw, 688px" /></a></p>
<p>Now that all of the required files are part of your project, you need to modify the &#8220;trcConfig.h&#8221; to switch to the stream recording mode (line 102).</p>
<pre class="start-line:87 lang:c decode:true">/*******************************************************************************
 * Configuration Macro: TRC_CFG_RECORDER_MODE
 *
 * Specify what recording mode to use. Snapshot means that the data is saved in
 * an internal RAM buffer, for later upload. Streaming means that the data is
 * transferred continuously to the host PC. 
 *
 * For more information, see http://percepio.com/2016/10/05/rtos-tracing/
 * and the Tracealyzer User Manual.
 *
 * Values:
 * TRC_RECORDER_MODE_SNAPSHOT
 * TRC_RECORDER_MODE_STREAMING
 ******************************************************************************/
//#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_SNAPSHOT
#define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING</pre>
<p>My PSoC 4M only has 16K of SRAM.  So, I reduce the memory footprint of the streaming buffer by changing it to 1000 byte from 5000 bytes in trcStreamingPort.h.</p>
<pre class="start-line:54 lang:c decode:true">/*******************************************************************************
 * Configuration Macro: TRC_CFG_RTT_BUFFER_SIZE_UP
 *
 * Defines the size of the "up" RTT buffer (target -&gt; host) to use for writing
 * the trace data, for RTT buffer 1 or higher.
 *
 * This setting is ignored for RTT buffer 0, which can't be reconfigured
 * in runtime and therefore hard-coded to use the defines in SEGGER_RTT_Conf.h.
 *
 * Default buffer size for Tracealyzer is 5000 bytes. 
 *
 * If you have a stand-alone J-Link probe, the can be decreased to around 1 KB.
 * But integrated J-Link OB interfaces are slower and needs about 5-10 KB, 
 * depending on the amount of data produced.
 ******************************************************************************/
//#define TRC_CFG_RTT_BUFFER_SIZE_UP 5000
#define TRC_CFG_RTT_BUFFER_SIZE_UP 1000</pre>
<h1>Run Tracealyzer</h1>
<p>After the project is updated for the Tracealyzer RTT Streamport, I can program it into my CY8CKIT-044 development kit.  The next step is to start the Tracealyzer.  If you have previously run the program it will use your previous J-Link settings.  If you have not run it before then you need to setup the J-Link Settings</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.15-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.15-PM.png" alt="Percepio Tracelyzer" width="867" height="660" class="alignnone wp-image-3908 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.15-PM.png 867w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.15-PM-600x457.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.15-PM-300x228.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.15-PM-768x585.png 768w" sizes="auto, (max-width: 867px) 100vw, 867px" /></a></p>
<p>I am using a CY8CKIT-044 which has a CY8C4247xxx PSoC 4200M MCU onboard.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.31-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.31-PM.png" alt="Configure JLink for Tracelyzer RTT Streamport" width="565" height="440" class="alignnone wp-image-3907 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.31-PM.png 565w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.31-PM-300x234.png 300w" sizes="auto, (max-width: 565px) 100vw, 565px" /></a></p>
<p>I use the default settings for the Segger RTT.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.46-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.46-PM.png" alt="Tracelyzer RTT Streamport Stream Trace Settings" width="564" height="440" class="alignnone wp-image-3906 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.46-PM.png 564w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.58.46-PM-300x234.png 300w" sizes="auto, (max-width: 564px) 100vw, 564px" /></a></p>
<p>Once things are setup you can &#8220;Connect to Target System&#8230;&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.56.53-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.56.53-PM.png" alt="Percepio Tracelyzer" width="867" height="659" class="alignnone wp-image-3905 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.56.53-PM.png 867w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.56.53-PM-600x456.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.56.53-PM-300x228.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.56.53-PM-768x584.png 768w" sizes="auto, (max-width: 867px) 100vw, 867px" /></a></p>
<p>Then click &#8220;Start Recording&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.29-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.29-PM.png" alt="Percepio Tracelyzer" width="686" height="318" class="alignnone wp-image-3904 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.29-PM.png 686w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.29-PM-600x278.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.29-PM-300x139.png 300w" sizes="auto, (max-width: 686px) 100vw, 686px" /></a></p>
<p>As you are recording the Tracealyzer shows the CPU usage.  In this case it is very close to 0% as all the program does is blink the LED and then sleep for 500ms.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.47-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.47-PM.png" alt="Percepio Tracelyzer Recording" width="681" height="310" class="alignnone wp-image-3903 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.47-PM.png 681w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.47-PM-600x273.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.12.47-PM-300x137.png 300w" sizes="auto, (max-width: 681px) 100vw, 681px" /></a></p>
<p>After I stop recording I can look at the trace.   The first thing to notice in this trace is that I can look at quite a bit more data.  In this case I recorded for about 22 seconds.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.14.20-PM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.14.20-PM.png" alt="Percepio Tracelyzer" width="877" height="631" class="alignnone wp-image-3902 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.14.20-PM.png 877w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.14.20-PM-600x432.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.14.20-PM-300x216.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-23-at-1.14.20-PM-768x553.png 768w" sizes="auto, (max-width: 877px) 100vw, 877px" /></a></p>
<p>In the next article I am planning on doing a Streamport based on the PSoC UART which means I will not need to use a JLink.</p>
<p><span><p>As always you can find all of these projects on the <a href="https://github.com/iotexpert/PSoC-Tracelyzer" target="_blank" rel="noopener">IotExpert GitHub</a> site or git@github.com:iotexpert/PSoC-Tracelyzer.git</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Article</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/07/18/percepio-tracelyzer-psoc-4200m/">Percepio Tracealyzer &amp; PSoC</a></td>
<td >An Introduction to Percepio Tracealyzer on the Cypress PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/07/25/perception-tracelyzer-rtt-streamport-psoc4200m/">Percepio Tracealyzer RTT Streamport - PSoC4200M</a></td>
<td >Make the JLINK RTT Library work with Tracealyzer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/01/percepio-tracelyzer-psoc-uart-streamport/">Percepio Tracealyzer PSoC UART Streamport</a></td>
<td >Creating a UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/03/psoc-tracelyzer-streampoint/">Percepio Tracealyzer - Analyzing the PSoC Tracealyzer Streamport</a></td>
<td >Figure out what is broken in the UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/08/percepio-tracelyzer-a-psoc-dma-streamport/">Percepio Tracealyzer - Using PSoC DMA to Fix the UART Streamport</a></td>
<td >Implementing PSoC DMA to improve the CPU Utilization</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/15/percepio-tracealyzer-on-psoc6/">Percepio Tracealyzer - Running on PSoC6</a></td>
<td >Porting the Percepio Tracealyzer to PSoC6</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/percepio-tracealyzer-rtt-streamport-psoc4200m/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Percepio Tracealyzer &#038; PSoC 4200M</title>
		<link>https://iotexpert.com/percepio-tracealyzer-psoc-4200m/</link>
					<comments>https://iotexpert.com/percepio-tracealyzer-psoc-4200m/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Tue, 18 Jul 2017 09:42:21 +0000</pubDate>
				<category><![CDATA[CY8CKIT-044]]></category>
		<category><![CDATA[PSoC 4200]]></category>
		<category><![CDATA[Tracealyzer]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=3783</guid>

					<description><![CDATA[Summary 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? [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>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 <a href="https://percepio.com" target="_blank" rel="noopener">Percepio</a> asking me if I wanted to try out the Percepio Tracealyzer.  I said yes&#8230; but that I was really busy and it was going to take a while for me to get to it.  So now I have&#8230; 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&#8217;t their fault.</p>
<p>In this series of article&#8217;s I will instrument the <a href="https://iotexpert.com/category/tools/freertos/" target="_blank" rel="noopener">FreeRTOS</a> projects that I have been showing you with the <a href="https://percepio.com/tz/" target="_blank" rel="noopener">Percepio Tracealyzer</a> 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 Tracealyzer functionality going on a PSoC4200M.</p>
<h1>Percepio Tracealyzer</h1>
<p>The way that Percepio Tracelzer 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 &#8220;TzCtrl&#8221; 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.</p>
<p>This is the architecture picture from the Percepio website:</p>
<p><img loading="lazy" decoding="async" src="https://percepio.com/docs/FreeRTOS/images/FreeRTOS/system_overview.png" width="1338" height="669" class="alignnone" alt="Percepio Tracelyzer Architecture" /></p>
<h1>Updating CY8CKIT-044 PSoC4200M Development Kit</h1>
<p>To make the Percepio Tracealyzer work you need to turn the &#8220;Snapshot or streaming&#8221; line from the picture above into a real connection.  In snapshot mode there are two ways (I think) that you can do it.</p>
<ol>
<li>You can stop the processor with the debugger, then write the region of memory with the trace buffer into an &#8220;.hex&#8221; or a &#8220;.bin&#8221; 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&#8230; so plan 1 is out the window</li>
<li>You can attach a <a href="https://www.segger.com/products/debug-probes/j-link/" target="_blank" rel="noopener">Segger JLINK</a> to the PSoC via SWD.  Then, Tracealyzer knows how to talk to the JLink to read the memory.  This is what I am going to do for this Article.</li>
</ol>
<p>One feature that is very cool about the Snapshot methodology is that Tracealyzer can search the output file and find the trace buffer.  The trace buffer data structure is marked by something that Tracealyzer can find.</p>
<p>When our very good devkit team team in India built the <a href="http://www.cypress.com/documentation/development-kitsboards/cy8ckit-044-psoc-4-m-series-pioneer-kit" target="_blank" rel="noopener">CY8CKIT-044</a> (which I have used and <a href="https://iotexpert.com/category/devkits/cy8ckit-044/" target="_blank" rel="noopener">written</a> about quite a bit), they installed a built in debugger/programmer called &#8220;<a href="http://www.cypress.com/file/157966/download" target="_blank" rel="noopener">KitProg</a>&#8220;.  But they also understood that someone might want to connect some third part debugger like the JLINK.  So&#8230; 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).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/06/IMG_4515-e1499117018159.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/06/IMG_4515-e1499117018159-1024x768.jpg" alt="CY8CKIT-044 PSoC 4200M Development Kit" width="1024" height="768" class="alignnone wp-image-3716 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/06/IMG_4515-e1499117018159-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/06/IMG_4515-e1499117018159-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/06/IMG_4515-e1499117018159-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/06/IMG_4515-e1499117018159-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Before I can use a JLINK I needed to do this &#8230; which unfortunately ended with me burning myself with the soldering iron&#8230; bad Alan.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4576.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4576-1024x768.jpg" alt="CY8CKIT-044 PSoC 4200M Development Kit" width="1024" height="768" class="alignnone wp-image-3790 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4576-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4576-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4576-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4576-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Tracealyzer Snapshot Mode on Blinking LED Project</h1>
<p>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&#8217;t want to modify them.  This is exactly what I will do with the Percepio Tracealyzer 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</p>
<p>To start the first Percepio Tracealyzer example I will use the basic &#8220;Snapshot Mode&#8221;.  There is good documentation on the Percepio Tracealyzer documentation <a href="https://percepio.com/docs/FreeRTOS/manual/Recorder.html#Trace_Recorder_Library_Snapshot_Mode" target="_blank" rel="noopener">website</a>.  I will start by copying the PSoC Creator Workspace from the FreeRTOS articles from <a href="https://github.com/iotexpert/PSoC-FreeRTOS-Examples" target="_blank" rel="noopener">GitHub</a>.  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 Tracealyzer library from the Perceio <a href="http://percepio.com/docs/FreeRTOS/TraceRecorder.zip" target="_blank" rel="noopener">website</a> into a parallel directory called &#8220;TraceRecorder&#8221;.</p>
<p>Make a new folder for the non-changing include files called &#8220;TraceRecorder&#8221; (for the files that I don&#8217;t want to change)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.12.31-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.12.31-AM.png" alt="PSoC Creator Project Configuration" width="428" height="235" class="alignnone wp-image-3804 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.12.31-AM.png 428w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.12.31-AM-300x165.png 300w" sizes="auto, (max-width: 428px) 100vw, 428px" /></a></p>
<p>Next I will add the files that I don&#8217;t want to change to the project so that I can see them (meaning they are just referenced by PSoC Creator)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.11-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.11-AM.png" alt="PSoC Creator Project Configuration - Add External Files" width="453" height="364" class="alignnone wp-image-3802 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.11-AM.png 453w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.11-AM-300x241.png 300w" sizes="auto, (max-width: 453px) 100vw, 453px" /></a></p>
<p>They reside in the directory TraceRecorder/include</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.27-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.27-AM.png" alt="PSoC Creator Project Configuration - Add External Files" width="809" height="507" class="alignnone wp-image-3801 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.27-AM.png 809w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.27-AM-600x376.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.27-AM-300x188.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.13.27-AM-768x481.png 768w" sizes="auto, (max-width: 809px) 100vw, 809px" /></a></p>
<p>Once I have the unchanging .h&#8217;s into my project, I need to add their directory to the include path.  To do this right-click on the project and select &#8220;Build Settings &#8230;&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.43-AM.png"></a><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.18-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.18-AM.png" alt="PSoC Creator Project Configuration - Add External Files" width="427" height="582" class="alignnone wp-image-3809 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.18-AM.png 427w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.18-AM-220x300.png 220w" sizes="auto, (max-width: 427px) 100vw, 427px" /></a><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.43-AM.png"></a></p>
<p>Then click &#8220;Compiler&#8221; and then the &#8220;&#8230;&#8221; on the &#8220;Additional Include Directories&#8221; line</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.39-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.39-AM.png" alt="PSoC Creator Project Configuration - Compiler Options" width="815" height="538" class="alignnone wp-image-3808" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.39-AM.png 815w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.39-AM-600x396.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.39-AM-300x198.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.07.39-AM-768x507.png 768w" sizes="auto, (max-width: 815px) 100vw, 815px" /></a></p>
<p>Navigate until you get to TraceRecoder/include then press &#8220;Select Folder&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.31-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.31-AM.png" alt="PSoC Creator Project Configuration - Update include path" width="661" height="451" class="alignnone wp-image-3807 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.31-AM.png 661w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.31-AM-600x409.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.31-AM-300x205.png 300w" sizes="auto, (max-width: 661px) 100vw, 661px" /></a></p>
<p>Now your include path should look like this:</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.43-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.43-AM.png" alt="PSoC Creator Project Configuration - Include Path" width="361" height="314" class="alignnone wp-image-3806 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.43-AM.png 361w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.08.43-AM-300x261.png 300w" sizes="auto, (max-width: 361px) 100vw, 361px" /></a></p>
<p>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)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.23.10-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.23.10-AM.png" alt="PSoC Creator Project Configuration - Add Trace Recorder Library" width="880" height="493" class="alignnone wp-image-3812 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.23.10-AM.png 880w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.23.10-AM-600x336.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.23.10-AM-300x168.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.23.10-AM-768x430.png 768w" sizes="auto, (max-width: 880px) 100vw, 880px" /></a></p>
<p>You want to paste them into your project directory</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.24.00-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.24.00-AM.png" alt="PSoC Creator Project Configuration - Add External Files" width="944" height="694" class="alignnone wp-image-3811 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.24.00-AM.png 944w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.24.00-AM-600x441.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.24.00-AM-300x221.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.24.00-AM-768x565.png 768w" sizes="auto, (max-width: 944px) 100vw, 944px" /></a></p>
<p>Then you need to add them to the project so that you can easily edit them by right clicking on the &#8220;Header Files&#8221; folder and selecting &#8220;Add&#8211;&gt;Existing Item&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-11.23.22-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-11.23.22-AM.png" alt="PSoC Creator Project Configuration - Add External Files" width="410" height="339" class="alignnone wp-image-3839 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-11.23.22-AM.png 410w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-11.23.22-AM-300x248.png 300w" sizes="auto, (max-width: 410px) 100vw, 410px" /></a></p>
<p>Then selecting them out of your project directory.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.26.36-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.26.36-AM.png" alt="PSoC Creator Project Configuration - Add External Files" width="657" height="452" class="alignnone wp-image-3815 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.26.36-AM.png 657w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.26.36-AM-600x413.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.26.36-AM-300x206.png 300w" sizes="auto, (max-width: 657px) 100vw, 657px" /></a></p>
<p>Now we need to add references to all of the .c files.  Start by making a new folder for the c-files called &#8220;TraceRecorder&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.15.13-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.15.13-AM.png" alt="PSoC Creator Project Configuration - Add TraceRecorder" width="426" height="329" class="alignnone wp-image-3805 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.15.13-AM.png 426w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-7.15.13-AM-300x232.png 300w" sizes="auto, (max-width: 426px) 100vw, 426px" /></a></p>
<p>Then &#8220;Add&#8211;&gt;Existing Item&#8230;&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.12-AM.png"></a><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.12-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.12-AM.png" alt="PSoC Creator Project Configuration - Add External Files" width="474" height="563" class="alignnone wp-image-3820 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.12-AM.png 474w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.12-AM-253x300.png 253w" sizes="auto, (max-width: 474px) 100vw, 474px" /></a></p>
<p>Select the files from the TraceRecorder directory</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.31-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.31-AM.png" alt="PSoC Creator Project Configuration - Add TraceRecorder Files" width="688" height="649" class="alignnone wp-image-3819 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.31-AM.png 688w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.31-AM-600x566.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.31-AM-300x283.png 300w" sizes="auto, (max-width: 688px) 100vw, 688px" /></a></p>
<p>Now your project should look like this</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.50-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.50-AM.png" alt="PSoC Creator Project Configuration - Project Configuration" width="447" height="434" class="alignnone wp-image-3818 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.50-AM.png 447w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.33.50-AM-300x291.png 300w" sizes="auto, (max-width: 447px) 100vw, 447px" /></a></p>
<p>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.</p>
<pre class="start-line:90 lang:c decode:true" title="FreeRTOSConfig.h">/* Integrates the Tracealyzer recorder with FreeRTOS */
#if ( configUSE_TRACE_FACILITY == 1 )
#include "trcRecorder.h"
#endif</pre>
<p>Then modify the trcConfig.h so that it has access to all of the CMSIS header files.</p>
<pre class="start-line:57 lang:c decode:true" title="trfConfig.h">/******************************************************************************
 * 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 &lt;project.h&gt;</pre>
<p>Then tell the TraceRecorder that we are using an ARM Cortex-M</p>
<pre class="start-line:67 lang:c decode:true ">/*******************************************************************************
 * 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:
 *
 * #define TRC_CFG_ARM_CM_USE_SYSTICK
 *
 * 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.
 ******************************************************************************/
//#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_NOT_SET
#define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_ARM_Cortex_M</pre>
<p>Now, you need to modify the project&#8217;s stack and heap size setup</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.47.40-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.47.40-AM-1024x578.png" alt="PSoC Creator Project Configuration - Design Wide Resources" width="1024" height="578" class="alignnone wp-image-3822 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.47.40-AM-1024x578.png 1024w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.47.40-AM-600x339.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.47.40-AM-300x169.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.47.40-AM-768x433.png 768w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-8.47.40-AM.png 1028w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The default snapshot buffer is to big to fit into PSoC SRAM, so I change the size to 400 records</p>
<pre class="start-line:88 lang:c decode:true ">/*******************************************************************************
 * TRC_CFG_EVENT_BUFFER_SIZE
 *
 * 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.
 ******************************************************************************/
#define TRC_CFG_EVENT_BUFFER_SIZE 400</pre>
<p>Finally modify main to start the Trace Recorder (vTraceEnable on line 40)</p>
<pre class="start-line:35 lang:c decode:true">int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    
    setupFreeRTOS();
    vTraceEnable(TRC_START);

    /* Create LED task, which will blink the RED LED */
    xTaskCreate(
        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 */
      
    vTaskStartScheduler();
    while(1); // get rid of the stupid warning
}</pre>
<h1>Testing the Output</h1>
<p>After all of the setup is done you can build and program the development kit.</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.10.10-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.10.10-AM-1024x757.png" alt="PSoC Creator Program Project" width="1024" height="757" class="alignnone wp-image-3825 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.10.10-AM-1024x757.png 1024w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.10.10-AM-600x443.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.10.10-AM-300x222.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.10.10-AM-768x568.png 768w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.10.10-AM.png 1165w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Plug in the Segger J-Link</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4663-e1500124155235.jpg"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4663-e1500124155235-1024x768.jpg" alt="CY8CKIT-044 + JLINK" width="1024" height="768" class="alignnone wp-image-3824 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/IMG_4663-e1500124155235-1024x768.jpg 1024w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4663-e1500124155235-600x450.jpg 600w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4663-e1500124155235-300x225.jpg 300w, https://iotexpert.com/wp-content/uploads/2017/07/IMG_4663-e1500124155235-768x576.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Start Tracealyzer then setup the J-Link (click on J-Link Settings&#8230;)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.31.44-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.31.44-AM-1024x658.png" alt="Percepio Tracelyzer" width="1024" height="658" class="alignnone wp-image-3830 size-large" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.31.44-AM-1024x658.png 1024w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.31.44-AM-600x385.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.31.44-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.31.44-AM-768x493.png 768w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.31.44-AM.png 1130w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Select &#8220;Select Device&#8230;&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.22-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.22-AM.png" alt="Percepio Tracelyzer - JLINK Settings" width="559" height="440" class="alignnone wp-image-3828 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.22-AM.png 559w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.22-AM-300x236.png 300w" sizes="auto, (max-width: 559px) 100vw, 559px" /></a></p>
<p>Filter the list to &#8220;cypress&#8221; then choose the &#8220;CY8C4247xxx&#8221; (which is the chip that is on the C8CKIT-044)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.33.47-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.33.47-AM.png" alt="Percepio Tracelyzer - JLINK Settings Select Device" width="507" height="529" class="alignnone wp-image-3826 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.33.47-AM.png 507w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.33.47-AM-288x300.png 288w" sizes="auto, (max-width: 507px) 100vw, 507px" /></a></p>
<p>Then Select &#8220;Jink-&gt;Read Trace&#8221;</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.39.47-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.39.47-AM.png" alt="Percepio Tracelyzer - Read Trace" width="411" height="187" class="alignnone wp-image-3832 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.39.47-AM.png 411w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.39.47-AM-300x136.png 300w" sizes="auto, (max-width: 411px) 100vw, 411px" /></a></p>
<p>Accept the defaults (this window only is only brought up the first time)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.02-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.02-AM.png" alt="Percepio Tracelyzer - JLINK Memory Region" width="307" height="179" class="alignnone wp-image-3829 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.02-AM.png 307w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-9.32.02-AM-300x175.png 300w" sizes="auto, (max-width: 307px) 100vw, 307px" /></a></p>
<p>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 &#8220;LED Blink&#8221; 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).</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.10.55-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.10.55-AM.png" alt="Percepio Tracelyzer - Console" width="794" height="642" class="alignnone wp-image-3836 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.10.55-AM.png 794w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.10.55-AM-600x485.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.10.55-AM-300x243.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.10.55-AM-768x621.png 768w" sizes="auto, (max-width: 794px) 100vw, 794px" /></a></p>
<p>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)</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.06.08-AM.png"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.06.08-AM.png" alt="Percepio Tracelyzer - Console" width="835" height="657" class="alignnone wp-image-3835 size-full" srcset="https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.06.08-AM.png 835w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.06.08-AM-600x472.png 600w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.06.08-AM-300x236.png 300w, https://iotexpert.com/wp-content/uploads/2017/07/Screen-Shot-2017-07-15-at-10.06.08-AM-768x604.png 768w" sizes="auto, (max-width: 835px) 100vw, 835px" /></a></p>
<h1>Conclusion</h1>
<p>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:</p>
<ul>
<li>Use Segger JLINK RTT streaming</li>
<li>Make a streaming port</li>
<li>Use some of the other screens in the Percepio Tracealyzer</li>
</ul>
<p><span><p>As always you can find all of these projects on the <a href="https://github.com/iotexpert/PSoC-Tracelyzer" target="_blank" rel="noopener">IotExpert GitHub</a> site or git@github.com:iotexpert/PSoC-Tracelyzer.git</p>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Article</th>
<th >Description</th>
</tr>
</thead>
<tbody>
<tr><td ><a href="https://iotexpert.com/2017/07/18/percepio-tracelyzer-psoc-4200m/">Percepio Tracealyzer &amp; PSoC</a></td>
<td >An Introduction to Percepio Tracealyzer on the Cypress PSoC</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/07/25/perception-tracelyzer-rtt-streamport-psoc4200m/">Percepio Tracealyzer RTT Streamport - PSoC4200M</a></td>
<td >Make the JLINK RTT Library work with Tracealyzer</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/01/percepio-tracelyzer-psoc-uart-streamport/">Percepio Tracealyzer PSoC UART Streamport</a></td>
<td >Creating a UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/03/psoc-tracelyzer-streampoint/">Percepio Tracealyzer - Analyzing the PSoC Tracealyzer Streamport</a></td>
<td >Figure out what is broken in the UART Streamport</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/08/percepio-tracelyzer-a-psoc-dma-streamport/">Percepio Tracealyzer - Using PSoC DMA to Fix the UART Streamport</a></td>
<td >Implementing PSoC DMA to improve the CPU Utilization</td>
</tr>

<tr><td ><a href="https://iotexpert.com/2017/08/15/percepio-tracealyzer-on-psoc6/">Percepio Tracealyzer - Running on PSoC6</a></td>
<td >Porting the Percepio Tracealyzer to PSoC6</td>
</tr>
</tbody></table></div></p></span></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/percepio-tracealyzer-psoc-4200m/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
