<?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 SWO Trace setup for LPC5410x in LPCXpresso IDE FAQs</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/SWO-Trace-setup-for-LPC5410x/m-p/474104#M118</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To carry out SWO Trace on &lt;STRONG&gt;LPC5410x&lt;/STRONG&gt;, it is necessary to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Ensure that your board has SWO pinned out to the debug connector&lt;/LI&gt;&lt;LI&gt;If using the built-in LPC-Link2 debug probe of a LPCXpresso54102 board, ensure that the probe is configured for DFU booting&lt;/LI&gt;&lt;LI&gt;Turn on the trace clock within the MCU, as this is not enabled by default&lt;/LI&gt;&lt;LI&gt;Configure the MCU pinmuxing, so that the SWO signal is accesible on the appropriate pin of the MCU&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should typically be done within each of your application projects (or library projects that your projects link against).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note : &lt;/STRONG&gt;SWO Trace on LPC5410x MCUs can only be carried out for debug sessions connected to the Cortex-M4 CPU, not to the Cortex-M0+.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId-1708424228"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;SWO pin and debug connector&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On LPCXpresso54102 boards, pin P0_15 is connected to SWO of the debug connector.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using a different board, you will need to check the schematics to identify if SWO is connected to the debug connector (and on which pin from the MCU).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId--843732733"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;Debug probe&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LPCXpresso54102 board is typically shipped with CMSIS-DAP firmware installed into the built-in LPC-Link2 debug probe that does not provide the necessary channels for SWO trace data transfer back to the host debugger. You need to configure your board so that the LPCXpresso IDE can softload "redlink" firmware. This is done by fitting a jumper on JP5, then repowering the board. For more details, please see &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fmicrocontrollers-and-processors%2Farm-processors%2Flpc-cortex-m-mcus%2Fsoftware-and-tools-for-lpc-mcus%2Flpcxpresso-boards%3ALPCXPRESSO-BOARDS" rel="nofollow noopener noreferrer" target="_blank"&gt;LPCXpresso Boards|NXP&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId-899077602"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;Enabling the trace clock&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The startup code generated by the new project wizards for LPC5410x in LPCXpresso IDE v7.7 (and later) contain code to optionally turn on the trace clock.&amp;nbsp; By default this code will be enabled by the new project wizard, but if not required can be removed by defining the compiler symbol &lt;STRONG&gt;DONT_ENABLE_SWVTRACECLK&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using different startup code (for instance, as provided in the projects in the LPCOpen v2.14.1 package for the LPCXpresso5410x board), then you can add the following code to your project to turn on the trace clock&amp;nbsp; (for example right at the start of main() or in the startup file before the call to main() ) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;volatile unsigned int *TRACECLKDIV = (unsigned int *) 0x400000E4; &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;volatile unsigned int *SYSAHBCLKCTRLSET = (unsigned int *) 0x400000C8; &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;// Write 0x00000001 to TRACECLKDIV (0x400000E4) – Trace divider &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;*TRACECLKDIV = 1; &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;// Enable IOCON peripheral clock (for SWO on PIO0-15 or PIO1_1) &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;// by setting bit13 via SYSAHBCLKCTRLSET[0] (0x400000C8) &lt;/STRONG&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;*SYSAHBCLKCTRLSET = 1 &amp;lt;&amp;lt; 13; // 0x2000&lt;/STRONG&gt;

&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Note that later versions of the LPCOpen package for LPC5410x should contain appropriate trace clock setup code in the startup file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId--1653079359"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;SWO pinmux configuration&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On LPCXpresso54102 boards, pin P0_15 is connected to SWO of the debug connector. This needs configuring in the pinmux settings for your project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using the examples from the LPCOpen v2.14.1 package for the LPCXpresso5410x board, then you need to modify the pinmux settings in &lt;STRONG&gt;board_sysinit.c&lt;/STRONG&gt; of the &lt;STRONG&gt;lpc_board_lpcxpresso_54102&lt;/STRONG&gt; library project, so that the SWO settings are not commented out by the #if 0 ... #endif clause (as they are by default). Thus after modifying the code, it should look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {0, 15, (IOCON_FUNC2 | IOCON_MODE_INACT | IOCON_DIGITAL_EN)}, /* SWO */&lt;/STRONG&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;#if 0&amp;nbsp; /* Debugger signals, do not touch */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {0, 16, (IOCON_FUNC5 | IOCON_MODE_INACT | IOCON_DIGITAL_EN)}, /* SWCLK_TCK */&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {0, 17, (IOCON_FUNC5 | IOCON_MODE_INACT | IOCON_DIGITAL_EN)}, /* SWDIO */&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;#endif&lt;/SPAN&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; that later versions of the LPCOpen package for LPC5410x should contain appropriate SWO pinmux setup code for the LPCXpresso54102 board in the board library.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;&lt;H1 id="toc-hId-286244481"&gt;For more information:&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389084" data-objecttype="1" href="https://community.nxp.com/thread/389084" rel="nofollow noopener noreferrer" target="_blank"&gt;Overview of Trace support in LPCXpresso IDE&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Mar 2016 23:10:13 GMT</pubDate>
    <dc:creator>lpcware-support</dc:creator>
    <dc:date>2016-03-31T23:10:13Z</dc:date>
    <item>
      <title>SWO Trace setup for LPC5410x</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/SWO-Trace-setup-for-LPC5410x/m-p/474104#M118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To carry out SWO Trace on &lt;STRONG&gt;LPC5410x&lt;/STRONG&gt;, it is necessary to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Ensure that your board has SWO pinned out to the debug connector&lt;/LI&gt;&lt;LI&gt;If using the built-in LPC-Link2 debug probe of a LPCXpresso54102 board, ensure that the probe is configured for DFU booting&lt;/LI&gt;&lt;LI&gt;Turn on the trace clock within the MCU, as this is not enabled by default&lt;/LI&gt;&lt;LI&gt;Configure the MCU pinmuxing, so that the SWO signal is accesible on the appropriate pin of the MCU&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should typically be done within each of your application projects (or library projects that your projects link against).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note : &lt;/STRONG&gt;SWO Trace on LPC5410x MCUs can only be carried out for debug sessions connected to the Cortex-M4 CPU, not to the Cortex-M0+.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId-1708424228"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;SWO pin and debug connector&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On LPCXpresso54102 boards, pin P0_15 is connected to SWO of the debug connector.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using a different board, you will need to check the schematics to identify if SWO is connected to the debug connector (and on which pin from the MCU).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId--843732733"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;Debug probe&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LPCXpresso54102 board is typically shipped with CMSIS-DAP firmware installed into the built-in LPC-Link2 debug probe that does not provide the necessary channels for SWO trace data transfer back to the host debugger. You need to configure your board so that the LPCXpresso IDE can softload "redlink" firmware. This is done by fitting a jumper on JP5, then repowering the board. For more details, please see &lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.nxp.com%2Fproducts%2Fmicrocontrollers-and-processors%2Farm-processors%2Flpc-cortex-m-mcus%2Fsoftware-and-tools-for-lpc-mcus%2Flpcxpresso-boards%3ALPCXPRESSO-BOARDS" rel="nofollow noopener noreferrer" target="_blank"&gt;LPCXpresso Boards|NXP&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId-899077602"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;Enabling the trace clock&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The startup code generated by the new project wizards for LPC5410x in LPCXpresso IDE v7.7 (and later) contain code to optionally turn on the trace clock.&amp;nbsp; By default this code will be enabled by the new project wizard, but if not required can be removed by defining the compiler symbol &lt;STRONG&gt;DONT_ENABLE_SWVTRACECLK&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using different startup code (for instance, as provided in the projects in the LPCOpen v2.14.1 package for the LPCXpresso5410x board), then you can add the following code to your project to turn on the trace clock&amp;nbsp; (for example right at the start of main() or in the startup file before the call to main() ) :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;volatile unsigned int *TRACECLKDIV = (unsigned int *) 0x400000E4; &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;volatile unsigned int *SYSAHBCLKCTRLSET = (unsigned int *) 0x400000C8; &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;// Write 0x00000001 to TRACECLKDIV (0x400000E4) – Trace divider &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;*TRACECLKDIV = 1; &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;// Enable IOCON peripheral clock (for SWO on PIO0-15 or PIO1_1) &lt;/STRONG&gt;
&lt;STRONG style="font-family: courier new,courier;"&gt;// by setting bit13 via SYSAHBCLKCTRLSET[0] (0x400000C8) &lt;/STRONG&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;*SYSAHBCLKCTRLSET = 1 &amp;lt;&amp;lt; 13; // 0x2000&lt;/STRONG&gt;

&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Note that later versions of the LPCOpen package for LPC5410x should contain appropriate trace clock setup code in the startup file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H2 id="toc-hId--1653079359"&gt;&lt;SPAN style="color: #eb7a3d;"&gt;SWO pinmux configuration&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On LPCXpresso54102 boards, pin P0_15 is connected to SWO of the debug connector. This needs configuring in the pinmux settings for your project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using the examples from the LPCOpen v2.14.1 package for the LPCXpresso5410x board, then you need to modify the pinmux settings in &lt;STRONG&gt;board_sysinit.c&lt;/STRONG&gt; of the &lt;STRONG&gt;lpc_board_lpcxpresso_54102&lt;/STRONG&gt; library project, so that the SWO settings are not commented out by the #if 0 ... #endif clause (as they are by default). Thus after modifying the code, it should look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {0, 15, (IOCON_FUNC2 | IOCON_MODE_INACT | IOCON_DIGITAL_EN)}, /* SWO */&lt;/STRONG&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;#if 0&amp;nbsp; /* Debugger signals, do not touch */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {0, 16, (IOCON_FUNC5 | IOCON_MODE_INACT | IOCON_DIGITAL_EN)}, /* SWCLK_TCK */&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {0, 17, (IOCON_FUNC5 | IOCON_MODE_INACT | IOCON_DIGITAL_EN)}, /* SWDIO */&lt;/SPAN&gt;
&lt;SPAN style="font-family: courier new,courier;"&gt;#endif&lt;/SPAN&gt;

&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Note&lt;/STRONG&gt; that later versions of the LPCOpen package for LPC5410x should contain appropriate SWO pinmux setup code for the LPCXpresso54102 board in the board library.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;&lt;H1 id="toc-hId-286244481"&gt;For more information:&lt;/H1&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;A _jive_internal="true" data-containerid="11529" data-containertype="14" data-objectid="389084" data-objecttype="1" href="https://community.nxp.com/thread/389084" rel="nofollow noopener noreferrer" target="_blank"&gt;Overview of Trace support in LPCXpresso IDE&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Mar 2016 23:10:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE-FAQs/SWO-Trace-setup-for-LPC5410x/m-p/474104#M118</guid>
      <dc:creator>lpcware-support</dc:creator>
      <dc:date>2016-03-31T23:10:13Z</dc:date>
    </item>
  </channel>
</rss>

