Problems with STM32's JTAG, SWD and serial port downloading

Publisher:翩翩轻舞Latest update time:2016-07-30 Source: eefocusKeywords:STM32  JTAG  SWD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Recently, a project used STM32. In order to make PCB wiring more convenient, some pins were changed, which occupied PA15 and PB3 of the JTAG interface, so JTAG had to be disabled and the download was in SWD mode. In this way, some conclusions were made in actual operation (the methods are available on the Internet, and here is just a summary):

 

1: GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);

   Change the mapping of the specified pin GPIO_Remap_SWJ_Disable SWJ completely disabled (JTAG+SW-DP)

 

2: GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);

   Change the mapping of the specified pin GPIO_Remap_SWJ_JTAGDisable, JTAG-DP disable + SW-DP enable

 

Select the mode you want here. I only use SWD without JTAG.

 

1
2
3
4
5
6
7
8
9
10
11
12
void GPIOint(void)
{
GPIO_InitTypeDef GPIO_InitStructure;     
 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
  GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA , ENABLE);
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
  GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);  
}

 

STM32 cannot perform JTAG simulation after disabling the JTAG function in the program.

If you accidentally use only JTAG and cannot download the program, you can solve it by the following method:

 

1. Set the boot mode to ISP mode (BOOT0=1, BOOT1=0) or set the boot mode to RAM operation mode (BOOT0=1, BOOT1=1).

   Re-power the board. Since it is not in user program mode, the statement to disable JTAG will not be executed and the JTAG function can be used normally.

 

2. Set the boot mode to ISP mode (BOOT0=1, BOOT1=0), use the ISP program to erase the STM32 FLASH, and then you can restore the JTAG function.

   The software Flash_Loader_Demonstrator for serial port download is available on the official website. Note that serial port download can only use USART1, which is the group of PA9 and PA10 pins.

 

3. If your emulator supports SWD emulation mode, such as JLINK in IAR and ULINK2 in MDK.

   Simply set the emulator mode to SWD mode to avoid being affected by disabling the JTAG function.

Keywords:STM32  JTAG  SWD Reference address:Problems with STM32's JTAG, SWD and serial port downloading

Previous article:STM32 TIM remapping
Next article:STM32F407 external SRAM

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号