How to send string through the SWO interface by calling printf() function ?

by <a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero Employee</font></font> </a> yucheng on ‎10-09-2017 03:37 AM

 

In addition to the debug signals of the SWD interface which allows normal debug operations and programming of the EFM32. The microcontroller also includes a SWO (Serial Wire Output) interface. SWO specifies a dedicated pin, which allows the CPU to output data on the dedicates pin via UART or Manchester protocol. This pin is unidirectional, so it is not possible to send data to the target CPU on this pin.

 

The SWO module formats and sends the data from the ITM (Instrumentation Trace Module). By having the software writing to the ITM-registers, data can be sent to the debugger through this one wire interface.

 

The following section demonstrates how to send string through the SWO interface to the Simplicity commander.

 

  1. Adding "#include <stdio.h>" is necessary for sending string by calling printf.
  2. To get the printf working in the application code in Simplicity IDE, you need to add the c file 'retargetio.c' to your project. The c file can be found in the SDK.  \sdks\gecko_sdk_suite\v1.1\hardware\kit\common\drivers\retargetio.c
  1. Set up the Serial Wire Output by calling the setupSWOForPrint() function.
  2. To print a single character use the CMSIS function ITM_SendChar(char c), or print a string use the printf() fucntion.

 

A simplicity studio project for EFM32TG be attached to demonstrate how to send signal character use ITM_SendChar(char c) and send string by calling printf().

 

Untitled.jpg