章节5 目标板程序SystemView模块的实现
来源:互联网 发布:淘宝联系客服链接 编辑:程序博客网 时间:2024/06/08 05:16
本文博客链接:http://blog.csdn.net/bjr2016,作者:bjr2016,未经允许不得转载。
章节5 目标板程序SystemView模块的实现
本节描述了目标应用程序如何添加SEGGER SystemView模块。
5.1 先决条件
想要使用SEGGER SystemView,首先要把SystemView源码文件加到目标应用程序工程中。SEGGER SystemView源码包可以从https://www.segger.com/systemview.html下载。
要实现连续实时跟踪,还有以下几项要求:
- 一个ARM Cortex-M 或者 Renesas RX 核的目标设备
- 一个J-Link调试器
要想快速把SystemView用起来,推荐使用embOS V4.12或者更新版本(已经集成在SystemView中了)。
5.1 SEGGER SystemView目标实现模块
以下文件是SEGGER SystemView目标实现的一部分。我们建议将所有文件复制到应用程序工程中,并维持目录结构。
5.2 在应用程序中引用SEGGER_SystemView
要使用SEGGER SystemView,目标实现模块必须添加到目标程序中。从文件夹/Config/和/SEGGER/中拷贝源码文件,以及复制匹配你程序所使用的系统和OS的SEGGER_SYSVIEW_Config_[SYSTEM].c和SEGGER_SYSVIEW_[OS].c及其头文件,并在工程中引用它们。
示例
例如一个在Cortex-M3芯片上使用了embOS的系统,那么应该引用 SEGGER_SYSVIEW_Config_embOS.c,SEGGER_SYSVIEW_embOS.c和SEGGER_SYSVIEW_embOS.h。
而对于一个在Cortex-M3芯片上的没有操作系统或者no instrumented OS的系统,那么只需要引用 SEGGER_SYSVIEW_NoOS.c。
5.3 初始化SystemView
系统信息是由应用程序发送的。这个信息可以通过SEGGER_SYSVIEW_Config_[SYSTEM]. c中的定义来配置。我们可以在main函数中添加一个调用SEGGER_SYSVIEW_Conf()来初始化SystemView。
#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 */ /* You need to create at least one task before calling OS_Start() */ OS_CREATETASK(&TCB0, "MainTask", MainTask, 100, Stack0); OS_Start(); /* Start multitasking */ return 0;}
SEGGER SystemView的通用部分现在已经准备好监视应用程序了。
当使用启用了分析功能的embOS V4.12或更高版本时,将生成中断、任务和API调用这四种SystemView事件。当不使用embOS时,应用程序必须产生适当的事件。
将应用程序下载到目标板并运行。只要SystemView程序没有连接,并且不调用SEGGER_SYSVIEW_Start(),应用程序就不会生成SystemView事件。当连接了SystemView程序或者调用了SEGGER_SYSVIEW_Start时,它将激活记录SystemView事件。
5.4 启动和停止录制
当使用SystemView连续读取数据时,SystemView自动开始和停止记录。当SystemView没有录制时,目标系统不会生成SystemView事件。
对于single-shot录制,在应用程序中必须调用SEGGER_SYSVIEW_Start,用来激活录制SystemView事件。事件会一直被记录,直到SystemView缓冲区被填满或调用了SEGGER_SYSVIEW_Stop。
对于事后分析,在应用程序中必须调用SEGGER_SYSVIEW_Start,用来激活录制SystemView事件。事件会一直被记录,直到调用了SEGGER_SYSVIEW_Stop。当SystemView缓冲区被填满时,老的事件将被覆盖。
5.5 SystemView系统信息配置**
SEGGER_SYSVIEW_Config_[SYSTEM].c文件提供了SystemView的配置。大多数情况下,不需要修改就可以使用。
/********************************************************************** SEGGER Microcontroller GmbH & Co. KG ** The Embedded Experts ************************************************************************ ** (c) 2015 - 2017 SEGGER Microcontroller GmbH & Co. KG ** ** www.segger.com Support: support@segger.com ** ************************************************************************ ** SEGGER SystemView * Real-time application analysis ** ************************************************************************ ** SystemView version: V2.52a ** ***********************************************************************-------------------------- END-OF-HEADER -----------------------------File : SEGGER_SYSVIEW_Config_embOS.cPurpose : Sample setup configuration of SystemView with embOS.Revision: $Rev: 7750 $*/#include "RTOS.h"#include "SEGGER_SYSVIEW.h"#include "SEGGER_SYSVIEW_Conf.h"#include "SEGGER_SYSVIEW_embOS.h"//// SystemcoreClock can be used in most CMSIS compatible projects.// In non-CMSIS projects define SYSVIEW_CPU_FREQ.//extern unsigned int SystemCoreClock;/*********************************************************************** Defines, configurable************************************************************************/// The application name to be displayed in SystemViewer#ifndef SYSVIEW_APP_NAME #define SYSVIEW_APP_NAME "Demo Application"#endif// The target device name#ifndef SYSVIEW_DEVICE_NAME #define SYSVIEW_DEVICE_NAME "Cortex-M4"#endif// Frequency of the timestamp. Must match SEGGER_SYSVIEW_Conf.h#ifndef SYSVIEW_TIMESTAMP_FREQ #define SYSVIEW_TIMESTAMP_FREQ (SystemCoreClock)#endif// System Frequency. SystemcoreClock is used in most CMSIS compatible projects.#ifndef SYSVIEW_CPU_FREQ #define SYSVIEW_CPU_FREQ (SystemCoreClock)#endif// The lowest RAM address used for IDs (pointers)#ifndef SYSVIEW_RAM_BASE #define SYSVIEW_RAM_BASE (0x20000000)#endif#ifndef SYSVIEW_SYSDESC0 #define SYSVIEW_SYSDESC0 "I#15=SysTick"#endif// Define as 1 if the Cortex-M cycle counter is used as SystemView timestamp. Must match SEGGER_SYSVIEW_Conf.h#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//#ifndef SYSVIEW_SYSDESC1// #define SYSVIEW_SYSDESC1 ""//#endif//#ifndef SYSVIEW_SYSDESC2// #define SYSVIEW_SYSDESC2 ""//#endif/*********************************************************************** Defines, fixed************************************************************************/#define DEMCR (*(volatile OS_U32*) (0xE000EDFCuL)) // Debug Exception and Monitor Control Register#define TRACEENA_BIT (1uL << 24) // Trace enable bit#define DWT_CTRL (*(volatile OS_U32*) (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 ",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}/*********************************************************************** 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 // // 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 } }#endif 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.}/*************************** End of file ****************************/
- 章节5 目标板程序SystemView模块的实现
- 章节2 开始使用SystemView
- 章节3 SystemView PC端应用程序
- 章节4 使用SystemView进行记录
- 章节6 目标板配置
- SystemView
- 嵌入式目标板程序的压缩(3)--实现目标板解压升级程序功能
- 一种Java与OpenCV结合实现的目标检测模块
- 基于opencv的计算机视觉技术实现 第五章节第一个程序 改错
- c语言接口与实现--原子atom章节例子程序的理解
- 简单的Java程序(章节摘要)
- 《一段程序的人生》章节索引
- 开发程序的目标
- 实现目标的方法
- 模块管理常规功能自定义系统的设计与实现(21--第二阶段设计目标)
- systemview里设置不同循环时的参数
- 自定义iptables/netfilter的目标模块
- 简单的调试目标程序
- 20171111
- 第二周 神经网络基础
- 发博客只是为了记录自己学习过程的东西,到时候要使用的时候忘记 免得在寻找
- 关于Construct2游戏制作策划与成果
- jQuery属性html()、text()、和val()方法的对比
- 章节5 目标板程序SystemView模块的实现
- 6.17兑换人民币
- <map>标签
- LeetCode题解 week10
- SpringMvc学习之路
- 在Spring3中,配置DataSource的方法有5种
- jQuery过滤
- Android应用稳定性优化--快速点击产生异常的解决思路
- Unity日常——关于射线