User`s manual

Copyright © Quantum Leaps, LLC. All Rights Reserved.
QDK™
Renesas RX with HEW
state-machine.com/rx
6 QS Software Tracing Instrumentation
Quantum Spy (QS) is a software tracing facility built into all QP components and also available to your
application code. QS allows you to gain unprecedented visibility into your application by selectively
logging almost all interesting events occurring within state machines, the framework, the kernel, and your
application code. QS software tracing is minimally intrusive, offers precise time-stamping, sophisticated
runtime filtering of events, and good data compression (please refer to “QSP Reference Manual” section
in the “QP/C Reference Manual” and also to Chapter 11 in [PSiCC2]).
This QDK demonstrates how to use the QS to generate real-time trace of a running QP application.
Normally, the QS instrumentation is inactive and does not add any overhead to your application, but you
can turn the instrumentation on by defining the Q_SPY macro and recompiling the code. In this QDK, this
means selecting and building the "Spy" variant of the code (as opposed to the Debug or Release variant).
QS can be configured to send the real-time data out of the serial port of the target device. On the
YRDKRX62N evaluation board, QS uses SCI2 in asynchronous (UART) mode to send the trace data out
of DB9 connector J5 "COMM PORT". The YRDKRX62N kit does not come with a serial cable, you will
need to provide this. In all likelihood, you will need to use a serial-to-USB cable/adapter as nowadays it is
difficult to find a computer with a standard DB9 serial port.
NOTE: This port uses the serial port (configured for 115,200 baud by default) as the output port for
sending QSPY trace data.
6.1 QS initialization in QS_onStartup()
The routine
QS_onStartup()
is invoked during initialization to initialize and configure the QSPY tracing
buffer, timing variables, and trace data transmit UART.
Listing 14: QS initialization in bsp.c
(1) uint8_t QS_onStartup(void const *arg) {
(2) static uint8_t qsBuf[6*256]; /* buffer for Quantum Spy */
(3) QS_initBuf(qsBuf, sizeof(qsBuf));
/* Configure & enable the serial interface used by QS */
(4) . . .
/* Initialize QS timing variables */
(5) QS_tickPeriod_ = TICK_COUNT_VAL;
(6) QS_tickTime_ = 0; /* count up timer starts at zero */
(7) QS_FILTER_ON(QS_ALL_RECORDS);
(8) QS_FILTER_OFF(QS_QF_ACTIVE_ADD);
. . .
QS_FILTER_OFF(QS_QF_ISR_EXIT);
(9) return (uint8_t)1; /* return success */
}
(1) The
QS_onStartup()
routine is called when the BSP is initialized through the macro QS_INIT().
(2) Trace data to be sent out the serial port is enqueued in this buffer. Adjust the size of this buffer
based on your application's tracing needs. The bursts of volume of data being traced / transmitted,
and the serial baud rate will impact the size required.
(3)
QS_initBuf()
is called to initialize the output buffer.
28 of 32