关于用JLINK通过ITM调试stm32单片机的问题
本帖最后由 H_JEN 于 2016-1-5 17:46 编辑做的一直都不成功,可以烧录,但是不能在线调试
下面是代码:
#include "stm32f10x.h"
#include "stdio.h"
#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)
{
if (DEMCR & TRCENA)
{
while (ITM_Port32(0) == 0);
ITM_Port8(0) = ch;
}
return ch;
}
int main(void)
{
printf("Hello World !");
for(;;);
}
有关的设置如下:
图1中红色框住的那个文件,是在网上看到的一篇关于“使用JLINK通过ITM调试stm32单片机”的文章中,作者说要加的一个文件,后缀是.ini,是一个配置文件来的
代码是:
/******************************************************************************/
/* STM32DBG.INI: STM32 Debugger Initialization File */
/******************************************************************************/
// <<< Use Configuration Wizard in Context Menu >>> //
/******************************************************************************/
/* This file is part of the uVision/ARM development tools. */
/* Copyright (c) 2005-2007 Keil Software. All rights reserved. */
/* This software may only be used under the terms of a valid, current, */
/* end user licence from KEIL for a compatible version of KEIL software */
/* development tools. Nothing else gives you the right to use this software.*/
/******************************************************************************/
FUNC void DebugSetup (void) {
// <h> Debug MCU Configuration
// <o1.0> DBG_SLEEP <i> Debug Sleep Mode
// <o1.1> DBG_STOP <i> Debug Stop Mode
// <o1.2> DBG_STANDBY <i> Debug Standby Mode
// <o1.5> TRACE_IOEN <i> Trace I/O Enable
// <o1.6..7> TRACE_MODE <i> Trace Mode
// <0=> Asynchronous
// <1=> Synchronous: TRACEDATA Size 1
// <2=> Synchronous: TRACEDATA Size 2
// <3=> Synchronous: TRACEDATA Size 4
// <o1.8> DBG_IWDG_STOP <i> Independant Watchdog Stopped when Core is halted
// <o1.9> DBG_WWDG_STOP <i> Window Watchdog Stopped when Core is halted
// <o1.10> DBG_TIM1_STOP <i> Timer 1 Stopped when Core is halted
// <o1.11> DBG_TIM2_STOP <i> Timer 2 Stopped when Core is halted
// <o1.12> DBG_TIM3_STOP <i> Timer 3 Stopped when Core is halted
// <o1.13> DBG_TIM4_STOP <i> Timer 4 Stopped when Core is halted
// <o1.14> DBG_CAN_STOP<i> CAN Stopped when Core is halted
// </h>
_WDWORD(0xE0042004, 0x00000027);// DBGMCU_CR
_WDWORD(0xE000ED08, 0x20000000); // Setup Vector Table Offset Register
}
DebugSetup(); // Debugger Setup
目的是让 DBGMCU_CR的 bit5 置一
这图是的Trace Cache Size的选项中只有这几个可以选,但是在网上看到别人的设置是2M
file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1225804498\QQ\WinTemp\RichOle\KMGNQ]}]YZ68Q3L}Q%Q%GC1.jpg
看了你说的那个帖子,也就是实现输出调试信息到Debug (printf)Viewer窗口,其他的没详细看,要实现找个功能可以参考我下面的帖子。
【STM32F303开发】+ 使用SWO输出调试信息到Debug Viewer窗口
creep 发表于 2016-1-5 18:21
看了你说的那个帖子,也就是实现输出调试信息到Debug (printf)Viewer窗口,其他的没详细看,要实现找个功 ...
你的帖子我也有看,也下载了你的程序来看,除了FLASH没设置之外,其他都跟你的差不多。但是还是不行...... creep 发表于 2016-1-5 18:21
看了你说的那个帖子,也就是实现输出调试信息到Debug (printf)Viewer窗口,其他的没详细看,要实现找个功 ...
而且我这边不能进行软件调试,进行软件调试的话就会弹出这两个框
H_JEN 发表于 2016-1-5 22:46
而且我这边不能进行软件调试,进行软件调试的话就会弹出这两个框
先把下载的问题解决吧,是不是下载模式不对或者不能检测到jlink。 我调429时也遇到类似问题,不过用的是板载的stlink creep 发表于 2016-1-5 23:33
先把下载的问题解决吧,是不是下载模式不对或者不能检测到jlink。
软件调试可以了,之前我忘记把Use Simulator这个软件调试的选项勾上,所以一直不行。但是硬件调试还是只可以烧录,在线调试可以进去,但是很快就退出来了.......不知道是不是电脑问题 :):):):):)顶一下 桌面请问一下这是这么回事,选不了SWD 请问一下这是这么回事,选不了SWD
页:
[1]