The JTAG port of the stm32f103 series chip is used as a normal IO

Publisher:sky0001Latest update time:2017-10-02 Source: eefocusKeywords:stm32f103 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The chip used is stm32f103c8t6.

Today, when debugging the board, I found that the LED light on the PA15 port only has an intermediate level of 2.3V regardless of whether the output is high or low. Later, Baidu said that this port (PA15--JTDI) is used as a JTAG debugging port by default and needs to be configured as a normal IO port. So I wrote two sentences according to that person's method: RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);

It would have been fine if I hadn't written it, but after writing it, even the SWD port that was originally used to download and debug programs could not be used... Later, I found the correct way to write it in the STM32 library: RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); This means not to use JTAG but to keep SWD. Neither the previous JTAG nor SWD will be kept.

The problem has been discovered, but what can I do? Now even SWD cannot be used... I used the serial port to download, but I was dumbfounded when I saw the board (I drew it myself), BOOT1 was floating, and BOOT0 was grounded... There was no way to connect the jumpers, so I grounded BOOT1, and pulled BOOT0 up to 3V3 through 4K7, and then used the MCUISP serial port to download (those who have used the Wildfire development board should know). The software first erased the chip and then wrote a new HEX file (the new HEX file is the second code above, only SWD is retained).

The download is successful, then pull up BOOT0 (it doesn’t matter if BOOT1 is still grounded, it is very clear in the data sheet), and after connecting to ST-LINK, SWD mode can download normally, and the PA15 port can also control the light normally.

From this we can see: 1. If the pin resources are not very tight, it is still better to pull the BOOT1 pin low; 2. In the first code above, the 5 IOs originally occupied by JTAG can be used as ordinary IO ports, but the program can only be downloaded through the serial port in the future.


  1. void LED_GPIO_INIT(void)  

  2. {  

  3.     GPIO_InitTypeDef GPIO_InitStructure;  

  4.       

  5.     RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE ); //PA clock enable  

  6.       

  7.     GPIO_InitStructure.GPIO_Pin = LED_PIN;  

  8.     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //PULL PUSH   

  9.     GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;  

  10.       

  11.     GPIO_Init( LED_PORT, &GPIO_InitStructure );  

  12.       

  13.     // for PA15 JTDI REMAP  

  14.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);  

  15. // GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE); // JTAG&SWD DISABLE  

  16.     GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); // JTAG DISABLE,SWD ENABLE  

  17.       

  18.     GPIO_ResetBits( LED_PORT, LED_PIN ); //TURN OFF LED  

  19. }  


Keywords:stm32f103 Reference address:The JTAG port of the stm32f103 series chip is used as a normal IO

Previous article:STM32 timer input capture points
Next article:Understanding of 8 GPIO modes of STM32

Recommended ReadingLatest update time:2024-11-23 10:54

Detailed explanation of STM32F103 series microcontroller timer
The STM32F103 series of microcontrollers has a total of 11 timers, including: 2 advanced timers 4 normal timers 2 basic timers 2 watchdog timers 1 system tick timer   8 timers are divided into 3 groups; TIM1 and TIM8 are advanced timers TIM2-TIM5 are general-purpose timers TIM6 and TIM7 are basic timers These 8 timers
[Microcontroller]
Introduction and points to note for Stm32f103rct6ADC voltage acquisition
The STM32f103 series has 3 ADCs with 12-bit accuracy, and each ADC has up to 16 external channels. ADC1 and ADC2 both have 16 external channels, and ADC3 has different channel numbers depending on the CPU pins, but generally has 8 external channels. The ADC has many modes and is very powerful. The ADC input range is:
[Microcontroller]
Introduction and points to note for Stm32f103rct6ADC voltage acquisition
Design of deep sea remote motor control system based on STM32F103
Deep-sea motor control system is a key technology in deep-sea operations such as deep-sea scientific investigation, geological exploration, biological resource collection, and deep-sea salvage. It is of great significance to make the motor run efficiently and reliably in the complex environment of the deep sea. At p
[Industrial Control]
Design of deep sea remote motor control system based on STM32F103
STM32F103 outputs multiple dead zone complementary PWM waves
Read count: 39 TIM1 and TIM8 can generate dead zone complementary PWM waves. After learning, I found that the timer function of stm32 is really powerful. A small summary is convenient for reference in the future. Stm32 timers are divided into three types: tim1 and tim8 are advanced timers, 6 and 7 are basic timers,
[Microcontroller]
Bootloader software security design solution for STM32F103RB
introduction With the development of embedded system products, their functions tend to be systematic and complex, and different occasions and specific applications have put forward more requirements for product upgrade and maintenance. Manufacturers generally adopt Bootloader to guide the embedded software
[Microcontroller]
STM32F103ZET6 — EXTI
STM32F103ZET6 supports 20 external interrupt inputs (EXIT0~EXIT19), of which there are 4: EXTI line 16 is connected to the PVD output EXTI line 17 is connected to the RTC alarm event EXTI line 18 is connected to the USB wake-up event EXTI line 19 is connected to Ethernet wake-up event (only for interconnection prod
[Microcontroller]
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号