UM08027 SystemView
UM08027 SystemView
SystemView
Recording and analyzing runtime
behavior of embedded systems
User Guide
Document: UM08027
Software Version: 3.52
Revision: 0
Date: July 4, 2023
www.segger.com
2
Disclaimer
The information written in this document is assumed to be accurate without guarantee. The
information in this manual is subject to change for functional or performance improvements
without notice. SEGGER Microcontroller GmbH (SEGGER) assumes no responsibility for any errors
or omissions in this document. SEGGER disclaims any warranties or conditions, express, implied
or statutory for the fitness of the product for a particular purpose. It is your sole responsibility
to evaluate the fitness of the product for any specific use.
Copyright notice
You may not extract portions of this manual or modify the PDF file in any way without the prior
written permission of SEGGER. The software described in this document is furnished under a
license and may only be used or copied in accordance with the terms of such a license.
© 2015 - 2023 SEGGER Microcontroller GmbH, Monheim am Rhein / Germany
Trademarks
Names mentioned in this manual may be trademarks of their respective companies.
Brand and product names are trademarks or registered trademarks of their respective holders.
Contact address
SEGGER Microcontroller GmbH
Ecolab-Allee 5
D-40789 Monheim am Rhein
Germany
Tel. +49-2173-99312-0
Fax. +49-2173-99312-28
E-mail: support@segger.com
Internet: www.segger.com
Credits
Special thanks to Jean Labrosse for continuous feedback, beta testing, and good ideas.
Manual versions
This manual describes the current software version. If you find an error in the manual or a
problem in the software, please inform us and we will try to assist you as soon as possible.
Contact us for further information on topics or functions that are not yet documented.
Print date: July 4, 2023
3.42 0 221208 PC
• Added Peak Load and Peak Used metrics to heap monitoring.
3.10 0 191213 JL
• Manual updated to SystemView V3.
2.52 4 180921 NV • Section “FreeRTOS” added Note about number of tasks displayed by
default.
2.52 3 180809 NV
• Section “No OS” added link to generic setup example.
2.52 2 180315 NV
• Section “FreeRTOS” updated for V10.
2.42 1 170306 AG
• Chapter “Supported CPUs” updated.
2.38 0 160624 JL
• Section “Renesas RX” to “Supported Devices” added.
2.32 1 160322 JL
• Chapter “Performance and resource usage” added.
2.32 0 160310 JL
• Section Supported OSes added.
2.26 1 160106 JL
Configuration for embOS and FreeRTOS added.
2.26 0 151223 JL
• Printf functionality added.
2.24 0 151216 JL
• macOS and Linux version added.
2.22 0 151214 JL
• GUI and performance improvements.
2.10 0 151106 JL
• Official Release.
2.09 0 151026 JL
• Initial Pre-Release.
Assumptions
This document assumes that you already have a solid knowledge of the following:
• The software tools used for building your application (assembler, linker, C compiler).
• The C programming language.
• The target processor.
• DOS command line.
If you feel that your knowledge of C is not sufficient, we recommend The C Programming Lan-
guage by Kernighan and Ritchie (ISBN 0--13--1103628), which describes the standard in C pro-
gramming and, in newer editions, also covers the ANSI C standard.
Table of contents
1 Overview ..................................................................................................................... 12
1.1 What is SEGGER SystemView? .......................................................................13
1.1.1 How does it work? ............................................................................ 13
1.1.2 What resources are required on the target side? ................................... 13
1.1.3 On which CPUs can SystemView be used? ............................................ 14
1.1.4 How much work is it to add it to a target system? .................................14
1.2 The SEGGER SystemView package ................................................................. 15
1.2.1 Download and installation .................................................................. 15
1.2.2 Package content ................................................................................15
1.3 Licensing .....................................................................................................18
1.3.1 Non-commercial license ..................................................................... 18
Overview
Windows Installer
Download the latest setup from http://www.segger.com/systemview and execute it. The
setup wizard guides through the installation.
After installation the package content can be accessed through the Windows Start menu
or from the file explorer.
macOS Installer
Download the latest pkg installer from http://www.segger.com/systemview and execute it.
The package installer guides through the installation.
After installation the SystemView Application can be accessed through Launchpad.
Linux Requirements
To run SystemView on Linux the Qt V4.8 libraries have to be installed on the system.
Linux Installer
Download the latest DEB or RPM installer for your Linux from http://www.segger.com/sys-
temview and execute it. The software installer guides through the installation.
Target Sources
Download the latest sources to be included in the embedded application from http://
www.segger.com/systemview and extract it to a folder of your choice.
Sources to interface with SEGGER software, such as embOS are also included.
SystemView package
File Description
File Description
File Description
1.3 Licensing
SystemView can be used free of charge for non-commercial purposes under SEGGER’s
Friendly License (https://www.segger.com/license-sfl). For any other use a commercial-use
license is required.
There are no feature limitations with a non-commercial license. SystemView enables un-
limited recording and comes with features for better analysis, search, and filtering.
Commercial-use licenses for SystemView are available as single-user licenses as well as
group or company-wide licenses. For more information refer to SEGGER’s Commercial-use
License (https://www.segger.com/license-cul).
This section describes how to get started with SEGGER SystemView. It explains how to
analyze an application based on monitored data.
This chapter refers to the sample data file OS_IP_WebServer.SVDat which is part of the
SEGGER SystemView package.
The sample data file shows the behavior of a target system running the embOS RTOS, the
emNet TCP/IP stack and a web server application.
We are going to analyze what the application is doing with the information from SEGGER
SystemView.
System Information
The System Information dialog, shown after loading the data, provides a first overview on
the recording. It displays information about the target system, the recording and statistical
information of tasks, interrupts, and events. The system information is reported by the
application, therefore SystemView does not require any additional configuration to analyze
and display the system behavior.
Timeline
SystemView Timeline
The Timeline window shows the complete monitored data. In the Events list, scroll to the
first item to get started.
The Timeline window visualizes the system activity by context (task, interrupt, scheduler
and idle) over the system time. Each row refers to one context item and we can see all
items which have been used in the application while it has been monitored.
At the beginning we can see that there are two tasks, IP_Task and IP_WebServer, indicated
by the light background in the context row.
Zoom in to a timeline width of 2.0 ms and double-click on the vertical line below ’+1. 0 ms’
to center and select the item. (Use the mouse wheel or the [+]/[-] keys to zoom, or use
the menu or context menu to set the zoom level to a distinct value.)
There is some system activity every millisecond from the SysTick interrupt.
Move the mouse over a context name to get more information about the context type and
run time information.
Click on the right arrow button of the IP_Task context to jump to its next execution.
Zoom in or out to show the activity in detail.
We can see the SysTick interrupt returned to the OS Scheduler, which makes the IP_Task
ready, indicated by the grey bar in the IP_Task’s row, and lets it run. The IP_Task returns
from the embOS API function OS_TASKEVENT_GetTimed with return value 0, which indicates
that no event has been signaled in time.
The IP_Task calls three other embOS API functions which quickly return and OS_TASKEVEN-
T_GetTimed, which activates the scheduler, deactivates the task, and puts the system into
idle. IP_Task will be activated again when the event (EventMask = 1) occurs or after the
timeout of 10 ticks (i.e. 10.0 ms, as a tick occures every 1.0 ms).
Recorded function calls are visualized in the timeline as small bars in the context row.
The vertical peak line indicates the call of a function, the bar shows the length of the call.
Stacked bars visualize nested function calls.
Move the mouse over the context activity to get more information about context runtime,
events and function calls.
Conclusion
We have got some first information about the monitored system. From the Timeline we
know which tasks and interrupts are used by the application, that it is controlled by the
1 kHz SysTick interrupt, and the IP_Task is activated at least every 10 ms.
Events list
The Events list shows all events as they are reported from the system and displays their
information, including timestamp of the event, active context, type of event and event
details. It is synchronized with the Timeline.
We have seen that every millisecond the SysTick ISR enters and exits and that it activates
the IP_Task every 10 ms because its timeout occurred.
Go to event #66 with Go →Goto Event… (Keyboard shortcut: Ctrl+G). It is a call of
OS_TASKEVENT_GetTimed with a timeout of 10 ms from the IP_Task at 00.016 052 607.
The timeout would happen at 00.026 052 607.
Set a time reference on the event (View →Toggle Reference, Right-Click → Toggle Ref-
erence, or (Keyboard shortcut R). All following timestamps in the Events list are measured
from the latest reference.
To now see whether the IP_Task runs because of the timeout or because of the event it
waits for, go to the next activity of IP_Task with Go →Forward (Keyboard shortcut: F).
The timestamp is 00.003 467 857, so 3 ms after the last reference and clearly before the
10 ms timeout. So the task has been activated by the event it waited for.
We can see the ETH_Rx interrupt happened before. We received a packet via ethernet (60
Bytes on interface 0). Therefore the ETH_Rx interrupt signaled the event, which marked the
task as ready as indicated in the timeline. The ETH_Rx interrupt returns to the Scheduler.
IP_Task runs and returns from OS_TASKEVENT_GetTimed with return value 0b1, indicating
that this event happened.
Conclusion
Going further through the events, we can see that the IP_Task is activated after the 10 ms
timeout occurred or after we received something and the ETH_Rx interrupt occurred.
Note: Tasks are ordered by priority in the Timeline, the exact task priority can be seen
in the Contexts window.
3.1 Introduction
SystemView Application
The SystemView Application is the host PC visualization tool for SEGGER SystemView. It
connects to the target application, controls the system events and reads its data. The mon-
itored data is analyzed on runtime and visualized in the different windows of SystemView.
After recording has stopped, the data can be saved to a file which allows later analysis of
the application trace.
To get started with SystemView please refer to the previous chapter.
SystemView provides different windows to visualize the execution in the system, measure
timing and analyze the CPU load. All windows are synchronized to always get all information
of the currently selected state.
For a description of the application windows please refer to the following sections.
SystemView allows going through the monitored data and keeping track of what happened
in the system at any time.
3.2 Timeline
SystemView Timeline
The Timeline window gathers all system information within one view. It shows the system
activity by context (task, interrupt, scheduler, timer and idle) over the system time. Each
row refers to one context item to show all context items which have been used in the
application while it has been monitored.
A mouse-over tooltip on the context items reveals more details and run time information
about the context.
A mouse-over tooltip on context activity shows the details of the current event and the
invokated functions if available.
A ruler shown on mouse-over on context activity, marks the activity time span.
A tasks life time is marked with a light background from creation to termination to provide
a quick overview which tasks exist at any time.
Switches between contexts are displayed as connection lines to easily identify which events
cause context switches and when they occurred.
Tasks which are marked ready for execution are displayed with a light grey bar until their
execution starts.
Contexts are ordered by priority. The first row displays all activity in a unified context.
Interrupts are top of the list, ordered by Id. Followed by the Scheduler and software timers,
if they are used in the system. Below the Scheduler (and timer) the tasks are ordered by
priority. The bottom context displays idle time, when no other context is active.
The Timeline is synchronized with the Events list. The event marker (the blue line or range)
matches the event selection in the Events list.
The corresponding context label is highlighted when context under the event marker is
active.
The marker can be fixed at 10% to 90% of the window and update the selection in the
Events list when scrolling through the timeline.
An event can be dragged under the event marker to select the corresponding event in the
Events list and vice-versa.
To get an overview of the whole system or to see the exact duration of an event the Timeline
view can be zoomed in or out.
To jump to the next or previous activity of a context, the context labels include buttons
for forward and backward naviagtion on mouse-over, or use the shortcut keys F and B,
respectively.
3.4 Terminal
SystemView Terminal
The Terminal window shows printf() output from the target application next to the task
context from which the output has been sent and the timestamp when the message was
sent.
Double-click on a message to show it with all information in the Events list.
The Timeline window also displays indicators for output. When indicators overlapping in
display they are ordered by severity level - Errors are shown always on top. The minimum
severity level for output indicators to be displayed in Timeline can be configured via View
→ Message Indicators….
SystemView printf output (SEGGER_SYSVIEW_Print*) can be sent formatted by the ap-
plication or unformatted with all parameters for formatted display by the SystemView ap-
plication.
3.6 Contexts
SystemView Contexts
The Contexts window shows statistical information for each reported context (Tasks, Inter-
rupts, Scheduler, Timer, and Idle). Each context can be identified by its Name and Type.
The Type includes the priority for tasks and the ID for interrupts (e.g. the Cortex-M SysTick
is interrupt ID #15.)
The Contexts window information include following items:
• The context name and type.
• Stack information for tasks, if available.
• Number of activations of the context.
• Total, Min and Max Blocked Time, total, minimal and maximal duration the context was
ready, but not active, respectively.
• Total Run Time, total time the context was active.
• Time Interrupted, total time the context was suspended by interrupts.
• CPU Load, ratio of contexts active time to complete recorded time.
• Last, Min and Max Run Time, the duration of the latest, shortest and longest time the
context was active, respectively.
• Min and Max Run Time/s, the minimal and maximal contexts active time in the last
recorded second.
The Contexts window is updated during the recording.
3.7 Runtime
SystemView Runtime
The Runtime window displays statistical measures for every context regarding its active
time. The measures shown are (over all invocations of a certain context):
• Minimal active time,
• Quartiles (25%, 50%, 75%)
• Maximal active time.
The statistical measures will be shown on request as a box plot over activation time as
multiples of 1 or 5 * 10N cycles as reported by target. N is chosen dynamically so, that
the until then appearing maximum active time will fit. The histogram of duration samples
always consists of 100 bins over the box plot span for a certain context.
3.8 Heap
SystemView Heap
The Heap window records allocations and deallocations of dynamic memory recorded us-
ing SEGGER_RTL_HeapAlloc(), SEGGER_RTL_HeapFree(), and other heap-related API func-
tions.
Each allocation or deallocation event updates SystemView’s model of one or more heaps
maintained by the application. SystemView maintains this model and each allocation and
deallocation event in the Event and Heap window shows the state of this model. If event
overflow causes allocation or deallocation events to be lost, the model of the heap becomed
invalid.
3.9 System
SystemView System
The System window displays:
• Target System, information about the system, which has been reported by the
application to identify it. Also located in this section are user-settable properties for
configuring the display of operating system, module and system events.
• Recording information, like Number of Events, the average and peak event frequency
and additional user provided meta-information about the record.
• Analysis information, statistical information about the analysis phase of recording.
• Statistics about tasks, interrupts, timers and other SystemView events.
The Target System information include i.a. the application name, the running OS, informa-
tion about the target hardware, and timing information. Additional information about task
switches and interrupt frequency provide a quick overview of the system.
The properties and meta-information settable by the user are saved with the record and
allow identification and pre-set configuration of a record for later analysis.
Start recording
To start continuous recording, connect the target and the chosen recorder interface.
Select Target →Start Recording. On the first start of SystemView, the recorder configu-
ration is opened. The configuration is saved for subsequent recordings. To switch to another
recorder or change the configuration, select Target →Recorder Configuration.
When the recorder is configured, SystemView connects and starts recording.
Stop recording
To stop recording select Target →Stop Recording.
Note
For RTT Control Block Auto Detection, as well as to properly connect to a device, the
exact device has to be known. It is recommended to not select a generic core instead.
Select the target interface and target interface speed for the connected device.
Configure the RTT Control Block Detection. In most cases Auto Detection can be used. If the
RTT Control Block can not be detected, get the address of _SEGGER_RTT from the application
or its map file and enter it, or enter a Search Range in which the symbol might be located
in the format <StartAddress> <Size>, for example 0x10000000 0x10000.
Note
SystemView can be used parallel to a debugger. In this case recording can be done
while the debugger is running. Make sure all required configuration is done in the
debugger. When the debugger is stopped, SystemView recording will stop, too.
With a J-Link debug probe and the SEGGER Real Time Transfer technology (RTT), Sys-
temView can continuously record target execution in real time, while the target is running.
RTT requires the ability of reading memory via the debug interface during program execu-
tion. This especially includes ARM Cortex-M0, M0+, M1, M3, M4 and M7 processors as well
as all Renesas RX devices.
3.13.1.2 IP Recorder
The SystemView IP Recorder connects to its counterpart running on the target device.
On the target the “IP Recorder host” is running and accepting connections form the Sys-
temView Application to send its data to.
Select the IP of the target device and the port (default: 19111).
Note
To get as much useful data for analysis as possible it is recommended to use a large buffer
for SystemView, 8 kByte or more. External RAM can be used for the SystemView buffer.
To configure the target system for post-mortem mode, please refer to SEG-
GER_SYSVIEW_POST_MORTEM_MODE on page 66 and SEGGER_SYSVIEW_SYNC_PERIOD_SHIFT
on page 67.
This section describes how to add the SystemView modules to a target system.
File Description
Example
For a system with embOS on a Cortex-M3 include /Sample/embOS/Config/Cor-
tex-M/SEGGER_SYSVIEW_Config_embOS.c, /Sample/embOS/SEGGER_SYSVIEW_embOS.c and
/Sample/embOS/SEGGER_SYSVIEW_embOS.h.
For a system with no OS or no instrumented OS on a Cortex-M3 include /Sample/NoOS/
Config/Cortex-M/SEGGER_SYSVIEW_Config_NoOS.c only.
#include "SEGGER_SYSVIEW.h"
/*********************************************************************
*
* main()
*
* Function description
* Application entry point
*/
int main(void) {
OS_IncDI(); /* Initially disable interrupts */
OS_InitKern(); /* Initialize OS */
OS_InitHW(); /* Initialize Hardware for OS */
BSP_Init(); /* Initialize BSP module */
The generic part of SEGGER SystemView is now ready to monitor the application.
When using embOS V4.12 or later with profiling enabled, SystemView events for ISRs,
Task, and API calls are generated. When not using embOS, appropriate events must be
generated by the application.
Download the application to the target and let it run. As long as the SystemView Application
is not connected, and SEGGER_SYSVIEW_Start() is not called, the application will not gen-
erate SystemView events. When SystemView is connected or SEGGER_SYSVIEW_Start() is
called it will activate recording SystemView events.
/*********************************************************************
* (c) SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
File : SEGGER_SYSVIEW_Config_embOS.c
Purpose : Sample setup configuration of SystemView with embOS.
Revision: $Rev: 25330 $
*/
#include "RTOS.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_embOS.h"
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
#define DEMCR (*(volatile U32*) (0xE000EDFCuL))
// Debug Exception and Monitor Control Register
#define TRACEENA_BIT (1uL << 24) // Trace enable bit
#define DWT_CTRL (*(volatile U32*) (0xE0001000uL)) // DWT Control Register
#define NOCYCCNT_BIT (1uL << 25)
// Cycle counter support bit
#define CYCCNTENA_BIT (1uL << 0)
// Cycle counter enable bit
//
// If events will be recorded without a debug probe (J-Link) attached,
// enable the cycle counter
//
#define ENABLE_DWT_CYCCNT (SEGGER_SYSVIEW_POST_MORTEM_MODE || SEGGER_SYSVIEW_USE_INTERNAL_RECORDE
/*********************************************************************
*
* Local functions
*
**********************************************************************
*/
/*********************************************************************
*
* _cbSendSystemDesc()
*
* Function description
* Sends SystemView description strings.
*/
static void _cbSendSystemDesc(void) {
SEGGER_SYSVIEW_SendSysDesc("N=" SEGGER_SYSVIEW_APP_NAME ",O=embOS,D=" SEGGER_SYSVIEW_DEVICE_NAM
#ifdef SEGGER_SYSVIEW_SYSDESC0
SEGGER_SYSVIEW_SendSysDesc(SEGGER_SYSVIEW_SYSDESC0);
#endif
#ifdef SEGGER_SYSVIEW_SYSDESC1
SEGGER_SYSVIEW_SendSysDesc(SEGGER_SYSVIEW_SYSDESC1);
#endif
#ifdef SEGGER_SYSVIEW_SYSDESC2
SEGGER_SYSVIEW_SendSysDesc(SEGGER_SYSVIEW_SYSDESC2);
#endif
}
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* SEGGER_SYSVIEW_Conf()
*
* Function description
* Configure and initialize SystemView and register it with embOS.
*
* Additional information
* If enabled, SEGGER_SYSVIEW_Conf() will also immediately start
* recording events with SystemView.
*/
void SEGGER_SYSVIEW_Conf(void) {
#if ENABLE_DWT_CYCCNT
//
// If no debugger is connected, the DWT must be enabled by the application
//
if ((DEMCR & TRACEENA_BIT) == 0) {
DEMCR |= TRACEENA_BIT;
}
#endif
//
// The cycle counter must be activated in order
// to use time related functions.
//
if ((DWT_CTRL & NOCYCCNT_BIT) == 0) { // Cycle counter supported?
if ((DWT_CTRL & CYCCNTENA_BIT) == 0) { // Cycle counter not enabled?
DWT_CTRL |= CYCCNTENA_BIT; // Enable Cycle counter
}
}
SEGGER_SYSVIEW_Init(SEGGER_SYSVIEW_TIMESTAMP_FREQ, SEGGER_SYSVIEW_CPU_FREQ,
&SYSVIEW_X_OS_TraceAPI, _cbSendSystemDesc);
OS_SetTraceAPI(&embOS_TraceAPI_SYSVIEW); // Configure embOS to use SYSVIEW.
#if SEGGER_SYSVIEW_START_ON_INIT
SEGGER_SYSVIEW_Start();
// Start recording to catch system initialization.
#endif
}
4.5.1.1 SEGGER_SYSVIEW_GET_TIMESTAMP()
Function macro to retrieve the system timestamp for SystemView events.
On Cortex-M3/4/7 devices the Cortex-M cycle counter can be used as system timestamp.
Default on Cortex-M3/4/7: (*(U32 *)(0xE0001004))
On most other devices the system timestamp has to be generated by a timer. With the de-
fault configuration the system timestamp is retrieved via the user-provided function SEG-
GER_SYSVIEW_X_GetTimestamp().
Default on other cores: SEGGER_SYSVIEW_X_GetTimestamp()
For an example, please refer to Sample/embOS/Config/Cortex-M0/SEGGER_SYSVIEW_Con-
fig_embOS_CM0.c or Sample/NoOS/Config/RX/SEGGER_SYSVIEW_Config_NoOS_RX.c
Note
4.5.1.2 SEGGER_SYSVIEW_TIMESTAMP_BITS
Number of valid low-order bits delivered by clock source as system timestamp.
If an unmodified clock source is used as system timestamp, the number of valid bits is the
bit-width of the clock source (e.g. 32 or 16 bit).
Default: 32 (32-bit clock source used)
4.5.1.3 SEGGER_SYSVIEW_GET_INTERRUPT_ID()
Function macro to get the currently active interrupt.
On Cortex-M devices the active vector can be read from the ICSR.
Default on Cortex-M3/4/7: ((*(U32*)(0xE000ED04)) & 0x1FF)
Default on Cortex-M0/1: ((*(U32*)(0xE000ED04)) & 0x3F)
On other devices the active interrupt can either be retrieved from the interrupt controller
directly, can be saved in a variable in the generic interrupt handler, or has to be assigned
manually in each interrupt routine.
By default this can be done with the user-provided function SEGGER_SYSVIEW_X_GetInter-
ruptId() or by replacing the macro definition.
For an example refer to Sample/embOS/Config/RX/SEGGER_SYSVIEW_Config_embOS_RX.c
or Cortex-A/R Interrupt ID on page 93.
4.5.1.4 SEGGER_SYSVIEW_LOCK()
Function macro to recursively lock SystemView transfers from being interrupted. I.e. disable
interrupts.
SEGGER_SYSVIEW_LOCK() must preserve the previous lock state to be restored in SEG-
GER_SYSVIEW_UNLOCK().
Recording a SystemView event must not be interrupted by recording another event. There-
fore all interrupts which are recorded by SystemView (call SEGGER_SYSVIEW_RecordEn-
terISR / SEGGER_SYSVIEW_RecordExitISR), call an instrumented function (e.g. an OS API
function), cause an immediate context switch, or possibly create any other SystemView
event must be disabled.
SEGGER_SYSVIEW_LOCK() can use the same locking mechanism as SEGGER_RTT_LOCK().
Default: SEGGER_RTT_LOCK()
SEGGER_RTT_LOCK() is defined for most systems (for example Cortex-M devices with Em-
bedded Studio, GCC, IAR or Keil ARM, and RX devices with IAR) in SEGGER_RTT_Conf.h. If
the macro is not defined, or empty, it has to be provided to match the target system.
4.5.1.5 SEGGER_SYSVIEW_UNLOCK()
Function macro to recursively unlock SystemView transfers from being interrupted. I.e.
restore previous interrupt state.
SEGGER_SYSVIEW_UNLOCK() can use the same locking mechanism as SEGGER_RTT_UN-
LOCK().
Default: SEGGER_RTT_UNLOCK()
SEGGER_RTT_UNLOCK() is defined for most systems (for example Cortex-M devices with
Embedded Studio, GCC, IAR or Keil ARM, and RX devices with IAR) in SEGGER_RTT_Conf.h.
If the macro is not defined, or empty, it has to be provided to match the target system.
4.5.2.1 SEGGER_SYSVIEW_RTT_BUFFER_SIZE
Number of bytes that SystemView uses for the recording buffer.
For continuous recording a buffer of 1024 bytes is sufficient in most cases. Depending on
the target interface speed, the target speed and the system load the buffer size might be
increased to up to 4096 bytes.
For single-shot recording the buffer size determines the number of events which can be
recorded. A system might generate between 10 and 200 kByte/s, depending on its load.
A buffer of at least 8 kByte, up to the whole free RAM space is recommended. The buffer
can also be in external RAM.
For post-mortem analysis the buffer size determines the maximum number of events which
will be available for analysis. A system might generate between 10 and 200 kByte/s, de-
pending on its load. A buffer of at least 8 kByte, up to the whole free RAM space is recom-
mended. The buffer can also be in external RAM.
Default: 1024 bytes
4.5.2.2 SEGGER_SYSVIEW_RTT_CHANNEL
The RTT Channel used for SystemView event recording and communication. 0: Auto selec-
tion
Note
Default: 0
4.5.2.3 SEGGER_SYSVIEW_USE_STATIC_BUFFER
If set to 1 SystemView uses a static buffer to create SystemView events. This in general
saves space, since only one buffer is required and task stacks can be as small as possible.
When a static buffer is used, critical code executed between SystemView locking invocations
takes slightly longer.
If set to 0 SystemView events are created on the stack. Make sure all task stacks, as well
as the C stack for interrupts are large enough to hold the largest SystemView events (~228
bytes). SystemView locks only while transferring the stack buffer into the RTT buffer.
Default: 1
4.5.2.4 SEGGER_SYSVIEW_POST_MORTEM_MODE
If set to 1 post-mortem analysis mode is enabled.
In post-mortem mode, SystemView uses a cyclical buffer and preserves all events up to
the final recorded even rather than dropping events when the buffer is full.
Note
Do not use post-mortem analysis mode when an attached J-Link actively reads RTT
data.
Default: 0
4.5.2.5 SEGGER_SYSVIEW_SYNC_PERIOD_SHIFT
Configure how often Sync and System Info events are sent in post-mortem mode. Make
sure at least one sync is available in the SystemView buffer.
The recommended sync frequency is Buffer Size / 16
Default: 8 = Sync every 256 Packets
4.5.2.6 SEGGER_SYSVIEW_ID_BASE
Value to be subtracted from IDs recorded in SystemView packets.
IDs are TaskIds, TimerIds, and ResourceIds, which are usually pointers to a structure in
RAM. Parameters sent in OS and middleware API events can also be encoded as IDs by
the instrumentation.
Note
If the instrumented OS does not use pointers for TaskIds, TimerIds, or ResourceIds,
SEGGER_SYSVIEW_ID_BASE must be set to 0.
4.5.2.7 SEGGER_SYSVIEW_ID_SHIFT
Number of bits to shift IDs recorded in SystemView packets.
IDs are TaskIds, TimerIds, and ResourceIds, which are usually pointers to a structure in
RAM. Parameters sent in OS and middleware API events can also be encoded as IDs by
the instrumentation.
Note
If the instrumented OS does not use pointers for TaskIds, TimerIds, or ResourceIds,
SEGGER_SYSVIEW_ID_SHIFT must be set to 0.
As SystemView packets use a variable-length encoding for pointers, correctly shifting ad-
dresses can save both buffer space and bandwidth.
For most applications on 32-bit processors, all IDs recorded in SystemView events are really
pointers and as such multiples of 4, so that the lowest 2 bits can be safely ignored.
In case of doubt define SEGGER_SYSVIEW_ID_SHIFT as 0.
Default: 2
4.5.2.8 SEGGER_SYSVIEW_MAX_STRING_LEN
Maximum string length to be recorded by SystemView events.
Strings are used in the SystemView printf-style user functions, as well as in
SEGGER_SYSVIEW_SendSysDesc() and SEGGER_SYSVIEW_RecordModuleDescription. Make
sure SEGGER_SYSVIEW_MAX_STRING_LEN matches the string length used in these functions.
Default: 128
4.5.2.9 SEGGER_SYSVIEW_MAX_ARGUMENTS
Maximum number of arguments to be sent with SEGGER_SYSVIEW_PrintfHost,
SEGGER_SYSVIEW_PrintfHostEx, SEGGER_SYSVIEW_WarnfHost, and SEGGER_SYSVIEW_Er-
rorfHost.
If these functions are not used in the application SEGGER_SYSVIEW_MAX_ARGUMENTS can be
set to 0 to minimize the static buffer size.
Default: 16
4.5.2.10 SEGGER_SYSVIEW_BUFFER_SECTION
The SystemView RTT Buffer may be placed into a dedicated section, instead of the default
data section. This allows placing the buffer into external memory or at a given address.
When SEGGER_SYSVIEW_BUFFER_SECTION is defined, the section has to be defined in the
linker script.
Default: SEGGER_RTT_SECTION or not defined
//
// SEGGER_SYSVIEW_Conf.h
//
#define SEGGER_SYSVIEW_BUFFER_SECTION "SYSTEMVIEW_RAM"
//
// flash_placement.xml
//
<MemorySegment name="ExtRAM">
<ProgramSection load="No" name="SYSTEMVIEW_RAM" start="0x40000000" />
</MemorySegment>
4.5.3.1 BUFFER_SIZE_UP
Number of bytes to be used for the RTT Terminal output channel.
RTT can be used for printf terminal output without modification. BUFFER_SIZE_UP defines
how many bytes can be buffered for this.
If RTT Terminal output is not used, define BUFFER_SIZE_UP to its minimum of 4.
Default: 1024 Bytes
4.5.3.2 BUFFER_SIZE_DOWN
Number of bytes to be used for the RTT Terminal input channel.
RTT can receive input from the host on the terminal input channel. BUFFER_SIZE_DOWN
defines how many bytes can be buffered and therefore sent at once from the host.
If RTT Terminal input is not used, define BUFFER_SIZE_DOWN to its minimum of 4.
Default: 16 Bytes
4.5.3.3 SEGGER_RTT_MAX_NUM_UP_BUFFERS
Maximum number of RTT up (to host) buffers. Buffer 0 is always used for RTT terminal
output, so to use it with SystemView SEGGER_RTT_MAX_NUM_UP_BUFFERS has to be at least 2.
Default: 2
4.5.3.4 SEGGER_RTT_MAX_NUM_DOWN_BUFFERS
Maximum number of RTT down (to target) buffers. Buffer 0 is always used for RTT terminal
input, so to use it with SystemView SEGGER_RTT_MAX_NUM_UP_BUFFERS has to be at least 2.
Default: 2
4.5.3.5 SEGGER_RTT_MODE_DEFAULT
Mode for pre-initialized RTT terminal channel (buffer 0).
Default: SEGGER_RTT_MODE_NO_BLOCK_SKIP
4.5.3.6 SEGGER_RTT_PRINTF_BUFFER_SIZE
Size of buffer for RTT printf to bulk-send chars via RTT. Can be defined as 0 if SEGGER_RT-
T_Printf is not used.
Default: 64
4.5.3.7 SEGGER_RTT_SECTION
The RTT Control Block may be placed into a dedicated section, instead of the default data
section. This allows placing it at a known address to be able to use the J-Link auto-detection
or easily specify a search range.
When SEGGER_RTT_SECTION is defined, the application has to make sure the section is
valid, either by initializing it with 0 in the startup code or explicitly calling SEGGER_RT-
T_Init() at the start of the application. SEGGER_RTT_Init() is implicitly called by SEG-
GER_SYSVIEW_Init().
Default: not defined
4.5.3.8 SEGGER_RTT_BUFFER_SECTION
The RTT terminal buffer may be placed into a dedicated section, instead of the default data
section. This allows placing the buffer into external memory or at a given address.
Default: SEGGER_RTT_SECTION or not defined
Shrink IDs
IDs are pointers to a symbol in RAM, for example a Task ID is a pointer to the task control
block. To minimize the length of recorded IDs they can be shrunken.
SEGGER_SYSVIEW_ID_BASE is subtracted from a pointer to get its ID. It can be set to sub-
tract the base RAM address from pointers, which still results in unique, but smaller IDs.
For example if the RAM range is 0x20000000 to 0x20001000 it is recommended to define
SEGGER_SYSVIEW_ID_BASE as 0x20000000, which results in the pointer 0x20000100 to have
the ID 0x100 and requires two instead of four bits to store it.
SEGGER_SYSVIEW_ID_SHIFT is the number of bits a pointer is shifted right to get its ID. If
all recorded pointers are 4 byte aligned, SEGGER_SYSVIEW_ID_SHIFT can be defined as 2.
A pointer 0x20000100 would then have the ID 0x8000040 or with the previous subtraction
of SEGGER_SYSVIEW_ID_BASE as 0x20000000 the ID would be 0x40, requiring only one byte
to be recorded.
Timestamp source
Event timestamps in SystemView are recorded as the difference of the timestamp to the
previous event. This saves buffer space per se.
While it is recommended to use a timestamp source with the CPU clock frequency for highest
time resolution, a lower timestamp frequency might save additional buffer space as the
timestamp delta is lower.
With a CPU clock frequency of 160 MHz the timestamp might be shifted by 4, resulting in
a timestamp frequency of 10 MHz (100 ns resolution), and 4 bits less to be encoded.
When the timestamp size is not 32-bit any more, i.e. it wraps around before 0xFFFFFFFF,
SEGGER_SYSVIEW_TIMESTAMP_BITS has to be defined as the timestamp size, e.g. as 28
when shifting a 32-bit timestamp by 4.
Configuration:
//
// Use full cycle counter for higher precision
//
#define SEGGER_SYSVIEW_GET_TIMESTAMP() (*(U32 *)(0xE0001004))
#define SEGGER_SYSVIEW_TIMESTAMP_BITS (32)
//
// Use cycle counter divided by 16 for smaller size / bandwidth
//
#define SEGGER_SYSVIEW_GET_TIMESTAMP() ((*(U32 *)(0xE0001004)) >> 4)
#define SEGGER_SYSVIEW_TIMESTAMP_BITS (28)
4.6.1.2 Interrupt ID
The currently active interrupt can be directly identified by reading the Cortex-M ICSR[8:0],
which is the active vector field in the interrupt controller status register (ICSR).
Configuration:
//
// Get the interrupt Id by reading the Cortex-M ICSR[8:0]
//
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x1FF)
By default the priority mask is set to 32, disabling all interrupts with a priority of 32 or
lower (higher numerical value).
Make sure to mask all interrupts which can send RTT data, i.e. generate SystemView events,
or cause task switches. When high-priority interrupts must not be masked while sending
RTT data, SEGGER_RTT_MAX_INTERRUPT_PRIORITY must be adjusted accordingly. (Higher
priority = lower priority number)
Default value for embOS: 128u
Default configuration in FreeRTOS: configMAX_SYSCALL_INTERRUPT_PRIORITY: ( con-
figLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
In case of doubt disable all interrupts.
Lock and unlock for SystemView and RTT can be the same.
Configuration:
//
// RTT locking for GCC toolchains in SEGGER_RTT_Conf.h
//
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, basepri \n\t" \
"mov r1, $32 \n\t" \
"msr basepri, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Conf.h
Purpose : SEGGER SysView configuration for Cortex-M3 / Cortex-M4.
*/
#ifndef SEGGER_SYSVIEW_CONF_H
#define SEGGER_SYSVIEW_CONF_H
/*********************************************************************
*
* SysView timestamp configuration
*/
// Cortex-M cycle counter.
#define SEGGER_SYSVIEW_GET_TIMESTAMP() ((*(U32 *)(0xE0001004)))
// Number of valid bits low-order delivered as timestamp.
#define SEGGER_SYSVIEW_TIMESTAMP_BITS 32
/*********************************************************************
*
* SysView Id configuration
*/
// Default value for the lowest Id reported by the application.
// Can be overridden by the application via SEGGER_SYSVIEW_SetRAMBase().
#define SEGGER_SYSVIEW_ID_BASE 0x20000000
// Number of bits to shift the Id to save bandwidth.
// (e.g. 2 when all reported Ids (pointers) are 4 byte aligned)
#define SEGGER_SYSVIEW_ID_SHIFT 0
/*********************************************************************
*
* SysView interrupt configuration
*/
// Get the currently active interrupt Id. (read Cortex-M ICSR[8:0]
= active vector)
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x1FF)
/*********************************************************************
*
* SysView locking
*/
// Lock SysView (nestable)
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
// Unlock SysView (nestable)
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_RTT_UNLOCK()
#endif
SEGGER_SYSVIEW_Config_NoOS_CM3.c
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
File : SEGGER_SYSVIEW_Config_NoOS.c
Purpose : Sample setup configuration of SystemView without an OS.
Revision: $Rev: 9599 $
*/
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_Conf.h"
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
// The application name to be displayed in SystemViewer
#define SYSVIEW_APP_NAME "Demo Application"
// Define as
1 if the Cortex-M cycle counter is used as SystemView timestamp. Must match SEGGER_SYSVIEW_Conf.
#ifndef USE_CYCCNT_TIMESTAMP
#define USE_CYCCNT_TIMESTAMP 1
#endif
// Define as
1 if the Cortex-M cycle counter is used and there might be no debugger attached while recording.
#ifndef ENABLE_DWT_CYCCNT
#define ENABLE_DWT_CYCCNT
(USE_CYCCNT_TIMESTAMP & SEGGER_SYSVIEW_POST_MORTEM_MODE)
#endif
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
#define DEMCR (*(volatile unsigned long*) (0xE000EDFCuL))
// Debug Exception and Monitor Control Register
#define TRACEENA_BIT (1uL << 24)
// Trace enable bit
#define DWT_CTRL (*(volatile unsigned long*) (0xE0001000uL))
// DWT Control Register
#define NOCYCCNT_BIT (1uL << 25)
// Cycle counter support bit
#define CYCCNTENA_BIT (1uL << 0)
// Cycle counter enable bit
/*********************************************************************
*
* _cbSendSystemDesc()
*
* Function description
* Sends SystemView description strings.
*/
static void _cbSendSystemDesc(void) {
SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",D="SYSVIEW_DEVICE_NAME);
SEGGER_SYSVIEW_SendSysDesc("I#15=SysTick");
}
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
void SEGGER_SYSVIEW_Conf(void) {
#if USE_CYCCNT_TIMESTAMP
#if ENABLE_DWT_CYCCNT
//
// If no debugger is connected, the DWT must be enabled by the application
//
if ((DEMCR & TRACEENA_BIT) == 0) {
DEMCR |= TRACEENA_BIT;
}
#endif
//
4.6.2 Cortex-M7
Same features / settings etc. as for Cortex-M4 apply. For more information, please refer
to Cortex-M3 / Cortex-M4 on page 82.
Cache
When placing the RTT buffer for SystemView into memory that is cacheable, the perfor-
mance is slightly lower (< 1% decrease in performance) for continuous recording mode via
J-Link and RTT. This is because J-Link must perform cache maintenance operations when
accessing the RTT buffer.
Configuration:
//
// SEGGER_SYSVIEW_TickCnt has to be defined in the module which
// handles the SysTick and must be incremented in the SysTick
// handler before any SYSVIEW event is generated.
//
// Example in embOS RTOSInit.c:
//
// unsigned int SEGGER_SYSVIEW_TickCnt; // <<-- Define SEGGER_SYSVIEW_TickCnt.
// void SysTick_Handler(void) {
// #if OS_PROFILE
// SEGGER_SYSVIEW_TickCnt++; // <<-- Increment SEGGER_SYSVIEW_TickCnt asap.
// #endif
// OS_EnterNestableInterrupt();
// OS_TICK_Handle();
// OS_LeaveNestableInterrupt();
// }
//
extern unsigned int SEGGER_SYSVIEW_TickCnt;
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
#define SCB_ICSR
(*(volatile U32*) (0xE000ED04uL)) // Interrupt Control State Register
#define SCB_ICSR_PENDSTSET_MASK (1UL << 26) // SysTick pending bit
#define SYST_RVR
(*(volatile U32*) (0xE000E014uL)) // SysTick Reload Value Register
#define SYST_CVR
(*(volatile U32*) (0xE000E018uL)) // SysTick Current Value Register
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetTimestamp()
*
* Function description
* Returns the current timestamp in ticks using the system tick
* count and the SysTick counter.
* All parameters of the SysTick have to be known and are set via
* configuration defines on top of the file.
*
* Return value
* The current timestamp.
*
* Additional information
* SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are
* disabled. Therefore locking here is not required.
*/
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
U32 TickCount;
U32 Cycles;
U32 CyclesPerTick;
//
// Get the cycles of the current system tick.
// SysTick is down-counting, subtract the current value from the number of cycles per tick.
//
CyclesPerTick = SYST_RVR + 1;
Cycles = (CyclesPerTick - SYST_CVR);
//
// Get the system tick count.
//
TickCount = SEGGER_SYSVIEW_TickCnt;
//
// If a SysTick interrupt is pending, re-read timer and adjust result
//
if ((SCB_ICSR & SCB_ICSR_PENDSTSET_MASK) != 0) {
Cycles = (CyclesPerTick - SYST_CVR);
TickCount++;
}
Cycles += TickCount * CyclesPerTick;
return Cycles;
}
Configuration:
//
// Get the interrupt Id by reading the Cortex-M ICSR[5:0]
//
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x3F)
Configuration:
//
// RTT locking for GCC toolchains in SEGGER_RTT_Conf.h
//
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs %0, primask \n\t" \
"mov r1, $1 \n\t" \
"msr primask, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
//
// Define SystemView locking in SEGGER_SYSVIEW_Conf.h
//
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_RTT_UNLOCK()
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Conf.h
Purpose : SEGGER SysView configuration for Cortex-M0, Cortex-M0+,
and Cortex-M1
*/
#ifndef SEGGER_SYSVIEW_CONF_H
#define SEGGER_SYSVIEW_CONF_H
/*********************************************************************
*
* SysView timestamp configuration
*/
// Retrieve a system timestamp via user-defined function
/*********************************************************************
*
* SysView Id configuration
*/
// Default value for the lowest Id reported by the application.
// Can be overridden by the application via SEGGER_SYSVIEW_SetRAMBase().
#define SEGGER_SYSVIEW_ID_BASE 0x20000000
// Number of bits to shift the Id to save bandwidth.
// (for example 2 when all reported Ids (pointers) are 4 byte aligned)
#define SEGGER_SYSVIEW_ID_SHIFT 0
/*********************************************************************
*
* SysView interrupt configuration
*/
// Get the currently active interrupt Id. (read Cortex-M ICSR[8:0]
= active vector)
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() ((*(U32 *)(0xE000ED04)) & 0x3F)
/*********************************************************************
*
* SysView locking
*/
// Lock SysView (nestable)
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
// Unlock SysView (nestable)
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_RTT_UNLOCK()
#endif
SEGGER_SYSVIEW_Config_embOS_CM0.c
/*********************************************************************
* (c) SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
File : SEGGER_SYSVIEW_Config_embOS_CM0.c
Purpose : Sample setup configuration of SystemView with embOS
on Cortex-M0/Cortex-M0+/Cortex-M1 systems which do not
have a cycle counter.
Revision: $Rev: 25330 $
Additional information:
SEGGER_SYSVIEW_TickCnt must be incremented in the SysTick
handler before any SYSVIEW event is generated.
void SysTick_Handler(void) {
#if (OS_PROFILE != 0)
SEGGER_SYSVIEW_TickCnt++; // Increment SEGGER_SYSVIEW_TickCnt before calling
OS_EnterNestableInterrupt().
#endif
OS_EnterNestableInterrupt();
OS_TICK_Handle();
OS_LeaveNestableInterrupt();
}
*/
#include "RTOS.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_embOS.h"
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
#define SCB_ICSR (*(volatile U32*) (0xE000ED04uL))
// Interrupt Control State Register
#define SCB_ICSR_PENDSTSET_MASK (1UL << 26) // SysTick pending bit
#define SYST_RVR (*(volatile U32*) (0xE000E014uL))
// SysTick Reload Value Register
#define SYST_CVR (*(volatile U32*) (0xE000E018uL))
// SysTick Current Value Register
/*********************************************************************
*
* Local functions
*
**********************************************************************
*/
/*********************************************************************
*
* _cbSendSystemDesc()
*
* Function description
* Sends SystemView description strings.
*/
static void _cbSendSystemDesc(void) {
SEGGER_SYSVIEW_SendSysDesc("N=" SEGGER_SYSVIEW_APP_NAME ",O=embOS,D=" SEGGER_SYSVIEW_DEVICE_NAM
#ifdef SEGGER_SYSVIEW_SYSDESC0
SEGGER_SYSVIEW_SendSysDesc(SEGGER_SYSVIEW_SYSDESC0);
#endif
#ifdef SEGGER_SYSVIEW_SYSDESC1
SEGGER_SYSVIEW_SendSysDesc(SEGGER_SYSVIEW_SYSDESC1);
#endif
#ifdef SEGGER_SYSVIEW_SYSDESC2
SEGGER_SYSVIEW_SendSysDesc(SEGGER_SYSVIEW_SYSDESC2);
#endif
}
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* SEGGER_SYSVIEW_Conf()
*
* Function description
* Configure and initialize SystemView and register it with embOS.
*
* Additional information
* If enabled, SEGGER_SYSVIEW_Conf() will also immediately start
* recording events with SystemView.
*/
void SEGGER_SYSVIEW_Conf(void) {
SEGGER_SYSVIEW_Init(SEGGER_SYSVIEW_TIMESTAMP_FREQ, SEGGER_SYSVIEW_CPU_FREQ,
&SYSVIEW_X_OS_TraceAPI, _cbSendSystemDesc);
OS_SetTraceAPI(&embOS_TraceAPI_SYSVIEW); // Configure embOS to use SYSVIEW.
#if SEGGER_SYSVIEW_START_ON_INIT
SEGGER_SYSVIEW_Start();
// Start recording to catch system initialization.
#endif
}
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetTimestamp()
*
* Function description
* Returns the current timestamp in cycles using the system tick
* count and the SysTick counter.
* All parameters of the SysTick have to be known and are set via
* configuration defines on top of the file.
*
* Return value
* The current timestamp.
*
* Additional information
* SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are
* disabled. Therefore locking here is not required.
*/
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
U32 TickCount;
U32 Cycles;
U32 CyclesPerTick;
//
// Get the cycles of the current system tick.
// SysTick is down-counting, subtract the current value from the number of cycles per tick.
//
CyclesPerTick = SYST_RVR + 1;
Cycles = (CyclesPerTick - SYST_CVR);
//
// Get the system tick count.
//
TickCount = SEGGER_SYSVIEW_TickCnt;
//
// If a SysTick interrupt is pending, re-read timer and adjust result
//
if ((SCB_ICSR & SCB_ICSR_PENDSTSET_MASK) != 0) {
Cycles = (CyclesPerTick - SYST_CVR);
TickCount++;
}
Cycles += TickCount * CyclesPerTick;
return Cycles;
}
Continuous recording is only supported on Cortex-A / Cortex-R devices, which support RTT
via background memory access via the AHB-AP. For more information please refer to the
J-Link User Manual and website.
Dummy configuration:
//
// SEGGER_SYSVIEW_TickCnt has to be defined in the module which
// handles interrupts and must be incremented in the interrupt
// handler as soon as the timer interrupt is acknowledged and
// before any SYSVIEW event is generated.
//
// Example:
//
// unsigned int SEGGER_SYSVIEW_TickCnt; // <<-- Define SEGGER_SYSVIEW_TickCnt.
// void OS_irq_handler(void) {
// U32 InterruptId;
// InterruptId = INTC_ICCIAR & 0x3FF; // read and extract the interrupt ID
// if (InterruptId == TIMER_TICK_ID) {
// SEGGER_SYSVIEW_TickCnt++; // <<-- Increment SEGGER_SYSVIEW_TickCnt asap.
// }
// SEGGER_SYSVIEW_InterruptId
= InterruptId; // Save active interrupt for SystemView event
// SEGGER_SYSVIEW_RecordEnterISR();
// //
// // Handle interrupt, call ISR
// //
// SEGGER_SYSVIEW_RecordExitISR();
// }
//
extern unsigned int SEGGER_SYSVIEW_TickCnt;
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
//
// Define the required timer registers here.
//
#define TIMER_RELOAD_VALUE /* as value which is used to initialize and
reload the timer */
#define TIMER_COUNT /* as timer register which holds the current
counter value */
#define TIMER_INTERRUPT_PENDING() /* as check if a timer interrupt is pending */
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetTimestamp()
*
* Function description
* Returns the current timestamp in ticks using the system tick
* count and the SysTick counter.
* All parameters of the SysTick have to be known and are set via
* configuration defines on top of the file.
*
* Return value
* The current timestamp.
*
* Additional information
* SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are
* disabled. Therefore locking here is not required.
*/
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
U32 TickCount;
U32 Cycles;
U32 CyclesPerTick;
//
// Get the cycles of the current system tick.
// Sample timer is down-counting,
// subtract the current value from the number of cycles per tick.
//
CyclesPerTick = TIMER_RELOAD_VALUE + 1;
Cycles = (CyclesPerTick - TIMER_COUNT);
//
// Get the system tick count.
//
TickCount = SEGGER_SYSVIEW_TickCnt;
//
// Check if a timer interrupt is pending
//
if (TIMER_INTERRUPT_PENDING()) {
TickCount++;
Cycles = (CyclesPerTick - TIMER_COUNT);
}
Cycles += TickCount * CyclesPerTick;
return Cycles;
}
Dummy configuration:
//
// SEGGER_SYSVIEW_InterruptId has to be defined in the module which
// handles the interrupts and must be set to the acknowledged interrupt Id.
//
// Example:
//
// #define GIC_BASE_ADDR /* as base address of the GIC on the device */
// #define GICC_BASE_ADDR (GIC_BASE_ADDR + 0x2000u)
// #define GICC_IAR (*(volatile unsigned*)(GICC_BASE_ADDR + 0x000C))
//
// unsigned int SEGGER_SYSVIEW_InterruptId; //
<<-- Define SEGGER_SYSVIEW_InterruptId.
// void OS_irq_handler(void) {
//
// int_id = GICC_IAR & 0x03FF; // Read interrupt ID, acknowledge interrupt
// SEGGER_SYSVIEW_InterruptId = iar_val;
// OS_EnterInterrupt(); // Inform OS that interrupt handler is running
// pISR(); // Call interrupt service routine
// OS_LeaveInterrupt();
// Leave interrupt, perform task switch if required
// }
//
extern unsigned int SEGGER_SYSVIEW_InterruptId;
Configuration:
//
// RTT locking for GCC toolchains in SEGGER_RTT_Conf.h
// Set and restore IRQ and FIQ mask bits.
//
#define SEGGER_RTT_LOCK() { \
unsigned int LockState; \
__asm volatile ("mrs r1, CPSR \n\t" \
"mov %0, r1 \n\t" \
"orr r1, r1, #0xC0 \n\t" \
"msr CPSR_c, r1 \n\t" \
: "=r" (LockState) \
: \
: "r1" \
);
//
// Define SystemView locking in SEGGER_SYSVIEW_Conf.h
//
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
SEGGER_SYSVIEW_Conf.h
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Conf.h
Purpose : SEGGER SysView configuration for Renesas RZ/A1 Cortex-A9
with SEGGER embOS.
*/
#ifndef SEGGER_SYSVIEW_CONF_H
#define SEGGER_SYSVIEW_CONF_H
/*********************************************************************
*
* SysView buffer configuration
*/
// Number of bytes that SysView uses for the buffer.
// Should be large enough for single-shot recording.
#define SEGGER_SYSVIEW_RTT_BUFFER_SIZE 1024 * 1024
// The RTT channel that SysView will use.
#define SEGGER_SYSVIEW_RTT_CHANNEL 1
/*********************************************************************
*
* SysView timestamp configuration
*/
// Retrieve a system timestamp via OS-specific function
#define SEGGER_SYSVIEW_GET_TIMESTAMP() SEGGER_SYSVIEW_X_GetTimestamp()
// number of valid bits low-order delivered by SEGGER_SYSVIEW_X_GetTimestamp()
#define SEGGER_SYSVIEW_TIMESTAMP_BITS 32
/*********************************************************************
*
* SysView interrupt configuration
*/
//
// SEGGER_SYSVIEW_InterruptId has to be defined in the module which
// handles the interrupts and must be set to the acknowledged interrupt Id.
//
// Example:
//
// #define GIC_BASE_ADDR /* as base address of the GIC on the device */
// #define GICC_BASE_ADDR (GIC_BASE_ADDR + 0x2000u)
// #define GICC_IAR (*(volatile unsigned*)(GICC_BASE_ADDR + 0x000C))
//
// unsigned int SEGGER_SYSVIEW_InterruptId; //
<<-- Define SEGGER_SYSVIEW_InterruptId.
// void OS_irq_handler(void) {
//
// int_id = GICC_IAR & 0x03FF; // Read interrupt ID, acknowledge interrupt
// SEGGER_SYSVIEW_InterruptId = iar_val;
// OS_EnterInterrupt(); // Inform OS that interrupt handler is running
// pISR(); // Call interrupt service routine
// OS_LeaveInterrupt();
// Leave interrupt, perform task switch if required
// }
//
extern unsigned int SEGGER_SYSVIEW_InterruptId;
/*********************************************************************
*
* SysView locking
*/
// Lock SysView (nestable)
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
// Unlock SysView (nestable)
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_RTT_UNLOCK()
#endif
SEGGER_SYSVIEW_Config_embOS_RZA1.c
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Config_embOS_RZA1.c
Purpose : Sample setup configuration of SystemView with embOS
for Renesas RZ/A1 Cortex-A9.
*/
#include "RTOS.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_embOS.h"
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
// The application name to be displayed in SystemView
#define SYSVIEW_APP_NAME "embOS Demo Application"
/*********************************************************************
*
* _cbSendSystemDesc()
*
* Function description
* Sends SystemView description strings.
*/
static void _cbSendSystemDesc(void) {
SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",D="SYSVIEW_DEVICE_NAME);
}
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
void SEGGER_SYSVIEW_Conf(void) {
SEGGER_SYSVIEW_Init(SYSVIEW_TIMESTAMP_FREQ, SYSVIEW_CPU_FREQ,
&SYSVIEW_X_OS_TraceAPI, _cbSendSystemDesc);
SEGGER_SYSVIEW_SetRAMBase(SYSVIEW_RAM_BASE);
OS_SetTraceAPI(&embOS_TraceAPI_SYSVIEW); // Configure embOS to use SYSVIEW.
}
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetTimestamp()
*
* Function description
* Returns the current timestamp in ticks using the system tick
* count and the SysTick counter.
* All parameters of the SysTick have to be known and are set via
* configuration defines on top of the file.
*
* Return value
* The current timestamp.
*
* Additional information
* SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are
* disabled. Therefore locking here is not required.
*/
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
U32 TickCount;
U32 Cycles;
U32 CyclesPerTick;
//
// Get the cycles of the current system tick.
// Sample timer is down-counting,
// subtract the current value from the number of cycles per tick.
//
CyclesPerTick = 33249 + 1;
Cycles = (CyclesPerTick - OSTM_CNT);
//
// Get the system tick count.
//
TickCount = SEGGER_SYSVIEW_TickCnt;
//
// Check if a timer interrupt is pending
//
if (TIMER_INTERRUPT_PENDING()) {
TickCount++;
Cycles = (CyclesPerTick - OSTM_CNT);
}
Cycles += TickCount * CyclesPerTick;
return Cycles;
}
SEGGER_SYSVIEW_Conf.h
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Conf.h
Purpose : Generic SEGGER SysView configuration for non-Cortex-M
devices.
*/
#ifndef SEGGER_SYSVIEW_CONF_H
#define SEGGER_SYSVIEW_CONF_H
/*********************************************************************
*
* SysView timestamp configuration
*/
// Retrieve a system timestamp via user-defined function
#define SEGGER_SYSVIEW_GET_TIMESTAMP() SEGGER_SYSVIEW_X_GetTimestamp()
// number of valid bits low-order delivered by SEGGER_SYSVIEW_X_GetTimestamp()
#define SEGGER_SYSVIEW_TIMESTAMP_BITS 32
/*********************************************************************
*
* SysView Id configuration
*/
// Default value for the lowest Id reported by the application.
// Can be overridden by the application via SEGGER_SYSVIEW_SetRAMBase().
#define SEGGER_SYSVIEW_ID_BASE 0
// Number of bits to shift the Id to save bandwidth.
// (for example 2 when all reported Ids (pointers) are 4 byte aligned)
#define SEGGER_SYSVIEW_ID_SHIFT 0
/*********************************************************************
*
* SysView interrupt configuration
*/
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId()
/*********************************************************************
*
* SysView locking
*/
// Lock SysView (nestable)
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
// Unlock SysView (nestable)
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_RTT_UNLOCK()
#endif
SEGGER_SYSVIEW_Config_embOS_AM3358.c
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Config_embOS_RZA1.c
Purpose : Sample setup configuration of SystemView with embOS
for TI AM3358 Cortex-A8.
*/
#include "RTOS.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_embOS.h"
//
// SystemcoreClock can be used in most CMSIS compatible projects.
// In non-CMSIS projects define SYSVIEW_CPU_FREQ directly.
//
extern unsigned int SystemCoreClock;
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
// The application name to be displayed in SystemView
#ifndef SYSVIEW_APP_NAME
#define SYSVIEW_APP_NAME "embOS start project"
#endif
#ifndef SYSVIEW_SYSDESC0
#define SYSVIEW_SYSDESC0 "I#67=SysTick,I#18=USB,I#17=USBSS,I#36=LCDC"
#endif
/*********************************************************************
*
* Local functions
*
**********************************************************************
*/
/*********************************************************************
*
* _cbSendSystemDesc()
*
* Function description
* Sends SystemView description strings.
*/
static void _cbSendSystemDesc(void) {
SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",O=embOS,D="SYSVIEW_DEVICE_NAME);
#ifdef SYSVIEW_SYSDESC0
SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC0);
#endif
#ifdef SYSVIEW_SYSDESC1
SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC1);
#endif
#ifdef SYSVIEW_SYSDESC2
SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC2);
#endif
}
/*********************************************************************
*
* _InitPerformanceCounter
*
* Function description
* Initialize the internal Cortex-A Performance counter.
* The function will work for Cortex-A8, Cortex-A9.
* Please check whether this also suites for your core.
*/
static void _InitPerformanceCounter(U32 PerformReset, I32 UseDivider) {
//
// in general enable all counters (including cycle counter)
//
I32 Value = 1;
//
// Peform reset:
//
if (PerformReset) {
Value |= 2; // reset all counters to zero.
Value |= 4; // reset cycle counter to zero.
}
if (UseDivider) {
Value |= 8; // enable "by 64" divider for CCNT.
}
Value |= 16;
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
/*********************************************************************
*
* SEGGER_SYSVIEW_Conf
*
* Function description
* Configures SYSVIEW.
*
* Please check whether this also suites for your core.
*/
void SEGGER_SYSVIEW_Conf(void) {
//
// Write USEREN Register
//
__asm volatile ("MCR p15, 0, %0, C9, C14, 0\n\t"
: // Output result
: "r"(1) // Input
: // Clobbered list
);
//
// Disable counter overflow interrupts
//
__asm volatile ("MCR p15, 0, %0, C9, C14, 2\n\t"
: // Output result
: "r"(0x8000000f) // Input
: // Clobbered list
);
_InitPerformanceCounter(1, 0);
SEGGER_SYSVIEW_Init(SYSVIEW_TIMESTAMP_FREQ, SYSVIEW_CPU_FREQ,
&SYSVIEW_X_OS_TraceAPI, _cbSendSystemDesc);
SEGGER_SYSVIEW_SetRAMBase(SYSVIEW_RAM_BASE);
OS_SetTraceAPI(&embOS_TraceAPI_SYSVIEW); // Configure embOS to use SYSVIEW.
}
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetTimestamp()
*
* Function description
* Returns the current timestamp in ticks using the performance counter.
*
* Return value
* The current timestamp.
*
* Additional information
* SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are
* disabled. Therefore locking here is not required.
*/
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
register U32 r = 0;
//
// Read CCNT Register
//
__asm volatile ("MRC p15, 0, %0, c9, c13, 0"
: "+r"(r) // Output result
: // Inputs
: ); // Clobbered list
return r;
}
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetInterruptId()
*
* Function description
4.6.5 Renesas RX
Recording mode Supported?
Continuous recording Yes
Single-shot recording Yes
Post-mortem analysis Yes
Configuration:
//
// SEGGER_SYSVIEW_TickCnt has to be defined in the module which
// handles the system tick timer and must be incremented in the timer interrupt
// handler before any SYSVIEW event is generated.
//
// Example in embOS RTOSInit.c:
//
// unsigned int SEGGER_SYSVIEW_TickCnt; // <<-- Define SEGGER_SYSVIEW_TickCnt.
// void SysTick_Handler(void) {
// #if OS_PROFILE
// SEGGER_SYSVIEW_TickCnt++; // <<-- Increment SEGGER_SYSVIEW_TickCnt asap.
// #endif
// OS_EnterNestableInterrupt();
// OS_TICK_Handle();
// OS_LeaveNestableInterrupt();
// }
//
extern unsigned int SEGGER_SYSVIEW_TickCnt;
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
// System Timer configuration
#define IRR_BASE_ADDR (0x00087000u)
#define CMT0_VECT 28u
#define OS_TIMER_VECT CMT0_VECT
#define TIMER_PRESCALE (8u)
#define CMT0_BASE_ADDR (0x00088000u)
#define CMT0_CMCNT (*(volatile U16*) (CMT0_BASE_ADDR + 0x04u))
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetTimestamp()
*
* Function description
* Returns the current timestamp in ticks using the system tick
* count and the system timer counter.
* All parameters of the system timer have to be known and are set via
* configuration defines on top of the file.
*
* Return value
* The current timestamp.
*
* Additional information
* SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are
* disabled. Therefore locking here is not required.
*/
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
U32 Time;
U32 Cnt;
Time = SEGGER_SYSVIEW_TickCnt;
Cnt = CMT0_CMCNT;
//
// Check if timer interrupt pending ...
//
if ((*(volatile U8*)(IRR_BASE_ADDR + OS_TIMER_VECT) & (1u << 0u)) != 0u) {
Cnt = CMT0_CMCNT; // Interrupt pending, re-read timer and adjust result
Time++;
}
return ((SYSVIEW_TIMESTAMP_FREQ/1000) * Time) + Cnt;
}
Configuration:
//
// Get the interrupt Id via user-provided function
//
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId()
Configuration:
//
// RTT locking for IAR toolchains in SEGGER_RTT_Conf.h
//
#define SEGGER_RTT_LOCK() { \
unsigned long LockState; \
LockState = __get_interrupt_state(); \
__disable_interrupt();
//
// Define SystemView locking in SEGGER_SYSVIEW_Conf.h
//
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_RTT_UNLOCK()
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : SEGGER_SYSVIEW_Conf.h
Purpose : SEGGER SysView configuration for Renesas RX
*/
#ifndef SEGGER_SYSVIEW_CONF_H
#define SEGGER_SYSVIEW_CONF_H
/*********************************************************************
*
* SysView timestamp configuration
*/
// Retrieve a system timestamp via user-defined function
#define SEGGER_SYSVIEW_GET_TIMESTAMP() SEGGER_SYSVIEW_X_GetTimestamp()
// number of valid bits low-order delivered by SEGGER_SYSVIEW_X_GetTimestamp()
#define SEGGER_SYSVIEW_TIMESTAMP_BITS 32
/*********************************************************************
*
* SysView Id configuration
*/
// Default value for the lowest Id reported by the application.
// Can be overridden by the application via SEGGER_SYSVIEW_SetRAMBase().
#define SEGGER_SYSVIEW_ID_BASE 0
// Number of bits to shift the Id to save bandwidth.
// (for example 2 when all reported Ids (pointers) are 4 byte aligned)
#define SEGGER_SYSVIEW_ID_SHIFT 0
/*********************************************************************
*
* SysView interrupt configuration
*/
// Get the currently active interrupt Id. (read Cortex-M ICSR[8:0]
= active vector)
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId()
/*********************************************************************
*
* SysView locking
*/
// Lock SysView (nestable)
#define SEGGER_SYSVIEW_LOCK() SEGGER_RTT_LOCK()
// Unlock SysView (nestable)
#define SEGGER_SYSVIEW_UNLOCK() SEGGER_RTT_UNLOCK()
#endif
SEGGER_SYSVIEW_Config_embOS_CM0.c
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
File : SEGGER_SYSVIEW_Config_NoOS_RX.c
Purpose : Sample setup configuration of SystemView on Renesas RX
systems without an operating system.
Revision: $Rev: 18540 $
*/
#include "RTOS.h"
#include "SEGGER_SYSVIEW.h"
#include "SEGGER_SYSVIEW_embOS.h"
//
// SystemcoreClock can be used in most CMSIS compatible projects.
// In non-CMSIS projects define SYSVIEW_CPU_FREQ directly.
//
extern unsigned int SystemCoreClock;
/*********************************************************************
*
* Defines, fixed
*
**********************************************************************
*/
/*********************************************************************
*
* Defines, configurable
*
**********************************************************************
*/
// The application name to be displayed in SystemViewer
#ifndef SYSVIEW_APP_NAME
#define SYSVIEW_APP_NAME "Demo Application"
#endif
#ifndef SYSVIEW_SYSDESC0
#define SYSVIEW_SYSDESC0
"I#0=IntPrio0,I#1=IntPrio1,I#2=IntPrio2,I#3=IntPrio3,I#4=IntPrio4"
#endif
//#ifndef SYSVIEW_SYSDESC1
// #define SYSVIEW_SYSDESC1
"I#5=IntPrio5,I#6=IntPrio6,I#7=IntPrio7,I#8=IntPrio8,I#9=IntPrio9,I#10=IntPrio10"
//#endif
//#ifndef SYSVIEW_SYSDESC2
// #define SYSVIEW_SYSDESC2
"I#11=IntPrio11,I#12=IntPrio12,I#13=IntPrio13,I#14=IntPrio14,I#15=IntPrio15"
//#endif
/*********************************************************************
*
* _cbSendSystemDesc()
*
* Function description
* Sends SystemView description strings.
*/
static void _cbSendSystemDesc(void) {
SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",D="SYSVIEW_DEVICE_NAME);
#ifdef SYSVIEW_SYSDESC0
SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC0);
#endif
#ifdef SYSVIEW_SYSDESC1
SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC1);
#endif
#ifdef SYSVIEW_SYSDESC2
SEGGER_SYSVIEW_SendSysDesc(SYSVIEW_SYSDESC2);
#endif
}
/*********************************************************************
*
* Global functions
*
**********************************************************************
*/
void SEGGER_SYSVIEW_Conf(void) {
SEGGER_SYSVIEW_Init(SYSVIEW_TIMESTAMP_FREQ, SYSVIEW_CPU_FREQ,
0, _cbSendSystemDesc);
SEGGER_SYSVIEW_SetRAMBase(SYSVIEW_RAM_BASE);
}
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetTimestamp()
*
* Function description
* Returns the current timestamp in ticks using the system tick
* count and the SysTick counter.
* All parameters of the SysTick have to be known and are set via
* configuration defines on top of the file.
*
* Return value
* The current timestamp.
*
* Additional information
* SEGGER_SYSVIEW_X_GetTimestamp is always called when interrupts are
* disabled.
* Therefore locking here is not required and OS_GetTime_Cycles() may
* be called.
*/
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
U32 Time;
U32 Cnt;
Time = SEGGER_SYSVIEW_TickCnt;
Cnt = CMT0_CMCNT;
//
// Check if timer interrupt pending ...
//
if ((*(volatile U8*)(IRR_BASE_ADDR + OS_TIMER_VECT) & (1u << 0u)) != 0u) {
Cnt = CMT0_CMCNT; // Interrupt pending, re-read timer and adjust result
Time++;
}
return ((SYSVIEW_TIMESTAMP_FREQ/1000) * Time) + Cnt;
}
/*********************************************************************
*
* SEGGER_SYSVIEW_X_GetInterruptId()
*
* Function description
* Return the priority of the currently active interrupt.
*/
U32 SEGGER_SYSVIEW_X_GetInterruptId(void) {
U32 IntId;
__asm volatile ("mvfc PSW, %0 \t\n" // Load current PSW
"and #0x0F000000, %0 \t\n" // Clear all except IPL
([27:24])
"shlr #24, %0 \t\n" // Shift IPL to [3:0]
: "=r" (IntId) // Output result
: // Input
: // Clobbered list
);
return IntId;
}
On CPUs, which are not covered by the sections above SystemView can be used in sin-
gle-shot mode, too.
To properly run SystemView the same items have to be configured:
• Get an event timestamp.
• Get an interrupt Id of the active interrupt.
• Lock and unlock SystemView to prevent recording being interrupted.
4.7.1 embOS
SEGGER embOS (V4.12a and later) can generate trace events for SystemView and other
recording implementations when profiling is enabled.
4.7.2 uC/OS-III
SystemView can be used with Micrium’s uC/OS-III to record task, interrupt, and scheduler
activity.
Enable recording
Recording of uC/OS-III events can be configured in os_cfg.h.
[...]
BSP_Init(); /* Initialize BSP functions */
CPU_Init(); /* Initialize the uC/CPU services */
4.7.3 uC/OS-II
SystemView can be used with Micrium’s uC/OS-II to record task, interrupt, and scheduler
activity. SystemView support has been added with v2.92.13
For information on how to configure uC/OS-II for SystemView, follow the guide at https://
doc.micrium.com/display/osiidoc/SEGGER+SystemView
Enable recording
Recording of uC/OS-II events can be configured in os_cfg.h.
Define OS_CFG_TRACE_EN as 1u to enable basic recording.
When OS_CFG_TRACE_API_ENTER_EN is defined as 1u, API function calls will be recorded,
too.
To also record when an API function exits, define OS_CFG_TRACE_API_EXIT_EN as 1u as well.
Call TRACE_INIT() at the beginning of the application, after the system has been initialized:
[...]
BSP_Init(); /* Initialize BSP functions */
CPU_Init(); /* Initialize the uC/CPU services */
Enable recording
Recording of Micrium OS Kernel events can be configured in os_cfg.h.
Define OS_CFG_TRACE_EN as 1u to enable basic recording.
When OS_CFG_TRACE_API_ENTER_EN is defined as 1u, API function calls will be recorded,
too.
To also record when an API function exits, define OS_CFG_TRACE_API_EXIT_EN as 1u as well.
Call TRACE_INIT() at the beginning of the application, after the system has been initialized:
[...]
BSP_Init(); /* Initialize BSP functions */
CPU_Init(); /* Initialize the uC/CPU services */
4.7.5 FreeRTOS
FreeRTOS can also generate trace events for SystemView and allows basic but useful analy-
sis without modification.
For more detailed analysis, like Scheduler activity and interrupts, the FreeRTOS source and
the used port have to be slightly modified.
4.7.6 NuttX
SystemView can be used with NuttX RTOS to record system activity.
SystemView has been added to the NuttX mainline and can be enabled and configured in
its setup tools.
More information is available in the NuttX project documentation.
4.7.7 Zephyr
SystemView can be used as a recorder in Zephyr to record events.
More information is available in the Zephyr project documentation.
4.7.8.1 No OS
SystemView can be used without any instrumented OS at all, to record interrupt activity
and user events.
functions for SystemView and can be modified to fit the system. For an example configu-
ration, refer to Supported CPUs on page 82. An additional SEGGER_SYSVIEW_OS_API pointer
can be passed in SEGGER_SYSVIEW_Init to provide information about the system time or
“tasks” of the system.
For a description on how to record interrupts in the system, refer to Recording interrupts
on page 121.
A generic guide on how to implement SystemView on a NoOS system can be found on our
Wiki: https://wiki.segger.com/Use_SystemView_without_RTOS.
This section describes how SystemView can be used in user application code to extend the
analysis information generated by the instrumented OS.
On Task Create events call SEGGER_SYSVIEW_OnTaskCreate() with the Id of the new task.
Additionally it is recommended to record the task information of the new task with SEG-
GER_SYSVIEW_SendTaskInfo().
Example
void OS_CreateTask(TaskFunc* pF, unsigned Prio, const char* sName, void* pStack) {
SEGGER_SYSVIEW_TASKINFO Info;
OS_TASK* pTask; // Pseudo struct to be replaced
SEGGER_SYSVIEW_OnTaskCreate((unsigned)pTask);
memset(&Info, 0, sizeof(Info));
//
// Fill elements with current task information
//
Info.TaskID = (U32)pTask;
Info.sName = pTask->Name;
Info.Prio = pTask->Priority;
Info.StackBase = (U32)pTask->pStack;
Info.StackSize = pTask->StackSize;
SEGGER_SYSVIEW_SendTaskInfo(&Info);
}
Example
int OS_HandleTick(void) {
int TaskReady = 0; // Pseudo variable indicating a task is ready
if (TaskReady) {
SEGGER_SYSVIEW_OnTaskStartReady((unsigned)pTask);
}
}
Example
void OS_Switch(void) {
//
// If a task is activated
//
SEGGER_SYSVIEW_OnTaskStartExec((unsigned)pTask);
//
// Else no task activated, go into idle state
//
SEGGER_SYSVIEW_OnIdle()
}
Example
SEGGER_SYSVIEW_OnTaskStopReady(OS_Global.pCurrentTask, OS_CAUSE_WAITING);
}
Example
void OS_TerminateTask(void) {
SEGGER_SYSVIEW_OnTaskStopExec();
}
Example
void OS_Switch(void) {
//
// If a task is activated
//
SEGGER_SYSVIEW_OnTaskStartExec((unsigned)pTask);
//
// Else no task activated, go into idle state
//
SEGGER_SYSVIEW_OnIdle()
}
Example
void OS_EnterInterrupt(void) {
SEGGER_SYSVIEW_RecordEnterISR();
}
Example
void OS_ExitInterrupt(void) {
//
SEGGER_SYSVIEW_RecordExitISRToScheduler();
//
// Otherwise
//
SEGGER_SYSVIEW_RecordExitISR();
}
void Timer_Handler(void) {
//
// Inform OS about start of interrupt execution
// (records SystemView Enter Interrupt event).
//
OS_EnterInterrupt();
//
// Interrupt functionality could be here
//
APP_TimerCnt++;
//
// Inform OS about end of interrupt execution
// (records SystemView Exit Interrupt event).
//
OS_ExitInterrupt();
}
void ADC_Handler(void) {
//
// Explicitly record SystemView Enter Interrupt event.
// Should not be called in high-frequency interrupts.
//
SEGGER_SYSVIEW_RecordEnterISR();
//
// Interrupt functionality could be here
//
APP_ADCValue = ADC.Value;
//
// Explicitly record SystemView Exit Interrupt event.
// Should not be called in high-frequency interrupts.
//
SEGGER_SYSVIEW_RecordExitISR();
}
SEGGER_SYSVIEW_OS_API
typedef struct {
U64 (*pfGetTime) (void);
void (*pfSendTaskList) (void);
} SEGGER_SYSVIEW_OS_API;
Parameters
Parameter Description
pfGetTime Pointer to a function returning the system time.
pfSendTaskList Pointer to a function recording the entire task list.
6.1.3.1 pfGetTime
Description
Get the system time, i.e. the time since starting the system, in microseconds.
If pfGetTime is NULL SystemView can show timestamps relative to the start of recording
only.
Prototype
6.1.3.2 pfSendTaskList
Description
Record the entire task list via SEGGER_SYSVIEW_SendTaskInfo().
If pfSendTaskList is NULL SystemView might only get task information of tasks which are
newly created while recording. pfSendTaskList is called on start of a recording when the
SystemView Application connects to get all information on the current task list.
Prototype
Example
void cbSendTaskList(void) {
SEGGER_SYSVIEW_TASKINFO Info;
OS_TASK* pTask;
OS_EnterRegion(); // Disable scheduling to make sure the task list does not change.
for (pTask = OS_Global.pTask; pTask; pTask = pTask->pNext) {
//
// Fill all elements with 0 to allow extending the structure
// in future version without breaking the code.
//
memset(&Info, 0, sizeof(Info));
//
// Fill elements with current task information
//
Info.TaskID = (U32)pTask;
Info.sName = pTask->Name;
Info.Prio = pTask->Priority;
Info.StackBase = (U32)pTask->pStackBot;
Info.StackSize = pTask->StackSize;
//
Example
/*********************************************************************
*
* OS_malloc()
*
* Function description
* API function to allocate memory on the heap.
*/
void OS_malloc(unsigned Size) {
SEGGER_SYSVIEW_RecordU32(ID_OS_MALLOC, // Id of OS_malloc (>= 32)
Size // First parameter
);
To record how long the execution of an API function takes and to record its return value, the
return of an API function can be instrumented, too by calling SEGGER_SYSVIEW_RecordEnd-
Call to only record the return or SEGGER_SYSVIEW_RecordEndCallReturnValue to record
the return and its return value.
<EventId> is the Id which is recorded for the API function. It can be in the range of 32
to 511.
<FunctionName> is the name of the API function, displayed in the Event column of Sys-
temView. It may not contain spaces.
<ParameterDescription> is the description string of the parameters which are recorded
with the API function.
<ReturnValueDescription> is the description string of the return value which can be
recorded with SystemView. The ReturnValueDescription is optional.
Example
The following example shows a part of SYSVIEW_embOS.txt
35 OS_CheckTimer pGlobal=%p
42 OS_Delay Delay=%u
43 OS_DelayUntil Time=%u
44 OS_setPriority Task=%t Pri=%u
45 OS_WakeTask Task=%t
46 OS_CreateTask Task=%t Pri=%u Stack=%p Size=%u
In addition to the default modifiers the description file can define NamedTypes to map nu-
merical values to strings, which can for example be useful to display the textual value of
enums or error codes.
NamedTypes have following format:
Example
#
# Types for parameter formatters
#
NamedType OSErr 0=OS_ERR_NONE
NamedType OSErr 10000=OS_ERR_A 10001=OS_ERR_ACCEPT_ISR
NamedType OSErr 12000=OS_ERR_C 12001=OS_ERR_CREATE_ISR
NamedType OSErr 13000=OS_ERR_D 13001=OS_ERR_DEL_ISR
Example
# Task States
#
TaskState 0xFF 0=Ready, 1=Delayed or Timeout, 2=Pending, 3=Pending with Timeout,
4=Suspended, 5=Suspended with Timeout, 6=Suspended and Pending, 7=Suspended and
Pending with Timeout, 255=Deleted
/*********************************************************************
* (c) 1995 - 2018 SEGGER Microcontroller GmbH *
* The Embedded Experts *
* www.segger.com *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
/*********************************************************************
*
* OS_CreateTask()
*
* Function description
* Create a new task and add it to the system.
*/
void OS_CreateTask(TaskFunc* pF, unsigned Prio, const char* sName, void* pStack) {
SEGGER_SYSVIEW_TASKINFO Info;
OS_TASK* pTask; // Pseudo struct to be replaced
SEGGER_SYSVIEW_OnTaskCreate((unsigned)pTask);
memset(&Info, 0, sizeof(Info));
//
// Fill elements with current task information
//
Info.TaskID = (U32)pTask;
Info.sName = pTask->Name;
Info.Prio = pTask->Priority;
Info.StackBase = (U32)pTask->pStack;
Info.StackSize = pTask->StackSize;
SEGGER_SYSVIEW_SendTaskInfo(&Info);
}
/*********************************************************************
*
* OS_TerminateTask()
*
* Function description
* Terminate a task and remove it from the system.
*/
void OS_TerminateTask(void) {
SEGGER_SYSVIEW_OnTaskStopExec();
/*********************************************************************
*
* OS_Delay()
*
* Function description
* Delay and suspend a task for the given time.
*/
void OS_Delay(unsigned NumTicks) {
SEGGER_SYSVIEW_OnTaskStopReady(OS_Global.pCurrentTask, OS_CAUSE_WAITING);
}
/*********************************************************************
*
* OS_HandleTick()
*
* Function description
* OS System Tick handler.
*/
int OS_HandleTick(void) {
int TaskReady = 0; // Pseudo variable indicating a task is ready
if (TaskReady) {
SEGGER_SYSVIEW_OnTaskStartReady((unsigned)pTask);
}
}
/*********************************************************************
*
* OS_Switch()
*
* Function description
* Switch to the next ready task or go to idle.
*/
void OS_Switch(void) {
//
// If a task is activated
//
SEGGER_SYSVIEW_OnTaskStartExec((unsigned)pTask);
//
// Else no task activated, go into idle state
//
SEGGER_SYSVIEW_OnIdle()
}
/*********************************************************************
*
* OS_EnterInterrupt()
*
* Function description
* Inform the OS about start of interrupt execution.
*/
void OS_EnterInterrupt(void) {
SEGGER_SYSVIEW_RecordEnterISR();
}
/*********************************************************************
*
* OS_ExitInterrupt()
*
* Function description
* Inform the OS about end of interrupt execution and switch to
* Scheduler if necessary.
*/
void OS_ExitInterrupt(void) {
SEGGER_SYSVIEW_MODULE
struct SEGGER_SYSVIEW_MODULE {
const char* sModule;
U32 NumEvents;
U32 EventOffset;
void (*pfSendModuleDesc)(void);
SEGGER_SYSVIEW_MODULE* pNext;
};
Parameters
Parameter Description
Pointer to a string containing the module name and optional-
sModule
ly the module event description.
NumEvents Number of events the module wants to register.
Offset to be added to the event Ids. Out parameter, set by
EventOffset
this function. Do not modify after calling this function.
Callback function pointer to send more detailed module de-
pfSendModuleDesc
scription to SystemView.
Pointer to next registered module. Out parameter, set by
pNext
this function. Do not modify after calling this function.
Example
SEGGER_SYSVIEW_MODULE IPModule = {
"M=embOSIP, " \
"0 SendPacket IFace=%u NumBytes=%u, " \
"1 ReceivePacket Iface=%d NumBytes=%u", // sModule
2, // NumEvents
0,
// EventOffset, Set by SEGGER_SYSVIEW_RegisterModule()
NULL,
// pfSendModuleDesc, NULL: No additional module description
Example
For more information refer to Recording OS API calls on page 124 and the API reference
on page 132.
As with OSes, the middleware module description can be made available in a description
file with the name of the module (Value of M=). Refer to OS description file on page 124.
The string length may not exceed SEGGER_SYSVIEW_MAX_STRING_LEN which is 128 by de-
fault.
To send additional description strings and to send the name of resources which are used
and recorded by the module, SEGGER_SYSVIEW_MODULE.pfSendModuleDesc can be set when
registering the module.
SEGGER_SYSVIEW_MODULE.pfSendModuleDesc is called periodically when SystemView
is connected. It can call SEGGER_SYSVIEW_RecordModuleDescription() and SEG-
GER_SYSVIEW_NameResource().
Example
SEGGER_SYSVIEW_MODULE IPModule = {
"M=embOSIP, " \
"0 SendPacket IFace=%u NumBytes=%u, " \
"1 ReceivePacket Iface=%d NumBytes=%u", // sModule
2, // NumEvents
0, // EventOffset, Set by RegisterModule()
_cbSendIPModuleDesc, // pfSendModuleDesc
NULL, // pNext, Set by RegisterModule()
};
API reference
7.1.1 Composition
The format is composed of zero or more directives: ordinary characters (not %, which are
copied unchanged to the output stream; and conversion specifications, each of which results
in fetching zero or more subsequent arguments, converting them, if applicable, according
to the corresponding conversion specifier, and then writing the result to the output stream.
Each conversion specification is introduced by the character %. After the % the following
appear in sequence:
• Zero or more flags (in any order) that modify the meaning of the conversion
specification.
• An optional minimum field width. If the converted value has fewer characters than
the field width, it is padded with spaces (by default) on the left (or right, if the left
adjustment flag has been given) to the field width. The field width takes the form of
an asterisk * or a decimal integer.
• An optional precision that gives the minimum number of digits to appear for the d, u,
x, and X conversions. The precision takes the form of a period . followed an optional
decimal integer; if only the period is specified, the precision is taken as zero. If a
precision appears with any other conversion specifier, the behavior is undefined.
• A conversion specifier character that specifies the type of conversion to be applied.
Flag Description
The result of the conversion is left-justified within the field. The de-
- fault, if this flag is not specified, is that the result of the conversion is
left-justified within the field.
The result of a signed conversion always begins with a plus or minus
+ sign. The default, if this flag is not specified, is that it begins with a
sign only when a negative value is converted.
For d, u, x, and X, leading zeros (following any indication of sign or
base) are used to pad to the field width rather than performing space
0 padding. If the 0 and - flags both appear, the 0 flag is ignored. For
d, u, x, and X conversions, if a precision is specified, the 0 flag is ig-
nored. For other conversions, the behavior is undefined.
Flag Description
The argument is converted to signed decimal in the style [-]dddd.
The precision specifies the minimum number of digits to appear; if
d the value being converted can be represented in fewer digits, it is ex-
panded with leading spaces. The default precision is one. The result
of converting a zero value with a precision of zero is no characters.
Flag Description
The unsigned argument is converted to unsigned octal for o, unsigned
decimal for u, or unsigned hexadecimal notation for x or X in the style
dddd the letters abcdef are used for x conversion and the letters
ABCDEF for X conversion. The precision specifies the minimum number
u, x, X
of digits to appear; if the value being converted can be represented in
fewer digits, it is expanded with leading spaces. The default precision
is one. The result of converting a zero value with a precision of zero is
no characters.
The argument is converted to an unsigned char, and the resulting
c
character is written.
s The s specifier is not supported.
The argument is a pointer to void. The value of the pointer is con-
p verted in the same format as the x conversion specifier with a fixed
precision of 2*sizeof(void *).
% A % character is written. No argument is converted.
Function Description
SEGGER_SYSVIEW_Init() Initializes the SYSVIEW module.
SEGGER_SYSVIEW_Start() Start recording SystemView events.
SEGGER_SYSVIEW_Stop() Stop recording SystemView events.
Handle incoming packets if any and check
SEGGER_SYSVIEW_IsStarted()
if recording is started.
Enable standard SystemView events to be
SEGGER_SYSVIEW_EnableEvents()
generated.
Disable standard SystemView events to
SEGGER_SYSVIEW_DisableEvents()
not be generated.
7.2.1 SEGGER_SYSVIEW_Init()
Description
Initializes the SYSVIEW module. Must be called before the SystemView Application connects
to the system.
Prototype
void SEGGER_SYSVIEW_Init( U32 SysFreq,
U32 CPUFreq,
const SEGGER_SYSVIEW_OS_API * pOSAPI,
SEGGER_SYSVIEW_SEND_SYS_DESC_FUNC pfSendSysDesc);
Parameters
Parameter Description
SysFreq Frequency of timestamp, usually CPU core clock frequency.
CPUFreq CPU core clock frequency.
pOSAPI Pointer to the API structure for OS-specific functions.
pfSendSysDesc Pointer to record system description callback function.
Additional information
This function initializes the RTT channel used to transport SEGGER SystemView packets.
The channel is assigned the label “SysView” for client software to identify the SystemView
channel.
The channel is configured with the macro SEGGER_SYSVIEW_RTT_CHANNEL.
7.2.2 SEGGER_SYSVIEW_Start()
Description
Start recording SystemView events.
This function is triggered by the SystemView Application on connect. For single-shot or
post-mortem mode recording, it needs to be called by the application.
Prototype
void SEGGER_SYSVIEW_Start(void);
Additional information
This function enables transmission of SystemView packets recorded by subsequent trace
calls and records a SystemView Start event.
As part of start, a SystemView Init packet is sent, containing the system frequency. The
list of current tasks, the current system time and the system description string is sent, too.
7.2.3 SEGGER_SYSVIEW_Stop()
Description
Stop recording SystemView events.
This function is triggered by the SystemView Application on disconnect. For single-shot or
postmortem mode recording, it can be called by the application.
Prototype
void SEGGER_SYSVIEW_Stop(void);
Additional information
This function disables transmission of SystemView packets recorded by subsequent trace
calls. If transmission is enabled when this function is called, a single SystemView Stop
event is recorded to the trace, send, and then trace transmission is halted.
7.2.4 SEGGER_SYSVIEW_IsStarted()
Description
Handle incoming packets if any and check if recording is started.
Prototype
int SEGGER_SYSVIEW_IsStarted(void);
Return value
0: Recording not started.
>0 Recording started.
7.2.5 SEGGER_SYSVIEW_EnableEvents()
Description
Enable standard SystemView events to be generated.
Prototype
void SEGGER_SYSVIEW_EnableEvents(U32 EnableMask);
Parameters
Parameter Description
EnableMask Events to be enabled.
7.2.6 SEGGER_SYSVIEW_DisableEvents()
Description
Disable standard SystemView events to not be generated.
Prototype
void SEGGER_SYSVIEW_DisableEvents(U32 DisableMask);
Parameters
Parameter Description
DisableMask Events to be disabled.
Function Description
Sets the RAM base address, which is sub-
SEGGER_SYSVIEW_SetRAMBase() tracted from IDs in order to save band-
width.
SEGGER_SYSVIEW_SendTaskList() Send all tasks descriptors to the host.
Send a Task Info Packet, containing TaskId
SEGGER_SYSVIEW_SendTaskInfo() for identification, task priority and task
name.
Send the system description string to the
SEGGER_SYSVIEW_SendSysDesc()
host.
SEGGER_SYSVIEW_SendPacket() Send an event packet.
7.3.1 SEGGER_SYSVIEW_SetRAMBase()
Description
Sets the RAM base address, which is subtracted from IDs in order to save bandwidth.
Prototype
void SEGGER_SYSVIEW_SetRAMBase(U32 RAMBaseAddress);
Parameters
Parameter Description
RAMBaseAddress Lowest RAM Address. (i.e. 0x20000000 on most Cortex-M)
7.3.2 SEGGER_SYSVIEW_SendTaskInfo()
Description
Send a Task Info Packet, containing TaskId for identification, task priority and task name.
Prototype
void SEGGER_SYSVIEW_SendTaskInfo(const SEGGER_SYSVIEW_TASKINFO * pInfo);
Parameters
Parameter Description
pInfo Pointer to task information to send.
7.3.3 SEGGER_SYSVIEW_SendTaskList()
Description
Send all tasks descriptors to the host.
Prototype
void SEGGER_SYSVIEW_SendTaskList(void);
7.3.4 SEGGER_SYSVIEW_SendSysDesc()
Description
Send the system description string to the host. The system description is used by the
SystemView Application to identify the current application and handle events accordingly.
The system description is usually called by the system description callback, to ensure it is
only sent when the SystemView Application is connected.
Prototype
void SEGGER_SYSVIEW_SendSysDesc(const char * sSysDesc);
Parameters
Parameter Description
sSysDesc Pointer to the 0-terminated system description string.
Additional information
One system description string may not exceed SEGGER_SYSVIEW_MAX_STRING_LEN charac-
ters. Multiple description strings can be recorded.
The Following items can be described in a system description string. Each item is identified
by its identifier, followed by ’=’ and the value. Items are separated by ’,’.
Example strings
• N=Test Application,O=embOS,D=MK66FN2M0xxx18
• I#15=SysTick,I#99=ETH_Tx,I#100=ETH_Rx
7.3.5 SEGGER_SYSVIEW_SendModule()
Description
Sends the information of a registered module to the host.
Prototype
void SEGGER_SYSVIEW_SendModule(U8 ModuleId);
Parameters
Parameter Description
ModuleId Id of the requested module.
7.3.6 SEGGER_SYSVIEW_SendModuleDescription()
Description
Triggers a send of the registered module descriptions.
Prototype
void SEGGER_SYSVIEW_SendModuleDescription(void);
7.3.7 SEGGER_SYSVIEW_SendNumModules()
Description
Send the number of registered modules to the host.
Prototype
void SEGGER_SYSVIEW_SendNumModules(void);
Function Description
Markers
Record a Performance Marker Start event
SEGGER_SYSVIEW_MarkStart()
to start measuring runtime.
Record a Performance Marker intermediate
SEGGER_SYSVIEW_Mark()
event.
Record a Performance Marker Stop event
SEGGER_SYSVIEW_MarkStop()
to stop measuring runtime.
Resources
Send the name of a resource to be dis-
SEGGER_SYSVIEW_NameResource()
played in SystemView.
Plain output functions
SEGGER_SYSVIEW_Print() Print a string to the host.
SEGGER_SYSVIEW_Warn() Print a warning string to the host.
SEGGER_SYSVIEW_Error() Print an error string to the host.
Host-based formatting
Print a string which is formatted on the
SEGGER_SYSVIEW_PrintfHost()
host by the SystemView Application.
Print a string which is formatted on the
SEGGER_SYSVIEW_PrintfHostEx() host by the SystemView Application with
Additional information.
Print a warning string which is formatted
SEGGER_SYSVIEW_WarnfHost() on the host by the SystemView Applica-
tion.
Print an error string which is formatted on
SEGGER_SYSVIEW_ErrorfHost()
the host by the SystemView Application.
Target-based formatting
Print a string which is formatted on the
SEGGER_SYSVIEW_PrintfTarget()
target before sent to the host.
Print a string which is formatted on the
SEGGER_SYSVIEW_PrintfTargetEx() target before sent to the host with Addi-
tional information.
Print a warning string which is formatted
SEGGER_SYSVIEW_WarnfTarget()
on the target before sent to the host.
Print an error string which is formatted on
SEGGER_SYSVIEW_ErrorfTarget()
the target before sent to the host.
7.4.1 SEGGER_SYSVIEW_MarkStart()
Description
Record a Performance Marker Start event to start measuring runtime.
Prototype
void SEGGER_SYSVIEW_MarkStart(unsigned MarkerId);
Parameters
Parameter Description
MarkerId User defined ID for the marker.
7.4.2 SEGGER_SYSVIEW_Mark()
Description
Record a Performance Marker intermediate event.
Prototype
void SEGGER_SYSVIEW_Mark(unsigned int MarkerId);
Parameters
Parameter Description
MarkerId User defined ID for the marker.
7.4.3 SEGGER_SYSVIEW_MarkStop()
Description
Record a Performance Marker Stop event to stop measuring runtime.
Prototype
void SEGGER_SYSVIEW_MarkStop(unsigned MarkerId);
Parameters
Parameter Description
MarkerId User defined ID for the marker.
7.4.4 SEGGER_SYSVIEW_NameMarker()
Description
Send the name of a Performance Marker to be displayed in SystemView.
Marker names are usually set in the system description callback, to ensure it is only sent
when the SystemView Application is connected.
Prototype
void SEGGER_SYSVIEW_NameMarker( unsigned int MarkerId,
const char * sName);
Parameters
Parameter Description
MarkerId User defined ID for the marker.
Pointer to the marker name. (Max. SEG-
sName
GER_SYSVIEW_MAX_STRING_LEN Bytes)
7.4.5 SEGGER_SYSVIEW_NameResource()
Description
Send the name of a resource to be displayed in SystemView.
Marker names are usually set in the system description callback, to ensure it is only sent
when the SystemView Application is connected.
Prototype
void SEGGER_SYSVIEW_NameResource( U32 ResourceId,
const char * sName);
Parameters
Parameter Description
ResourceId Id of the resource to be named. i.e. its address.
Pointer to the resource name. (Max. SEG-
sName
GER_SYSVIEW_MAX_STRING_LEN Bytes)
7.4.6 SEGGER_SYSVIEW_Print()
Description
Print a string to the host.
Prototype
void SEGGER_SYSVIEW_Print(const char * s);
Parameters
Parameter Description
s String to sent.
7.4.7 SEGGER_SYSVIEW_PrintfHost()
Description
Print a string which is formatted on the host by the SystemView Application.
Prototype
void SEGGER_SYSVIEW_PrintfHost(const char * s,
...);
Parameters
Parameter Description
s String to be formatted.
Additional information
All format arguments are treated as 32-bit scalar values.
7.4.8 SEGGER_SYSVIEW_PrintfHostEx()
Description
Print a string which is formatted on the host by the SystemView Application with Additional
information.
Prototype
void SEGGER_SYSVIEW_PrintfHostEx(const char * s,
U32 Options,
...);
Parameters
Parameter Description
s String to be formatted.
Options Options for the string. i.e. Log level.
Additional information
All format arguments are treated as 32-bit scalar values.
7.4.9 SEGGER_SYSVIEW_PrintfTarget()
Description
Print a string which is formatted on the target before sent to the host.
Prototype
void SEGGER_SYSVIEW_PrintfTarget(const char * s,
...);
Parameters
Parameter Description
s String to be formatted.
7.4.10 SEGGER_SYSVIEW_PrintfTargetEx()
Description
Print a string which is formatted on the target before sent to the host with Additional
information.
Prototype
void SEGGER_SYSVIEW_PrintfTargetEx(const char * s,
U32 Options,
...);
Parameters
Parameter Description
s String to be formatted.
Options Options for the string. i.e. Log level.
7.4.11 SEGGER_SYSVIEW_Warn()
Description
Print a warning string to the host.
Prototype
void SEGGER_SYSVIEW_Warn(const char * s);
Parameters
Parameter Description
s String to sent.
7.4.12 SEGGER_SYSVIEW_WarnfHost()
Description
Print a warning string which is formatted on the host by the SystemView Application.
Prototype
void SEGGER_SYSVIEW_WarnfHost(const char * s,
...);
Parameters
Parameter Description
s String to be formatted.
Additional information
All format arguments are treated as 32-bit scalar values.
7.4.13 SEGGER_SYSVIEW_WarnfTarget()
Description
Print a warning string which is formatted on the target before sent to the host.
Prototype
void SEGGER_SYSVIEW_WarnfTarget(const char * s,
...);
Parameters
Parameter Description
s String to be formatted.
7.4.14 SEGGER_SYSVIEW_Error()
Description
Print an error string to the host.
Prototype
void SEGGER_SYSVIEW_Error(const char * s);
Parameters
Parameter Description
s String to sent.
7.4.15 SEGGER_SYSVIEW_ErrorfHost()
Description
Print an error string which is formatted on the host by the SystemView Application.
Prototype
void SEGGER_SYSVIEW_ErrorfHost(const char * s,
...);
Parameters
Parameter Description
s String to be formatted.
Additional information
All format arguments are treated as 32-bit scalar values.
7.4.16 SEGGER_SYSVIEW_ErrorfTarget()
Description
Print an error string which is formatted on the target before sent to the host.
Prototype
void SEGGER_SYSVIEW_ErrorfTarget(const char * s,
...);
Parameters
Parameter Description
s String to be formatted.
Function Description
Register a middleware module for record-
SEGGER_SYSVIEW_RegisterModule()
ing its events.
SEGGER_SYSVIEW_RecordModuleDescrip- Sends detailed information of a registered
tion() module to the host.
7.5.1 SEGGER_SYSVIEW_RegisterModule()
Description
Register a middleware module for recording its events.
Prototype
void SEGGER_SYSVIEW_RegisterModule(SEGGER_SYSVIEW_MODULE * pModule);
Parameters
Parameter Description
pModule The middleware module information.
Additional information
SEGGER_SYSVIEW_MODULE elements: sDescription - Pointer to a string containing the module
name and optionally the module event description. NumEvents - Number of events the
module wants to register. EventOffset - Offset to be added to the event Ids. Out parameter,
set by this function. Do not modify after calling this function. pfSendModuleDesc - Callback
function pointer to send more detailed module description to SystemView Application. pNext
- Pointer to next registered module. Out parameter, set by this function. Do not modify
after calling this function.
7.5.2 SEGGER_SYSVIEW_RecordModuleDescription()
Description
Sends detailed information of a registered module to the host.
Prototype
void SEGGER_SYSVIEW_RecordModuleDescription
(const SEGGER_SYSVIEW_MODULE * pModule,
const char * sDescription);
Parameters
Parameter Description
pModule Pointer to the described module.
sDescription Pointer to a description string.
Function Description
High-level RTOS state recording
SEGGER_SYSVIEW_OnIdle() Record an Idle event.
SEGGER_SYSVIEW_OnTaskCreate() Record a Task Create event.
SEGGER_SYSVIEW_OnTaskStartExec() Record a Task Start Execution event.
SEGGER_SYSVIEW_OnTaskStartReady() Record a Task Start Ready event.
SEGGER_SYSVIEW_OnTaskStopExec() Record a Task Stop Execution event.
SEGGER_SYSVIEW_OnTaskStopReady() Record a Task Stop Ready event.
SEGGER_SYSVIEW_OnTaskTerminate() Record a Task termination event.
Low-level realtime recording
SEGGER_SYSVIEW_RecordEnterISR() Format and send an ISR entry event.
SEGGER_SYSVIEW_RecordExitISR() Format and send an ISR exit event.
SEGGER_SYSVIEW_RecordExitISRToSched- Format and send an ISR exit into sched-
uler() uler event.
SEGGER_SYSVIEW_RecordEnterTimer() Format and send a Timer entry event.
SEGGER_SYSVIEW_RecordExitTimer() Format and send a Timer exit event.
Formats and sends a SystemView Systime
SEGGER_SYSVIEW_RecordSystime() containing a single U64 or U32 parameter
payload.
7.6.1 SEGGER_SYSVIEW_OnIdle()
Description
Record an Idle event.
Prototype
void SEGGER_SYSVIEW_OnIdle(void);
7.6.2 SEGGER_SYSVIEW_OnTaskCreate()
Description
Record a Task Create event. The Task Create event corresponds to creating a task in the OS.
Prototype
void SEGGER_SYSVIEW_OnTaskCreate(U32 TaskId);
Parameters
Parameter Description
TaskId Task ID of created task.
7.6.3 SEGGER_SYSVIEW_OnTaskStartExec()
Description
Record a Task Start Execution event. The Task Start event corresponds to when a task has
started to execute rather than when it is ready to execute.
Prototype
void SEGGER_SYSVIEW_OnTaskStartExec(U32 TaskId);
Parameters
Parameter Description
TaskId Task ID of task that started to execute.
7.6.4 SEGGER_SYSVIEW_OnTaskStartReady()
Description
Record a Task Start Ready event.
Prototype
void SEGGER_SYSVIEW_OnTaskStartReady(U32 TaskId);
Parameters
Parameter Description
TaskId Task ID of task that started to execute.
7.6.5 SEGGER_SYSVIEW_OnTaskStopExec()
Description
Record a Task Stop Execution event. The Task Stop event corresponds to when a task stops
executing and terminates.
Prototype
void SEGGER_SYSVIEW_OnTaskStopExec(void);
7.6.6 SEGGER_SYSVIEW_OnTaskStopReady()
Description
Record a Task Stop Ready event.
Prototype
void SEGGER_SYSVIEW_OnTaskStopReady(U32 TaskId,
unsigned int Cause);
Parameters
Parameter Description
TaskId Task ID of task that completed execution.
Cause Reason for task to stop (i.e. Idle/Sleep)
7.6.7 SEGGER_SYSVIEW_OnTaskTerminate()
Description
Record a Task termination event. The Task termination event corresponds to terminating a
task in the OS. If the TaskId is the currently active task, SEGGER_SYSVIEW_OnTaskStopExec
may be used, either.
Prototype
void SEGGER_SYSVIEW_OnTaskTerminate(U32 TaskId);
Parameters
Parameter Description
TaskId Task ID of terminated task.
7.6.8 SEGGER_SYSVIEW_RecordEnterISR()
Description
Format and send an ISR entry event.
Prototype
void SEGGER_SYSVIEW_RecordEnterISR(void);
Additional information
Example packets sent 02 0F 50 // ISR(15) Enter. Timestamp is 80 (0x50)
7.6.9 SEGGER_SYSVIEW_RecordExitISR()
Description
Format and send an ISR exit event.
Prototype
void SEGGER_SYSVIEW_RecordExitISR(void);
Additional information
Format as follows: 03 <TimeStamp> // Max. packet len is 6
Example packets sent 03 20 // ISR Exit. Timestamp is 32 (0x20)
7.6.10 SEGGER_SYSVIEW_RecordExitISRToScheduler()
Description
Format and send an ISR exit into scheduler event.
Prototype
void SEGGER_SYSVIEW_RecordExitISRToScheduler(void);
Additional information
Format as follows: 18 <TimeStamp> // Max. packet len is 6
Example packets sent 18 20 // ISR Exit to Scheduler. Timestamp is 32 (0x20)
7.6.11 SEGGER_SYSVIEW_RecordEnterTimer()
Description
Format and send a Timer entry event.
Prototype
void SEGGER_SYSVIEW_RecordEnterTimer(U32 TimerId);
Parameters
Parameter Description
TimerId Id of the timer which starts.
7.6.12 SEGGER_SYSVIEW_RecordExitTimer()
Description
Format and send a Timer exit event.
Prototype
void SEGGER_SYSVIEW_RecordExitTimer(void);
7.6.13 SEGGER_SYSVIEW_RecordSystime()
Description
Formats and sends a SystemView Systime containing a single U64 or U32 parameter pay-
load.
Prototype
void SEGGER_SYSVIEW_RecordSystime(void);
Function Description
SEGGER_SYSVIEW_HeapDefine() Define heap.
SEGGER_SYSVIEW_HeapAlloc() Record a system-heap allocation event.
SEGGER_SYSVIEW_HeapAllocEx() Record a per-heap allocation event.
SEGGER_SYSVIEW_HeapFree() Record a heap deallocation event.
7.7.1 SEGGER_SYSVIEW_HeapDefine()
Description
Define heap.
Prototype
void SEGGER_SYSVIEW_HeapDefine(void * pHeap,
void * pBase,
unsigned int HeapSize,
unsigned int MetadataSize);
Parameters
Parameter Description
pHeap Pointer to heap control structure.
pBase Pointer to managed heap memory.
HeapSize Size of managed heap memory in bytes.
MetadataSize Size of metadata associated with each heap allocation.
Additional information
SystemView can track allocations across multiple heaps.
HeapSize must be a multiple of the natural alignment unit of the target. This size is subject
to compression, controlled by the specific setting of SEGGER_SYSVIEW_ID_SHIFT.
MetadataSize defines the size of the per-allocation metadata. For many heap implementa-
tions, the metadata size is a multiple of the word size of the machine and typically contains
the size of the allocated block (used upon deallocation), optional pointers to the preceding
and/or following blocks, and optionally a tag identifying the owner of the block. Note that
MetadataSize is not compressed within the SystemView packet and is not required to be
a multiple of 1<<SEGGER_SYSVIEW_ID_SHIFT.
7.7.2 SEGGER_SYSVIEW_HeapAlloc()
Description
Record a system-heap allocation event.
Prototype
void SEGGER_SYSVIEW_HeapAlloc(void * pHeap,
void * pUserData,
unsigned int UserDataLen);
Parameters
Parameter Description
pHeap Pointer to heap where allocation was made.
pUserData Pointer to allocated user data.
Size of block allocated to hold user data, excluding any
UserDataLen
metadata.
Additional information
The user data must be correctly aligned for the architecture, which typically requires that
the alignment is at least the alignment of a double or a long long. pUserData is, therefore,
compressed by shrinking as IDs are compressed, controlled by the specific setting of SEG-
GER_SYSVIEW_ID_SHIFT.
In the same way, UserDataLen must reflect the size of the allocated block, not the allocation
size requested by the application. This size is also subject to compression, controlled by
the specific setting of SEGGER_SYSVIEW_ID_SHIFT.
As an example, assume the allocator is running on a Cortex-M device with SEG-
GER_SYSVIEW_ID_SHIFT set to 2 (the word alignment of the device). If a user requests
an allocation of 5 bytes, a hypothetical heap allocator could allocate a block with size
32 bytes for this. The value of UserDataLen sent to SystemView for recording should be
32, not 5, and the 32 is compressed by shifting by two bits, the configured value of SEG-
GER_SYSVIEW_ID_SHIFT, and describes the number of bytes that are consumed from man-
aged memory from which SystemView can calculate accurate heap metrics.
7.7.3 SEGGER_SYSVIEW_HeapAllocEx()
Description
Record a per-heap allocation event.
Prototype
void SEGGER_SYSVIEW_HeapAllocEx(void * pHeap,
void * pUserData,
unsigned int UserDataLen,
unsigned int Tag);
Parameters
Parameter Description
pHeap Pointer to heap where allocation was made.
pUserData Pointer to allocated user data.
Size of block allocated to hold user data, excluding any
UserDataLen
metadata.
Tag Block tag, typically used to identify the owner of the block.
Additional information
The user data must be correctly aligned for the architecture, which typically requires that
the alignment is at least the alignment of a double or a long long. pUserData is, therefore,
compressed by shrinking as IDs are compressed, controlled by the specific setting of SEG-
GER_SYSVIEW_ID_SHIFT.
In the same way, UserDataLen must reflect the size of the allocated block, not the allocation
size requested by the application. This size is also subject to compression, controlled by
the specific setting of SEGGER_SYSVIEW_ID_SHIFT.
As an example, assume the allocator is running on a Cortex-M device with SEG-
GER_SYSVIEW_ID_SHIFT set to 2 (the word alignment of the device). If a user requests
an allocation of 5 bytes, a hypothetical heap allocator could allocate a block with size
32 bytes for this. The value of UserDataLen sent to SystemView for recording should be
32, not 5, and the 32 is compressed by shifting by two bits, the configured value of SEG-
GER_SYSVIEW_ID_SHIFT, and describes the number of bytes that are consumed from man-
aged memory from which SystemView can calculate accurate heap metrics.
7.7.4 SEGGER_SYSVIEW_HeapFree()
Description
Record a heap deallocation event.
Prototype
void SEGGER_SYSVIEW_HeapFree(void * pHeap,
void * pUserData);
Parameters
Parameter Description
pHeap Pointer to heap where allocation was made.
pUserData Pointer to allocated user data.
Additional information
SystemViews track allocations and knows the size of the allocated data.
Function Description
API Function Call
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordVoid()
with an empty payload.
Formats and sends a SystemView pack-
SEGGER_SYSVIEW_RecordU32() et containing a single U32 parameter pay-
load.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x2()
containing 2 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x3()
containing 3 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x4()
containing 4 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x5()
containing 5 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x6()
containing 6 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x7()
containing 7 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x8()
containing 8 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x9()
containing 9 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordU32x10()
containing 10 U32 parameter payload.
Formats and sends a SystemView packet
SEGGER_SYSVIEW_RecordString()
containing a string.
API Function Return
Format and send an End API Call event
SEGGER_SYSVIEW_RecordEndCall()
without return value.
Format and send an End API Call event
SEGGER_SYSVIEW_RecordEndCallU32()
with return value.
7.8.1 SEGGER_SYSVIEW_RecordVoid()
Description
Formats and sends a SystemView packet with an empty payload.
Prototype
void SEGGER_SYSVIEW_RecordVoid(unsigned int EventID);
Parameters
Parameter Description
EventID SystemView event ID.
7.8.2 SEGGER_SYSVIEW_RecordU32()
Description
Formats and sends a SystemView packet containing a single U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32(unsigned int EventID,
U32 Value);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Value
load.
7.8.3 SEGGER_SYSVIEW_RecordU32x2()
Description
Formats and sends a SystemView packet containing 2 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x2(unsigned int EventID,
U32 Para0,
U32 Para1);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
7.8.4 SEGGER_SYSVIEW_RecordU32x3()
Description
Formats and sends a SystemView packet containing 3 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x3(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
7.8.5 SEGGER_SYSVIEW_RecordU32x4()
Description
Formats and sends a SystemView packet containing 4 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x4(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2,
U32 Para3);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
The 32-bit parameter encoded to SystemView packet pay-
Para3
load.
7.8.6 SEGGER_SYSVIEW_RecordU32x5()
Description
Formats and sends a SystemView packet containing 5 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x5(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2,
U32 Para3,
U32 Para4);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
The 32-bit parameter encoded to SystemView packet pay-
Para3
load.
The 32-bit parameter encoded to SystemView packet pay-
Para4
load.
7.8.7 SEGGER_SYSVIEW_RecordU32x6()
Description
Formats and sends a SystemView packet containing 6 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x6(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2,
U32 Para3,
U32 Para4,
U32 Para5);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
The 32-bit parameter encoded to SystemView packet pay-
Para3
load.
The 32-bit parameter encoded to SystemView packet pay-
Para4
load.
The 32-bit parameter encoded to SystemView packet pay-
Para5
load.
7.8.8 SEGGER_SYSVIEW_RecordU32x7()
Description
Formats and sends a SystemView packet containing 7 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x7(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2,
U32 Para3,
U32 Para4,
U32 Para5,
U32 Para6);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
The 32-bit parameter encoded to SystemView packet pay-
Para3
load.
The 32-bit parameter encoded to SystemView packet pay-
Para4
load.
The 32-bit parameter encoded to SystemView packet pay-
Para5
load.
The 32-bit parameter encoded to SystemView packet pay-
Para6
load.
7.8.9 SEGGER_SYSVIEW_RecordU32x8()
Description
Formats and sends a SystemView packet containing 8 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x8(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2,
U32 Para3,
U32 Para4,
U32 Para5,
U32 Para6,
U32 Para7);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
The 32-bit parameter encoded to SystemView packet pay-
Para3
load.
The 32-bit parameter encoded to SystemView packet pay-
Para4
load.
The 32-bit parameter encoded to SystemView packet pay-
Para5
load.
The 32-bit parameter encoded to SystemView packet pay-
Para6
load.
The 32-bit parameter encoded to SystemView packet pay-
Para7
load.
7.8.10 SEGGER_SYSVIEW_RecordU32x9()
Description
Formats and sends a SystemView packet containing 9 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x9(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2,
U32 Para3,
U32 Para4,
U32 Para5,
U32 Para6,
U32 Para7,
U32 Para8);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
The 32-bit parameter encoded to SystemView packet pay-
Para3
load.
The 32-bit parameter encoded to SystemView packet pay-
Para4
load.
The 32-bit parameter encoded to SystemView packet pay-
Para5
load.
The 32-bit parameter encoded to SystemView packet pay-
Para6
load.
The 32-bit parameter encoded to SystemView packet pay-
Para7
load.
The 32-bit parameter encoded to SystemView packet pay-
Para8
load.
7.8.11 SEGGER_SYSVIEW_RecordU32x10()
Description
Formats and sends a SystemView packet containing 10 U32 parameter payload.
Prototype
void SEGGER_SYSVIEW_RecordU32x10(unsigned int EventID,
U32 Para0,
U32 Para1,
U32 Para2,
U32 Para3,
U32 Para4,
U32 Para5,
U32 Para6,
U32 Para7,
U32 Para8,
U32 Para9);
Parameters
Parameter Description
EventID SystemView event ID.
The 32-bit parameter encoded to SystemView packet pay-
Para0
load.
The 32-bit parameter encoded to SystemView packet pay-
Para1
load.
The 32-bit parameter encoded to SystemView packet pay-
Para2
load.
The 32-bit parameter encoded to SystemView packet pay-
Para3
load.
The 32-bit parameter encoded to SystemView packet pay-
Para4
load.
The 32-bit parameter encoded to SystemView packet pay-
Para5
load.
The 32-bit parameter encoded to SystemView packet pay-
Para6
load.
The 32-bit parameter encoded to SystemView packet pay-
Para7
load.
The 32-bit parameter encoded to SystemView packet pay-
Para8
load.
The 32-bit parameter encoded to SystemView packet pay-
Para9
load.
7.8.12 SEGGER_SYSVIEW_RecordString()
Description
Formats and sends a SystemView packet containing a string.
Prototype
void SEGGER_SYSVIEW_RecordString( unsigned int EventID,
const char * pString);
Parameters
Parameter Description
EventID SystemView event ID.
pString The string to be sent in the SystemView packet payload.
Additional information
The string is encoded as a count byte followed by the contents of the string. No more than
SEGGER_SYSVIEW_MAX_STRING_LEN bytes will be encoded to the payload.
7.8.13 SEGGER_SYSVIEW_RecordEndCall()
Description
Format and send an End API Call event without return value.
Prototype
void SEGGER_SYSVIEW_RecordEndCall(unsigned int EventID);
Parameters
Parameter Description
EventID Id of API function which ends.
7.8.14 SEGGER_SYSVIEW_RecordEndCallU32()
Description
Format and send an End API Call event with return value.
Prototype
void SEGGER_SYSVIEW_RecordEndCallU32(unsigned int EventID,
U32 Para0);
Parameters
Parameter Description
EventID Id of API function which ends.
Para0 Return value which will be returned by the API function.
Function Description
SEGGER_SYSVIEW_EncodeU32() Encode a U32 in variable-length format.
Encode a byte buffer in variable-length for-
SEGGER_SYSVIEW_EncodeData()
mat.
SEGGER_SYSVIEW_EncodeString() Encode a string in variable-length format.
Encode a 32-bit Id in shrunken vari-
SEGGER_SYSVIEW_EncodeId()
able-length format.
Get the shrunken value of an Id
SEGGER_SYSVIEW_ShrinkId() for further processing like in SEG-
GER_SYSVIEW_NameResource().
7.9.1 SEGGER_SYSVIEW_EncodeU32()
Description
Encode a U32 in variable-length format.
Prototype
U8 *SEGGER_SYSVIEW_EncodeU32(U8 * pPayload,
U32 Value);
Parameters
Parameter Description
pPayload Pointer to where U32 will be encoded.
Value The 32-bit value to be encoded.
Return value
Pointer to the byte following the value, i.e. the first free byte in the payload and the next
position to store payload content.
7.9.2 SEGGER_SYSVIEW_EncodeData()
Description
Encode a byte buffer in variable-length format.
Prototype
U8 *SEGGER_SYSVIEW_EncodeData( U8 * pPayload,
const char * pSrc,
unsigned int NumBytes);
Parameters
Parameter Description
pPayload Pointer to where string will be encoded.
pSrc Pointer to data buffer to be encoded.
NumBytes Number of bytes in the buffer to be encoded.
Return value
Pointer to the byte following the value, i.e. the first free byte in the payload and the next
position to store payload content.
Additional information
The data is encoded as a count byte followed by the contents of the data buffer. Make sure
NumBytes + 1 bytes are free for the payload.
7.9.3 SEGGER_SYSVIEW_EncodeString()
Description
Encode a string in variable-length format.
Prototype
U8 *SEGGER_SYSVIEW_EncodeString( U8 * pPayload,
const char * s,
unsigned int MaxLen);
Parameters
Parameter Description
pPayload Pointer to where string will be encoded.
s String to encode.
MaxLen Maximum number of characters to encode from string.
Return value
Pointer to the byte following the value, i.e. the first free byte in the payload and the next
position to store payload content.
Additional information
The string is encoded as a count byte followed by the contents of the string. No more than
1 + MaxLen bytes will be encoded to the payload.
7.9.4 SEGGER_SYSVIEW_EncodeId()
Description
Encode a 32-bit Id in shrunken variable-length format.
Prototype
U8 *SEGGER_SYSVIEW_EncodeId(U8 * pPayload,
U32 Id);
Parameters
Parameter Description
pPayload Pointer to where the Id will be encoded.
Id The 32-bit value to be encoded.
Return value
Pointer to the byte following the value, i.e. the first free byte in the payload and the next
position to store payload content.
Additional information
The parameters to shrink an Id can be configured in SEGGER_SYSVIEW_Conf.h and
via SEGGER_SYSVIEW_SetRAMBase(). SEGGER_SYSVIEW_ID_BASE: Lowest Id reported by
the application. (i.e. 0x20000000 when all Ids are an address in this RAM) SEG-
GER_SYSVIEW_ID_SHIFT: Number of bits to shift the Id to save bandwidth. (i.e. 2 when
Ids are 4 byte aligned)
7.9.5 SEGGER_SYSVIEW_ShrinkId()
Description
Get the shrunken value of an Id for further processing like in SEGGER_SYSVIEW_NameRe-
source().
Prototype
U32 SEGGER_SYSVIEW_ShrinkId(U32 Id);
Parameters
Parameter Description
Id The 32-bit value to be shrunken.
Return value
Shrunken Id.
Additional information
The parameters to shrink an Id can be configured in SEGGER_SYSVIEW_Conf.h and
via SEGGER_SYSVIEW_SetRAMBase(). SEGGER_SYSVIEW_ID_BASE: Lowest Id reported by
the application. (i.e. 0x20000000 when all Ids are an address in this RAM) SEG-
GER_SYSVIEW_ID_SHIFT: Number of bits to shift the Id to save bandwidth. (i.e. 2 when
Ids are 4 byte aligned)
7.9.6 SEGGER_SYSVIEW_SendPacket()
Description
Send an event packet.
Prototype
int SEGGER_SYSVIEW_SendPacket(U8 * pPacket,
U8 * pPayloadEnd,
unsigned int EventId);
Parameters
Parameter Description
pPacket Pointer to the start of the packet.
Pointer to the end of the payload. Make sure there are at
pPayloadEnd
least 5 bytes free after the payload.
EventId Id of the event packet.
Return value
≠0 Success, Message sent.
=0 Buffer full, Message *NOT* sent.
Function Description
SEGGER_SYSVIEW_Conf() Initialize and configures SystemView.
Callback called by SystemView to get the
SEGGER_SYSVIEW_X_GetTimestamp()
timestamp in cycles.
7.10.1 SEGGER_SYSVIEW_Conf()
Description
Can be used with OS integration to allow easier initialization of SystemView and the OS
SystemView interface.
This function is usually provided in the SEGGER_SYSVIEW_Config_<OS>.c configuration file
of the used OS.
Prototype
void SEGGER_SYSVIEW_Conf(void);
Example implementation
void SEGGER_SYSVIEW_Conf(void) {
//
// Initialize SystemView
//
SEGGER_SYSVIEW_Init(SYSVIEW_TIMESTAMP_FREQ, // Frequency of the timestamp.
SYSVIEW_CPU_FREQ, // Frequency of the system.
&SYSVIEW_X_OS_TraceAPI,
// OS-specific SEGGER_SYSVIEW_OS_API
_cbSendSystemDesc
// Callback for application-specific description
);
SEGGER_SYSVIEW_SetRAMBase(SYSVIEW_RAM_BASE);
// Explicitly set the RAM base address.
OS_SetTraceAPI(&embOS_TraceAPI_SYSVIEW);
// Configure embOS to use SystemView via the Trace-API.
}
7.10.2 SEGGER_SYSVIEW_X_GetTimestamp()
Description
This function must be implemented when SEGGER_SYSVIEW_GET_TIMESTAMP() is configured
to call it. By default this is done on all non-Cortex-M3/4 targets.
Prototype
U32 SEGGER_SYSVIEW_X_GetTimestamp(void);
Return value
Returns the current system timestamp in timestamp cycles. On Cortex-M3 and Cortex-M4
this is the cycle counter.
Example implementation
U32 SEGGER_SYSVIEW_X_GetTimestamp(void) {
U32 TickCount;
U32 Cycles;
U32 CyclesPerTick;
//
// Get the cycles of the current system tick.
// SysTick is down-counting, subtract the current value from the number of cycles per tick.
//
CyclesPerTick = SYST_RVR + 1;
Cycles = (CyclesPerTick - SYST_CVR);
//
// Get the system tick count.
//
TickCount = SEGGER_SYSVIEW_TickCnt; // SEGGER_SYSVIEW_TickCnt is incremented by the system tick
//
// If a SysTick interrupt is pending increment the TickCount
//
if ((SCB_ICSR & SCB_ICSR_PENDSTSET_MASK) != 0) {
TickCount++;
}
Cycles += TickCount * CyclesPerTick;
return Cycles;
}
This chapter covers the performance and resource usage of SystemView. It contains infor-
mation about the memory requirements in typical systems which can be used to obtain
sufficient estimates for most target systems.
Description ROM
Minimum core code required when using SystemView ~920 Byte
Basic SystemView recording functions for application, OS and module
~380 Byte
events
OS-related SystemView recording functions ~360 Byte
Middleware module-related recording functions ~120 Byte
Complete SystemView Module ~1.8 KByte
The following table list the ROM usage of SystemView with different configurations.
Since SystemView handles incoming requests for the system description and task informa-
tion, there must be enough free space on the stack to record an event and to send the
system description, which is recording another event.
SystemView can be configured to select between lower stack usage or less static RAM use.
Q: I get overflow events when continuously recording. How can I prevent this?
A: Overflow events occur when the SystemVIew RTT buffer is full. This can happen for
following reasons:
• J-Link is kept busy by a debugger and cannot read the data fast enough.
• The target interface speed is too low to read the data fast enough.
• The application generates too many events to fit into the buffer.
To prevent this:
• Minimize the interactions of the debugger with J-Link while the target is running. (e.g.
disable live watches)
• Select a higher interface speed in all instances connected to J-Link. (e.g. the debugger
and SystemView)
• Choose a larger buffer for SystemView. (1 - 4 kByte)
• Run SystemView stand-alone without a debugger.
Q: SystemView cannot find the RTT Control Block, how can I configure it?
A: Auto-detection of the RTT Control Block can only be done in a known RAM address range
after it is initialized. Make sure the application startup has run when starting to record.
If the RTT Control Block is outside the known range for the selected device, either select
’Address’ and enter the exact address of the RTT Control Block or select ’Address Range’
and enter an address range in which the RTT Control Block will be.
A: Yes. J-Link must know which target device is connected. The drop-down lists the most
recently used devices. To select another device simply enter its name. A list of supported
devices can be found here.