SystemView is an embedded system visualization analysis tool that provides complete insights into applications, including visual windows for timelines, CPU load, runtime information, and context runtime information, helping developers gain an in-depth understanding of application runtime behavior. It supports μC/OS-II, μC/OS-III, FreeRTOS, embOS, and bare-metal systems without an OS, allowing for a deep understanding of applications.
For applications using an OS, SystemView can analyze the entire system as an idle analysis method (click to read previous articles: Using SystemView in Bare-Metal Systems), and it can also detect system runtime behavior through task-based methods.
The specific integration steps are as follows:
1. Create a new project for the device being used in Embedded Studio.
2. Add all files from the /SEGGER and /Config folders in the SystemView installation directory, as well as the Sample/NoOS/Config/Cortex-M/SEGGER_SYSVIEW_Config_NoOS.c code file to the project.

3. Include SEGGER_SYSVIEW_Conf.h and SEGGER_SYSVIEW.h in main.c
#include “SEGGER_SYSVIEW_Conf.h”
#include “SEGGER_SYSVIEW.h”
4. Modify SEGGER_SYSVIEW_Conf.h to set SEGGER_SYSVIEW_ID_BASE to 0x0
#define SEGGER_SYSVIEW_ID_BASE 0x00000000
5. In SEGGER_SYSVIEW_Config_NoOS.c, include stdio.h and string.h
#include
#include
Add a SEGGER_SYSVIEW_OS_API pointer,
static const SEGGER_SYSVIEW_OS_API _NoOSAPI = {NULL, _cbSendTaskList};
Create a static void _cbSendTaskList(void) function to send all “task” information using SEGGER_SYSVIEW_SendTaskInfo.
static void _cbSendTaskList(void) {
for (int n = 0; n < _NumTasks; n++) {
SEGGER_SYSVIEW_SendTaskInfo(&_aTasks[n]);
}
}
Here, “Tasks” are functions directly called from main, and nested functions can be added using the API description method.
6. Call SEGGER_SYSVIEW_Conf(); in the main() function.
Next, call SEGGER_SYSVIEW_OnTaskCreate() to add the “Task” function. It is recommended to create a helper function for this task, such as SYSVIEW_AddTask in the sample project.
void SYSVIEW_AddTask(void* pTask, const char* sName, U32 Prio) {
int n;
SEGGER_SYSVIEW_OnTaskCreate((U32)pTask);
if (_NumTasks > NUM_TASKS) {
return;
}
n = _NumTasks;
_NumTasks++;
_aTasks[n].TaskID = (U32)pTask;
_aTasks[n].sName = sName;
_aTasks[n].Prio = Prio;
_aTasks[n].StackBase = 0;
_aTasks[n].StackSize = 0;
}
The SYSVIEW_AddTask call looks like this:
SYSVIEW_AddTask(_TestFunc0, “TestFunc0”, 10);
7. You can initialize the system tick clock in the main application and call SEGGER_SYSVIEW_RecordEnterISR() at the beginning of the tick handler Systick_Handler; call SEGGER_SYSVIEW_RecordExitISR() at the end.
void SysTick_Handler(void) {
volatile U32 Cnt;
SEGGER_SYSVIEW_RecordEnterISR();
Cnt++;
SEGGER_SYSVIEW_RecordExitISR();
}
8. Call the “task” functions that need to be recorded in the application.
9. You can call SEGGER_SYSVIEW_RecordVoid() and SEGGER_SYSVIEW_RecordEndCall() in the function implementation to record function nesting.
10. Run the application and start SystemView tracing.
If the build is successful, the SystemView record should look like the following image:

A general example project based on Cortex-M4 can be downloaded from the link (or click “Read the original text” at the end): https://wiki.segger.com/images/1/1f/SysView_NoOS_Tasked_GenericCortexM4_Example.zip

END
Source: Microtech Technology
Copyright belongs to the original author. If there is any infringement, please contact for deletion.
▍Recommended Reading
Cartoon | The Sad State of Chinese Software Development
A Huawei C Language Interview Question that Many Failed!
A hard drive that cannot be described is broken, but it is too embarrassing to repair…