当前位置:网站首页>stm32 printf 重定向 虚拟示波器
stm32 printf 重定向 虚拟示波器
2022-04-22 05:42:00 【sameTimer】
KEIL MDK 中使用DEBUG_VIEWER
#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))
#define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
#define TRCENA 0x01000000
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
#ifdef DEBUGVIEWER //使用DEBUG_VIEWER
if (DEMCR & TRCENA)
{
while (ITM_Port32(0) == 0);
ITM_Port8(0) = ch;
}
return(ch);
#else //使用Usart 输出Printf
HAL_UART_Transmit(&huart2,(uint8_t*)&ch,1,0xFFFF);
return (ch);
#endif
}
使用山外多功能调试助手的虚拟示波器
数据传输格式为0x03 0xFC .....0x03 0xFC
#define CMD_WARE 0x03
void Putbuff(UART_HandleTypeDef *huart,uint8_t *buff,uint32_t len)
{
while(len--)
{
HAL_UART_Transmit(huart,(uint8_t*)buff,1,0xFF);
buff++;
}
}
void SendData(void* dat,uint16_t size)
{
uint8_t cmdf[2] = {CMD_WARE, ~CMD_WARE};
uint8_t cmdr[2] = {~CMD_WARE, CMD_WARE};
Putbuff(&huart2, cmdf, sizeof(cmdf));
Putbuff(&huart2, (uint8_t *)dat, size);
Putbuff(&huart2, cmdr, sizeof(cmdr));
}
版权声明
本文为[sameTimer]所创,转载请带上原文链接,感谢
https://blog.csdn.net/hqm178933/article/details/83747611
边栏推荐
- 抓包工具mitmproxy和Anyproxy
- geojson文件shapefile文件 批量 互转 小工具
- 第87篇 LeetCode剑指Offer动态规划(四)连续子数组的最大和
- 16 - Container Comprehensive Training
- Alist easy to use guide
- Telbot load balancing settings
- Golang learning and school recruitment experience
- 马斯克更新微信推送(狗狗币)
- Blue Bridge Cup 31 day sprint Day17
- [2022 Ali security] real scene tampering image detection challenge final rank17 scheme sharing
猜你喜欢

Blue Bridge Cup 31 day sprint Day8

Blue Bridge Cup 31 day sprint Day7

Blue Bridge Cup 31 day sprint Day5

05 - variables and identifiers

Introduction to machine learning -- comparison and fancy indexing in numpy

geojson文件shapefile文件 批量 互转 小工具

第73篇 LeetCode题目练习(六) 6.Z字形变换

05-变量及标识符

11 - process control - for loop

wgs84坐标转换,地图拾取wgs84坐标工具推荐
随机推荐
基于51单片机和霍尔传感器的测速
Blue Bridge Cup 31 day sprint Day10
蓝桥杯嵌入式扩展板学习之DHT11
第85篇 LeetCode剑指Offer动态规划(二)青蛙跳台阶问题
Two ways of JS array value
03-pycharm
stm32单片机与LD3320语音模块交互法二
QT学习之安装QT
The postgraduate entrance examination is over
IDEA常用快捷键
C / S architecture
Subsets and problems (backtracking & branch and bound)
为CPropertySheet窗口添加最小化按钮
Blue Bridge Cup Sprint - DFS
meilisearch使用记录
第75篇 LeetCode题目练习(八) 8.字符串转整数
Summary of MySQL knowledge points
Golang learning and school recruitment experience
STM32学习笔记2——设置GPIO寄存器实现流水灯
本地搭建服务器后的访问问题