µVision4 User's Guide

Serial Window

Serial Window ButtonµVision4 provides several Serial Windows, including the Debug (printf) Viewer, for serial input and output, and lets you simulate the CPU's UART without the need for external hardware.

The serial output may be also assigned to a PC COM port using the ASSIGN command in the Command Window.

Serial data output from the simulated CPU is displayed in the window, while characters you type into the Serial Window are input to the simulated CPU.

The Debug (printf) Viewer also works on the target hardware, and displays serial data received from the Real-Time Agent (RT Agent) and, on Cortex-Mx microcontroller, the Instrumentation Trace Macrocell (ITM) printf data.

Input on this window is also sent to the RT Agent or, with some special target code (see CMSIS), to the Cortex-Mx.

Serial Window Display

Invoke the Context Menu to access the enhanced Serial Window features:

General Usability Improvements
  • Serial Window text can be saved to a file or to the Clipboard.
    For ASCII, HEX and Mixed Modes the actual visible window layout is used.
    For Terminal Mode the control sequence formatted view is saved.
  • As long as the last line is visible, the text will scroll automatically.
  • As soon as you start scrolling, the automatic scrolling stops, so that the text can be read easily.
Terminal Mode
Text formatting and cursor key terminal control sequences are available.

They allow an improved presentation of the text sent to a Serial Window, a better implementation of menus, command line editing, and command history.

Available control sequences are listed in the table at the end of the page.

ASCII Mode
Every printable character is displayed. An unprintable character is displayed as white-space (' ').
HEX Mode
Every character is displayed as a HEX-number.
Mixed Mode
Every character is displayed as a HEX-number and ASCII character. An unprintable character is displayed as dot ('.').
Settings - Add CR to LF
Adds a Carriage Return to every Line Feed that is received. This setting is enabled by default.

ANSI VT100 Terminal Sequences

SequenceDescription
 From Target ==> µVision4
CR ('\r')Carriage Return
LF ('\n')Line Feed
TAB ('\t')Tabulator
BS (0x08)Back Space
BEL (0x07)Bell
 
<ESC>[CMove cursor (position) 1 to the right
<ESC>[DMove cursor (position) 1 to the left
<ESC>[KDelete line right to cursor
 
<ESC>[JClear screen
<ESC>[y;xfSet cursor to Row y, Column x; (x,y) are numeric ASCII values
 From µVision4 ==> Target
<ESC>[ACursor Key UP
<ESC>[BCursor Key DOWN
<ESC>[CCursor Key RIGHT
<ESC>[DCursor Key LEFT

Examples

// Clear screen and set cursor home
void ClearScreen(void)
{
        printf("%c[1;1f%c[J", 27, 27);
}

// set cursor to position (x, y)
void SetCursorPosition(int x, int y)
{
        printf("%c[%i;%if", 27, (signed int)y, (signed int)x);
}