PB3, PB4, PA13, PA14, PA15 are used as special configurations of common IO ports

Publisher:PeacefulSoulLatest update time:2018-09-09 Source: eefocusKeywords:STM32F1 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Recently, a blogger made a temperature measurement and control module using STM32F103C8T6, using PB3, PB4, PA15 and other pins to control peripherals. It was found that no matter how to configure, these three pins cannot be set to zero. Later, it was discovered that PB3, PB4, PA13, PA14, and PA15, including these three pins, are special IO ports used as debug interfaces for JTAG/SWD emulators. Among them, PA13 and PA14 are used as SWIO and SWCLK for SWD debugging respectively; PB3, PB4, PA13, PA14, and PA15 are used together for JTAG. The Chinese and English descriptions of these five pins are shown in the figure below, which is from the STM32F1 reference manual:


These five IO pins are very special. Normally, they are used as debug pins for the SWJ emulator. If they are to be used as normal IO ports, special configuration is required. Take the PA13 pin as an example. The description of this pin in the STM32F1 data sheet is as follows:


Compared with other common IO, the main function of PA13 is JTMS-SWDIO. On the contrary, the function of common IO port is in remap in Alternate functions. In other words, if PA13 is to be used as a common IO port, it must use the remap in its alternate function. Therefore, the following two steps are required:

1. Enable the multiplexed clock in the clock configuration: RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO,ENABLE);

2. Remap the PA13 pin: GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); 

Step 1 is relatively easy to understand, so here we will focus on the remapping operation of step 2. The Chinese and English descriptions of the remapping operation of the five SWJ pins in the STM32F1 reference manual are shown in the figure below:

As can be seen from the above figure, there are three ways of remapping. They are described as follows:

1.GPIO_Remap_SWJ_JTAGDisable: /*!< JTAG-DP Disabled and SW-DP Enabled */ That is, PB3, PB4, PA15 can be used as normal IO, and PA13&14 can be used for SWD debugging

2.GPIO_Remap_SWJ_Disable: /*!< Full SWJ Disabled (JTAG-DP + SW-DP) */ All 5 pins are normal pins, but can no longer be debugged with JTAG&SWD emulator, only st-link can be used for debugging 

3.GPIO_Remap_SWJ_NoJTRST: /*!< Full SWJ Enabled (JTAG-DP + SW-DP) but without JTRST */PB4 can be a normal IO port, JTAG & SWD are used normally, but JTAG is not reset

If you use all five pins as normal IO ports, the remapping configuration in the above step 2 should be written as GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable, ENABLE); If you use PB3, PB4, PA15 as normal IO, and PA13&14 for SWD debugging, the remapping configuration should be written as GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); Similarly, you can configure only PB4 as a normal IO port.


Keywords:STM32F1 Reference address:PB3, PB4, PA13, PA14, PA15 are used as special configurations of common IO ports

Previous article:STM32 uses PB3 and other IO as normal IO
Next article:STM32 MCU releases PB3/PB4/PA15 as common IO port

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号