<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27855/using-swo-with-nrf52-redux</link><description>I know this question has been asked before, but I couldn&amp;#39;t find an answer... 
 I&amp;#39;m looking for an example of how to use the nRF52832&amp;#39;s SWO feature with the SEGGER JLink product. I have a PCA10040 board that I can program and debug via Eclipse/GCC/Jlink</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 May 2018 14:11:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27855/using-swo-with-nrf52-redux" /><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/132519?ContentTypeID=1</link><pubDate>Fri, 18 May 2018 14:11:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5efd96f2-abd1-459c-9fb8-8f02d2c730b3</guid><dc:creator>Igor</dc:creator><description>&lt;p&gt;Oh, I missed this. Thank you for your answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/132512?ContentTypeID=1</link><pubDate>Fri, 18 May 2018 13:29:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be2ba7f2-49d1-422a-817a-2df6e09fbe63</guid><dc:creator>Jui-Chou (Rick) Chung</dc:creator><description>&lt;p&gt;Hello Igor,&lt;/p&gt;
&lt;p&gt;I would like to suggest you check the &amp;quot;pin assignment&amp;quot; for nRF52840 in the inforcenter:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52840.ps%2Fpin.html&amp;amp;cp=2_0_0_6_0_0&amp;amp;anchor=qfn48"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52840.ps%2Fpin.html&amp;amp;cp=2_0_0_6_0_0&amp;amp;anchor=qfn48&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;According to the upon link, the P1.00 has SWO function.&lt;/p&gt;
&lt;p&gt;Hope this can do help :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/132511?ContentTypeID=1</link><pubDate>Fri, 18 May 2018 13:18:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac2eff20-4b40-478f-8a4b-0cf1cbedfd02</guid><dc:creator>Igor</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/rickchung1082"&gt;Jui-Chou (Rick) Chung&lt;/a&gt; What about nRF52840? It It uses P0.18 as RESET.&amp;nbsp;To which pin is SWO bound in this case?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/109764?ContentTypeID=1</link><pubDate>Fri, 08 Dec 2017 21:41:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16c61196-4866-4d31-a776-bc6b60ed2682</guid><dc:creator>ekrashtan</dc:creator><description>&lt;p&gt;Thanks, Rick, it works fine. But I have next question - is it possible to route NRF_LOG output to SWO? Actually, I see only UART (needs the extra converter) or RTT (requires a lot of RAM) variants.
I put&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int __putchar(int ch, FILE * p_file)
{
   ITM_SendChar(ch);
   return ch;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to my code and can use printf for output, but it&amp;#39;s not enough for me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/109763?ContentTypeID=1</link><pubDate>Thu, 11 Aug 2016 09:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:130a3000-2602-471f-bff3-3e9dd61118f3</guid><dc:creator>apuret</dc:creator><description>&lt;p&gt;Tested and approved, thanks Rick !
For my use case, I write &amp;#39;retarget&amp;#39; functions:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;int _write(int file, char *ptr, int len) {
	UNUSED_PARAMETER(file);
	for (int i = 0; i &amp;lt; len; i++)
		ITM_SendChar(ptr[i]);
	return len;
}

int _write_r(struct _reent *r, int file, char *ptr, int len) {
	UNUSED_PARAMETER(r);
	UNUSED_PARAMETER(file);
	for (int i = 0; i &amp;lt; len; i++)
		ITM_SendChar(ptr[i]);
	return len;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/109762?ContentTypeID=1</link><pubDate>Mon, 30 May 2016 04:31:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c492d77b-2876-4210-9e5a-d42390630584</guid><dc:creator>Jui-Chou (Rick) Chung</dc:creator><description>&lt;p&gt;Hello Jprofit,&lt;/p&gt;
&lt;p&gt;The following steps showing how to configure the SWO, hope it can satisfy your question : D&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;add the additional define &amp;quot;ENABLE_SWO&amp;quot; to the project setting, which will set the nRF52 P0.18 as SWO instead of been a common GPIO&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;set the TRACECONFIG register for
trace port debug interface; the
detail can be found in
&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.0/clock.html#register.TRACECONFIG"&gt;here&lt;/a&gt;.
If you are using JLink-OB on the
PCA10040, the maximum SWO sampling
frequencey is 7.5MHz, so it is
needed to configure the
TRACEPORTSPEED to 4MHz.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the &lt;a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0314h/Chdbicac.html"&gt;trace enable register&lt;/a&gt; and &lt;a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0314h/Chdbicac.html"&gt;trace control register&lt;/a&gt; which in the &amp;quot;Instrumentation Trace Macrocell&amp;quot; to turn on the ITM stimulus&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;call the ITM_SendChar(uint32_t ch) to transmit the character via ITM channel 0, the detail can be found in the  /components/toolchain/CMSIS/Include/core_cm4.h&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Sample code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf.h&amp;quot;

int main(void)
{
	// step 2
	NRF_CLOCK-&amp;gt;TRACECONFIG = (NRF_CLOCK-&amp;gt;TRACECONFIG &amp;amp; ~CLOCK_TRACECONFIG_TRACEPORTSPEED_Msk) |
		(CLOCK_TRACECONFIG_TRACEPORTSPEED_4MHz &amp;lt;&amp;lt; CLOCK_TRACECONFIG_TRACEPORTSPEED_Pos);
	// step 3
	ITM-&amp;gt;TCR |= 1;
	ITM-&amp;gt;TER |= 1;
	uint8_t c = 65;
	while (true)
	{
		// step 4	
		ITM_SendChar(c);
		if( c &amp;gt;= 90){
			c = 65;
		}else{
			c++;
		}
	}
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After flash the code, execute the JLinkExe and set the SWO speed to 4MHz, then you will see the result on the screen:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;~$ JLinkExe -if swd -device nrf52 -speed auto
JLink&amp;gt;connect
JLink&amp;gt;swoview 4000000
Receiving SWO data @ 4000 kHz
Data from stimulus port 0:
--------------------------------------------------------
ABCD...
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/109761?ContentTypeID=1</link><pubDate>Sat, 07 May 2016 00:57:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35611b52-eb66-4564-9d9a-4be0546dffb1</guid><dc:creator>Justin</dc:creator><description>&lt;p&gt;You might want to use RTT, it is much faster than using SWO
&lt;a href="https://www.segger.com/jlink-rtt.html"&gt;www.segger.com/jlink-rtt.html&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/109760?ContentTypeID=1</link><pubDate>Fri, 06 May 2016 22:36:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef1987de-b1ec-45b4-84c1-9650142602ac</guid><dc:creator>jprofit</dc:creator><description>&lt;p&gt;Ahhh... I thought RTT was synonymous with SWO. Thanks for the clarification.
Do you know if there is an API in the SDK somewhere for using SWO based debug output?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using SWO with nRF52 (redux)</title><link>https://devzone.nordicsemi.com/thread/109759?ContentTypeID=1</link><pubDate>Fri, 06 May 2016 22:23:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e27f3a31-c2be-408b-b884-7c8e2fe72cdf</guid><dc:creator>Justin</dc:creator><description>&lt;p&gt;It looks like you&amp;#39;re logging to RTT and not SWO, you might want to try JLinkRTTClient after running  JLinkGDBServer&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>