湉湉 发表于 2016-4-9 11:07:06

STM32L073RZ_NUCLEO板子使用DEBUG printf(SWO)来调试 报错

本帖最后由 湉湉 于 2016-4-9 11:12 编辑

收到了STM32L073RZ_NUCLEO板子,想使用printf 通过SWO输出打印,参考的方法是
http://www.keil.com/support/man/docs/jlink/jlink_trace_itm_viewer.htm



Debug (printf) ViewerHome » µVision Windows » Debug (printf) Viewer The Debug (printf) Viewer window displays data streams that are transmitted sequentially through the ITM Stimulus Port 0. Enable ITM Stimulus Port 0.
http://www.keil.com/support/man/docs/jlink/jlink_debug_viewer.png
To use the Debug (printf) Viewer for tracing:

[*]Add ITM Port register definitions to your source code.   #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
[*]Add an fputc function to your source code that writes tothe ITM Port 0 register. The fputc function enables   printf to output messages.   struct __FILE { int handle; /* Add whatever you need here */ };FILE __stdout;FILE __stdin;int fputc(int ch, FILE *f) {if (DEMCR & TRCENA) {    while (ITM_Port32(0) == 0);    ITM_Port8(0) = ch;}return(ch);}
[*]Add your debugging trace messages to your source code using     printf.   printf("AD value = 0x%04X\r\n", AD_value);
[*]Set the ITM Port 0 to capture the information. Clear the   Port 7..0 privilege bit to access ITM Port 0 from User mode.   http://www.keil.com/support/man/docs/jlink/jlink_debug_view2.png

[*]Open the View - Serial Windows - Debug (printf) Viewerwindow.

[*]

湉湉 发表于 2016-4-9 11:14:54

请问下 各位高手是否有遇到类似的情况

yklstudent-1794 发表于 2016-4-9 21:17:59

F0 L0系列的没有SWO引脚,所以估计不支持

z00 发表于 2016-4-12 22:07:18

可以尝试一下降低Core Clock

STM3240G-EVAL评估板提示"Trace HW not present"的解决方法

湉湉 发表于 2016-4-16 21:09:41

yklstudent-1794 发表于 2016-4-9 21:17
F0 L0系列的没有SWO引脚,所以估计不支持

看了下 L073的芯片datasheet 是没有发现此管脚,被原理图上的 PB3(SWO)给误导了下

湉湉 发表于 2016-4-16 21:10:18

z00 发表于 2016-4-12 22:07
可以尝试一下降低Core Clock

STM3240G-EVAL评估板提示"Trace HW not present"的解决方法 ...

3Q 以后在其他支出SWO的芯片上 在测试下
页: [1]
查看完整版本: STM32L073RZ_NUCLEO板子使用DEBUG printf(SWO)来调试 报错