打印
[STM32F1]

STM32F103 SWD编程端口与普通IO口共用问题

[复制链接]
13741|30
手机看帖
扫描二维码
随时随地手机跟帖
楼主
基本上与楼上所说一样,下面为软件示例源代码
建议楼主一定要添加jtag保护功能函数。

/*!< 保护jtag口,当按下PB0时,停机 */
ProtectJtagIO();

/* 失能Jtag口 */
GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE);

/* Configure PA.13 (JTMS/SWDAT), PA.14 (JTCK/SWCLK) and PA.15 (JTDI) as
   output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

/* Configure PB.03 (JTDO) and PB.04 (JTRST) as output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
GPIO_Init(GPIOB, &GPIO_InitStructure);

使用特权

评论回复
评论
zhuomuniao110 2016-5-8 22:55 回复TA
必须点赞,太完美了。 
沙发
lemonboard| | 2016-2-5 22:55 | 显示全部楼层
yklstudent 发表于 2016-2-5 13:30
STM32F0下怎么禁止JTAG口

目前stm32f0主要以STcubeMX生成代码为主,在其配置单不选择swd调试即可。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则