你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

关于用JLINK通过ITM调试stm32单片机的问题

[复制链接]
H_JEN 提问时间:2016-1-5 17:42 /
本帖最后由 H_JEN 于 2016-1-5 17:46 编辑

   做的一直都不成功,可以烧录,但是不能在线调试
   下面是代码:
  1. #include "stm32f10x.h"
  2. #include "stdio.h"

  3. #define ITM_Port8(n)    (*((volatile unsigned char *)(0xE0000000+4*n)))
  4. #define ITM_Port16(n)   (*((volatile unsigned short*)(0xE0000000+4*n)))
  5. #define ITM_Port32(n)   (*((volatile unsigned long *)(0xE0000000+4*n)))
  6. #define DEMCR           (*((volatile unsigned long *)(0xE000EDFC)))        
  7. #define TRCENA          0x01000000

  8. struct __FILE { int handle; /* Add whatever you need here */ };
  9. FILE __stdout;
  10. FILE __stdin;

  11. int fputc(int ch, FILE *f)
  12. {
  13.     if (DEMCR & TRCENA)
  14.     {
  15.         while (ITM_Port32(0) == 0);
  16.         ITM_Port8(0) = ch;
  17.     }
  18.     return ch;
  19. }

  20. int main(void)
  21. {
  22.         printf("Hello World !");
  23.         for(;;);
  24. }
复制代码
有关的设置如下:
5.jpg
图1中红色框住的那个文件,是在网上看到的一篇关于“使用JLINK通过ITM调试stm32单片机”的文章中,作者说要加的一个文件,后缀是.ini,是一个配置文件来的
代码是:
  1. /******************************************************************************/
  2. /* STM32DBG.INI: STM32 Debugger Initialization File                           */
  3. /******************************************************************************/
  4. // <<< Use Configuration Wizard in Context Menu >>>                           //
  5. /******************************************************************************/
  6. /* This file is part of the uVision/ARM development tools.                    */
  7. /* Copyright (c) 2005-2007 Keil Software. All rights reserved.                */
  8. /* This software may only be used under the terms of a valid, current,        */
  9. /* end user licence from KEIL for a compatible version of KEIL software       */
  10. /* development tools. Nothing else gives you the right to use this software.  */
  11. /******************************************************************************/


  12. FUNC void DebugSetup (void) {
  13. // <h> Debug MCU Configuration
  14. //   <o1.0>    DBG_SLEEP     <i> Debug Sleep Mode
  15. //   <o1.1>    DBG_STOP      <i> Debug Stop Mode
  16. //   <o1.2>    DBG_STANDBY   <i> Debug Standby Mode
  17. //   <o1.5>    TRACE_IOEN    <i> Trace I/O Enable
  18. //   <o1.6..7> TRACE_MODE    <i> Trace Mode
  19. //             <0=> Asynchronous
  20. //             <1=> Synchronous: TRACEDATA Size 1
  21. //             <2=> Synchronous: TRACEDATA Size 2
  22. //             <3=> Synchronous: TRACEDATA Size 4
  23. //   <o1.8>    DBG_IWDG_STOP <i> Independant Watchdog Stopped when Core is halted
  24. //   <o1.9>    DBG_WWDG_STOP <i> Window Watchdog Stopped when Core is halted
  25. //   <o1.10>   DBG_TIM1_STOP <i> Timer 1 Stopped when Core is halted
  26. //   <o1.11>   DBG_TIM2_STOP <i> Timer 2 Stopped when Core is halted
  27. //   <o1.12>   DBG_TIM3_STOP <i> Timer 3 Stopped when Core is halted
  28. //   <o1.13>   DBG_TIM4_STOP <i> Timer 4 Stopped when Core is halted
  29. //   <o1.14>   DBG_CAN_STOP  <i> CAN Stopped when Core is halted
  30. // </h>
  31. _WDWORD(0xE0042004, 0x00000027);  // DBGMCU_CR
  32. _WDWORD(0xE000ED08, 0x20000000);   // Setup Vector Table Offset Register
  33. }

  34. DebugSetup();                       // Debugger Setup
复制代码
目的是让 DBGMCU_CR的 bit5 置一

图2

图2


图3

图3


图4

图4

这图是的Trace Cache Size的选项中只有这几个可以选,但是在网上看到别人的设置是2M



file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1225804498\QQ\WinTemp\RichOle\KMGNQ]}]YZ68Q3L}Q%Q%GC1.jpg


收藏 1 评论9 发布时间:2016-1-5 17:42

举报

9个回答
creep 回答时间:2016-1-5 18:21:06
看了你说的那个帖子,也就是实现输出调试信息到Debug (printf)Viewer窗口,其他的没详细看,要实现找个功能可以参考我下面的帖子。
【STM32F303开发】+ 使用SWO输出调试信息到Debug Viewer窗口


H_JEN 回答时间:2016-1-5 22:35:43
creep 发表于 2016-1-5 18:21
看了你说的那个帖子,也就是实现输出调试信息到Debug (printf)Viewer窗口,其他的没详细看,要实现找个功 ...

你的帖子我也有看,也下载了你的程序来看,除了FLASH没设置之外,其他都跟你的差不多。但是还是不行......
H_JEN 回答时间:2016-1-5 22:46:03
creep 发表于 2016-1-5 18:21
看了你说的那个帖子,也就是实现输出调试信息到Debug (printf)Viewer窗口,其他的没详细看,要实现找个功 ...

而且我这边不能进行软件调试,进行软件调试的话就会弹出这两个框 6.png
7.png
creep 回答时间:2016-1-5 23:33:20
H_JEN 发表于 2016-1-5 22:46
而且我这边不能进行软件调试,进行软件调试的话就会弹出这两个框

先把下载的问题解决吧,是不是下载模式不对或者不能检测到jlink。
stary666 回答时间:2016-1-6 14:47:05
我调429时也遇到类似问题,不过用的是板载的stlink
H_JEN 回答时间:2016-1-7 21:47:16
creep 发表于 2016-1-5 23:33
先把下载的问题解决吧,是不是下载模式不对或者不能检测到jlink。

软件调试可以了,之前我忘记把Use Simulator这个软件调试的选项勾上,所以一直不行。但是硬件调试还是只可以烧录,在线调试可以进去,但是很快就退出来了.......不知道是不是电脑问题
zhangdaijin 回答时间:2016-1-8 08:49:30
顶一下
张sama 回答时间:2017-5-28 22:34:36
请问一下这是这么回事,选不了SWD
张sama 回答时间:2017-5-28 22:38:09
请问一下这是这么回事,选不了SWD
QQ图片20170528221730.png

所属标签

相似问题

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
微信公众号二维码 微信公众号
手机版二维码 手机版