5.2 UART text message capture module

The testbench in Cortex®-M3 DesignStart™ Eval includes a UART text message capture module. The function of the UART capture module is to capture the input data, and output the received characters when it receives the Carriage Return (CR) character.

When a program wants to display a message in the simulation environment, it can execute the printf or puts functions. It can also directly call the UART routines to output the message to UART0.

When the program executes the printf or puts functions, the UART output routine executes through retargeting code and outputs the characters to the serial output of UART0. The UART capture module then captures the input data and outputs the characters when it receives the CR character.

The UART capture module captures the input data at 1 bit per cycle to reduce simulation time. This is because the high-speed test mode of the example system UART outputs each bit in one clock cycle to reduce simulation time.

If the UART outputs serial data at a different speed, then you must change the clock that connects to the UART capture module.

You can use the UART capture module to terminate a simulation. When it receives a character value of 0x4, unless it receives this character immediately following the ESC (0x1B) character, it stops the simulation using the $stop Verilog system task. Before the end of the simulation, the UART capture module outputs a pulse on the SIMULATIONEND output to enable you to use this signal to trigger other tasks or hardware logic before the end of a simulation.

You can also use the UART capture module to turn on the SPIs, I2Cs, and UARTs on both Arduino shields by sending a character value of 0xF.

In order for printf and puts to use the UART, stdout has been retargeted by using the following files:

  • m3designstart/software/common/retarget/retarget.c
  • m3designstart/software/common/retarget/uart_stdout.c
  • m3designstart/software/common/retarget/uart_stdout.h

If you are using the UART, it is also important to call UartStdOutInit() before making any printf calls.

The Keil® project files that are included with each of the integration tests all define an 'mps2' build target. If you use this target, the code is compiled with the FPGA_IMAGE define enabled, and the executable files are copied to a suitable 8:3 format file name. The retarget.c file uses the FPGA_IMAGE define to configure the UART for 38 400 Baud, so the tests can be run on the FPGA.

If you build targeting the FPGA, you must either copy the image from the /testcodes/<test>/mps2/ directory into the FPGA board local storage (and configure the correct image to load), or load the image using the debugger (with the mps2 target selected).

Non-ConfidentialPDF file icon PDF versionARM 100894_0000_00_en
Copyright © 2017 ARM Limited or its affiliates. All rights reserved.