当前位置:网站首页>STM32CubeIDE SWV功能使用方法
STM32CubeIDE SWV功能使用方法
2022-06-24 19:45:00 【strongerHuang】
关注+星标公众号,不错过精彩内容

转自 | STM32单片机
很多工具都自带有 SWV (Serial Wire Viewer)的功能,之前给大家分享的《打印输出教程》就描述了在Keil、IAR、ST-LINK Utility、STM32CubeProg、J-Link等工具下实现“SWV”的功能。
今天再给大家分享一下STM32CubeIDE的SWV功能。

第一步:在Pinout & Configuration选项中打开SWO的功能,此步骤是必须的。

STM32CubeIDE中使能SWO功能

第二步:重定位printf的接口函数。
这里有个简单的方法,直接在syscalls.c文件中,改写_write()函数的内容,代码如下所示。再在此文件中包含ITM_SendChar 实现的头文件core_cmX.h,此文件一般都是已经被包含在你所选择的器件型号的头文件中。
此处我们选择的是stm32g431xx.h,直接放在此文件的开始处即可。


第三步:在main.c文件中包含stdio.h这个头文件,并尝试打印printf,此处注意,打印不能很频繁,所以需要增加延时。

全局编译一下,查看是否有错误,如果有错误,请对应提示信息修改。编译没有错误之后,我们就可以进行下一步了。


第四步:配置仿真调试参数。打开SWV的调试功能。此处注意:Core Clock必须与你配置的时钟是一致的。此处我配置是170MHz,与我的系统时钟一致。


第五步:开始进入调试界面,并在调试界面中打开Windows-->Show;View-->SWV的ITM data Console窗口。注意,整个SWV其实是共用一个配置文件的,所以,当你打开SWV内的任意一个窗口都可以进行SWV 的配置。在这里我们只是为了查看Printf的内容,所以就选择了SWV ITM Data Console窗口。关于这里边其他几个部分的详细说明参考UM2609的4.3章节的内容。

开启SWV ITM数据窗口
此窗口打开后,需要新增一个Port端口。默认TIM中使用的就是0端口,所以我们直接选0即可。

增加输出端口
选择点击配置按钮对参数进行配置。配置情况如下:

SWV窗口配置界面
推荐先复位一下工程(可选项),然后“启动跟踪/start trace”。注意:此处是先启动跟踪,之后再让程序运行起来,不能反序。

启动跟踪和开始运行
此时即可看到打印出来的内容了。

最后打印输出的状态
------------ END ------------

关注公众号回复“加群”按规则加入技术交流群,回复“1024”查看更多内容。


点击“阅读原文”查看更多分享。
边栏推荐
- R language uses GLM function to build Poisson log linear regression model, processes three-dimensional contingency table data to build saturation model, uses summary function to obtain model summary s
- 文件包含漏洞问题
- UNION ALL UNION FULL JOIN
- Simpledateformat concrete classes for formatting and parsing dates
- websocket长链接压测
- What good smart home brands in China support homekit?
- Binary lookup array subscript
- [JS] - [linked list - application] - learning notes
- 点的螺旋距离
- Ningde times will increase RMB 45billion: Hillhouse subscribes RMB 3billion and Zeng Yuqun still controls 23% of the equity
猜你喜欢

Installing IBM CPLEX academic edition | CONDA installing CPLEX

What good smart home brands in China support homekit?
![[JS] - [string - application] - learning notes](/img/dc/f35979b094f04c0ee13b3354c7741d.png)
[JS] - [string - application] - learning notes

国内有哪些好的智能家居品牌支持homekit?

From client to server

【js】-【字符串-应用】- 学习笔记
![[JS] - [array, stack, queue, linked list basics] - Notes](/img/c6/a1bd3b8ef6476d7d549abcb442949a.png)
[JS] - [array, stack, queue, linked list basics] - Notes

Adding, deleting, querying and modifying MySQL tables

Design and practice of vivo server monitoring architecture

7-6 铺设油井管道
随机推荐
二分查找数组下标
Continuous soul torture from two MySQL indexes of interviewers
R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用AIC函数比较两个模型的AIC值的差异(简单模型和复杂模型)
Go language pointer, value reference and pointer reference
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses exp function and coef function to obtain the corresponding odds rat
Morris遍历
Helix distance of point
Ningde times will increase RMB 45billion: Hillhouse subscribes RMB 3billion and Zeng Yuqun still controls 23% of the equity
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、对匹配后的样本的不同分组对应的目标变量的均值进行Welch双样本t检验分析、双独立样本t检验
golang convert map to json string
RT thread uses RT kprintf
Harmonyos accessing database instances (3) -- use ORM bee to test how good harmonyos is
7-6 laying oil well pipeline
Design and practice of vivo server monitoring architecture
Huawei machine learning service speech recognition function enables applications to paint "sound" and color
QT to place the form in the lower right corner of the desktop
一文理解OpenStack网络
Installation and deployment of ganglia
jar中没有主清单属性
【js】-【字符串-应用】- 学习笔记