<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use SWO on Kinetis? in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237279#M5563</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to use Cortex M's SWO for debugging on a MK10 and MK20, I own a J-Link and I love using the SWO viewer for debugging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I usually use STM32 microcontrollers, and I already know how to do the same thing on them, basically setup CoreDebug and ITM, but they also have a ST specific DBGMCU pheripheral that needs to be configured.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DBGMCU only exist on ST chips. What is the equivalent on Kinetis? I do not see any in the KQRUG document. Does that mean I can just write to ITM and see the output? Does the pin automatically default to being a SWO pin instead of GPIO?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jan 2014 03:17:51 GMT</pubDate>
    <dc:creator>frank26080115</dc:creator>
    <dc:date>2014-01-16T03:17:51Z</dc:date>
    <item>
      <title>How to use SWO on Kinetis?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237279#M5563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to use Cortex M's SWO for debugging on a MK10 and MK20, I own a J-Link and I love using the SWO viewer for debugging.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I usually use STM32 microcontrollers, and I already know how to do the same thing on them, basically setup CoreDebug and ITM, but they also have a ST specific DBGMCU pheripheral that needs to be configured.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DBGMCU only exist on ST chips. What is the equivalent on Kinetis? I do not see any in the KQRUG document. Does that mean I can just write to ITM and see the output? Does the pin automatically default to being a SWO pin instead of GPIO?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 03:17:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237279#M5563</guid>
      <dc:creator>frank26080115</dc:creator>
      <dc:date>2014-01-16T03:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SWO on Kinetis?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237280#M5564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Frank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will check this thread. I will let you know when there with any updated info.&lt;/P&gt;&lt;P&gt;Thank you for the patience.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B.R.&lt;/P&gt;&lt;P&gt;Ma Hui&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 04:12:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237280#M5564</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2014-01-16T04:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SWO on Kinetis?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237281#M5565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Frank,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I check IAR ARM Workbench support J-Link SWO debug/Trace.&lt;/P&gt;&lt;P&gt;I do a test with IAR software and record my setting with below pictures.&lt;/P&gt;&lt;P&gt;Wish it could be helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with regards,&lt;/P&gt;&lt;P&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Setting with IAR project option:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SWO trace0.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/42056i0EF0A15B50DD8B5E/image-size/large?v=v2&amp;amp;px=999" role="button" title="SWO trace0.jpg" alt="SWO trace0.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SWO trace1.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/42116iD7F5990AEDE26586/image-size/large?v=v2&amp;amp;px=999" role="button" title="SWO trace1.jpg" alt="SWO trace1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Debug panel setting:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SWO trace2.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/42180i441C3A83C17255F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="SWO trace2.jpg" alt="SWO trace2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SWO trace3.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/42242iF8185F2930FCADFC/image-size/large?v=v2&amp;amp;px=999" role="button" title="SWO trace3.jpg" alt="SWO trace3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SWO trace4.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/42363iFD527194D4C67399/image-size/large?v=v2&amp;amp;px=999" role="button" title="SWO trace4.jpg" alt="SWO trace4.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="SWO trace5.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/42436i535B306179E7A358/image-size/large?v=v2&amp;amp;px=999" role="button" title="SWO trace5.jpg" alt="SWO trace5.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jan 2014 08:01:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237281#M5565</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2014-01-16T08:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SWO on Kinetis?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237282#M5566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Hui Ma&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks but you did not answer my question at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DBGMCU only exist on ST chips. What is the equivalent on Kinetis? I do not see any in the KQRUG document. Does that mean I can just write to ITM and see the output? Does the pin automatically default to being a SWO pin instead of GPIO?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not using IAR, I am not using any auto-configuration tool of any kind. When you show me how to click those buttons, I need to know what is happening behind the scenes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jan 2014 03:32:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237282#M5566</guid>
      <dc:creator>frank26080115</dc:creator>
      <dc:date>2014-01-17T03:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SWO on Kinetis?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237283#M5567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;got my code working, apparently the answer is that there is Kinetis specific setup required, but the standard Cortex setup for ITM, CoreDebug, and DWT are required.&lt;/P&gt;&lt;PRE&gt;void swo_init()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;uint32_t SWOSpeed = 6000000; //6000kbps, default for JLinkSWOViewer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;uint32_t SWOPrescaler = (F_CPU / SWOSpeed) - 1; // SWOSpeed in Hz, note that F_CPU is expected to be 96000000 in this case
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CoreDebug-&amp;gt;DEMCR = CoreDebug_DEMCR_TRCENA_Msk;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*((volatile unsigned *)(ITM_BASE + 0x400F0)) = 0x00000002; // "Selected PIN Protocol Register": Select which protocol to use for trace output (2: SWO)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*((volatile unsigned *)(ITM_BASE + 0x40010)) = SWOPrescaler; // "Async Clock Prescaler Register". Scale the baud rate of the asynchronous output
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*((volatile unsigned *)(ITM_BASE + 0x00FB0)) = 0xC5ACCE55; // ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ITM-&amp;gt;TCR = ITM_TCR_TraceBusID_Msk | ITM_TCR_SWOENA_Msk | ITM_TCR_SYNCENA_Msk | ITM_TCR_ITMENA_Msk; // ITM Trace Control Register
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ITM-&amp;gt;TPR = ITM_TPR_PRIVMASK_Msk; // ITM Trace Privilege Register
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ITM-&amp;gt;TER = 0x00000001; // ITM Trace Enable Register. Enabled tracing on stimulus ports. One bit per stimulus port.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*((volatile unsigned *)(ITM_BASE + 0x01000)) = 0x400003FE; // DWT_CTRL
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*((volatile unsigned *)(ITM_BASE + 0x40304)) = 0x00000100; // Formatter and Flush Control Register
}

// may not be needed
void swo_deinit()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;volatile uint32_t i = 0xFFF;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while (ITM-&amp;gt;PORT[0].u32 == 0 &amp;amp;&amp;amp; i--); // wait for any pending transmission
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CoreDebug-&amp;gt;DEMCR = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*((volatile unsigned *)(ITM_BASE + 0x00FB0)) = 0xC5ACCE55; // ITM Lock Access Register, C5ACCE55 enables more write access to Control Register 0xE00 :: 0xFFC
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ITM-&amp;gt;TCR = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ITM-&amp;gt;TPR = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ITM-&amp;gt;TER = 0;
}

// function mostly copied from ITM_SendChar
void swo_sendchar(char x)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(CoreDebug-&amp;gt;DHCSR &amp;amp; CoreDebug_DHCSR_C_DEBUGEN_Msk) &amp;amp;&amp;amp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // if debugger is attached (does it really work?)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(CoreDebug-&amp;gt;DEMCR &amp;amp; CoreDebug_DEMCR_TRCENA_Msk)&amp;nbsp; &amp;amp;&amp;amp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Trace enabled
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(ITM-&amp;gt;TCR &amp;amp; ITM_TCR_ITMENA_Msk)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;&amp;amp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ITM enabled
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(ITM-&amp;gt;TER &amp;amp; (1UL &amp;lt;&amp;lt; 0))&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ITM Port #0 enabled
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;volatile uint32_t i = 0xFFF; // implement a timeout
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while (ITM-&amp;gt;PORT[0].u32 == 0 &amp;amp;&amp;amp; i--); // wait for next
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (ITM-&amp;gt;PORT[0].u32 != 0 &amp;amp;&amp;amp; i != 0) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ITM-&amp;gt;PORT[0].u8 = (uint8_t) x; // send
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jan 2014 20:43:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237283#M5567</guid>
      <dc:creator>frank26080115</dc:creator>
      <dc:date>2014-01-19T20:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to use SWO on Kinetis?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237284#M5568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello. I'm also "coming" from STM32, and there, under eclipse and SWV tool from Segger - all is fine with SWO debug messages. But this is not the case for me with Kinetis and Code Warrior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm configuring the ITM in similar way like you. Seems it works, because I see an output data frame on SWO output. But I don't have any data in SWO Viewer (Segger's tool). I'm asking me, is it possible that CodeWarrior debug plugin takes the control over the J-link probe and blocks the channel to external SWO tool?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frank, what kind of IDE you are using with success of SWO view?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 May 2014 09:40:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/How-to-use-SWO-on-Kinetis/m-p/237284#M5568</guid>
      <dc:creator>tsvetanmudrov</dc:creator>
      <dc:date>2014-05-17T09:40:12Z</dc:date>
    </item>
  </channel>
</rss>

