element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
MaaXBoard Hardware Design MaaXBoard-RT: ITM_Print (SWO Viewer) - for you
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 0 replies
  • Subscribers 341 subscribers
  • Views 270 views
  • Users 0 members are here
  • trace
  • debug
  • MaaXBoard-RT
  • Maaxboard RT
  • ITM
  • SWO
Related

MaaXBoard-RT: ITM_Print (SWO Viewer) - for you

tjaekel
tjaekel over 2 years ago

I have converted a SDK project "hello_word" to MaaXBoard-RT and extended it to demonstrate how to use the ITM Trace as "ITM_Print" (with SWO Viewer in IDE).

The demo project is here:

GitHub - tjaekel/MaaXBoard-RT_ITM_Print: MaaXBoard-RT with SWO Viewer (ITM_Print)

You could also use my "big" (and actual) project which uses also ITM_Print (via command "test"):

GitHub - tjaekel/MaaXBoard-RT_SPIder: MaaXBoard-RT SPIder framework

What is ITM_Print?

ITM_Print uses the "SWO Viewer" (provided by the IDE, when running in Debug mode).

You can print messages via a Debugger channel (ITM Trace), using the SWO signal. You can see messages, when enabled (!), in SWO_Viewer window.
You can also input characters and receive it in your running FW (e.g. waiting for an interaction, take a value before keep going...).
It works like a UART (in and out, bi-directional), with these benefits:

  • you can keep code for ITM_Print in your project: the overhead ("runtime penalty" is very small
    if you do not enable in IDE - your project runs in almost full-speed as possible
  • Even you enable SWO_Viewer in IDE: the overhead is still very small:
    such an ITM_Print does not take huge amount of code, does not have a decrease on performance (speed)
  • All the messages go via a "Debug Channel", like a UART, but it is not an UART (not so slow, not so much code)
  • You have still the user UART available (like a second debug log channel)

ITM_Print is much faster as any real UART debug log (e.g. LPUART1 with 115200 baud rate).

How to enable ITM_Print?

You should take a file "retarget_ITM.c" to your project: get it from SDK repository or from the project(s) above.
It provides functions calls as:

int _write(int iFileHandle, char *pcBuffer, int iLength);
int _read(int iFileHandle, char *pcBuffer, int iLength);

You can also use from "cmsis_cm7.h":

__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch);
__STATIC_INLINE int32_t ITM_ReceiveChar (void);

Add in "pin_mux.c":

You have to add the config for the SWO signal (so that it comes out).
Add in file "pin_mux.c" these lines of code:

IOMUXC_SetPinMux(
IOMUXC_GPIO_LPSR_11_ARM_TRACE_SWO, /* GPIO_LPSR_11 is configured as ARM_TRACE_SWO */
0U);                               /* Software Input On Field: Input Path is determined by functionality */

IOMUXC_SetPinConfig(
IOMUXC_GPIO_LPSR_11_ARM_TRACE_SWO, /* GPIO_LPSR_11 PAD functional properties : */
0x02U);                            /* Slew Rate Field: Slow Slew Rate
                                      Drive Strength Field: high driver
                                      Pull / Keep Select Field: Pull Disable
                                      Pull Up / Down Config. Field: Weak pull down
                                      Open Drain LPSR Field: Disabled
                                      Domain write protection: Both cores are allowed
                                      Domain write protection lock: Neither of DWP bits is locked */

The clock configuration should be already done (in file "clock_config.c"), as:

/* Configure CSTRACE using SYS_PLL2_CLK */
rootCfg.mux = kCLOCK_CSTRACE_ClockRoot_MuxSysPll2Out;
rootCfg.div = 4;
CLOCK_SetRootClock(kCLOCK_Root_Cstrace, &rootCfg);

Remember, which clock will it generate for the ITM (SWO): in most of the cases, where the MCU clock is set to 996 MHz, it should be 132 MHz (remember both values).

How to enable and use "SWO_Viewer"?

When you start a debug session, open the "Perspective" for "SWO ITM Console" (and also "SWO Trace Config" : which can be invoked from the other one).

You have to configure ITM Trace first: in "SWO Trace Config" and "Configuration" click on "Change":
Provide as parameters:

Core Clock Speed (Hz) :   996000000  (or use "Detect": the clock speed is changed during startup!)
Trace Clock Speed (Hz) : 132000000  (related to the CSTRACE clock speed config above)

SWO_Viewer_Config

Start the SWO_Viewer (the "run" icon needs to be pressed).

Now, you should see all ITM_prints and you are able to use the "terminal" (Console) also for inputs (your FW waiting for something received).

SWO_Viewer_Config

SWO_Viewer

--> Don't forget to press on the "run" icon (the green arrow)

Very helpful feature and very fast log message without to compromise your performance in FW.
A second debug channel and no need to use a slow UART to watch your FW.

  • Sign in to reply
  • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube