STM32 turns off JTAG and uses the corresponding GPIO port to record simply

Publisher:郑大大Latest update time:2017-11-28 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

STM32's PA13-PA14-PA15-PB3-PB4-PB5 are mainly used for JTAG debugging, so by default they are in JTAG mode after startup. However, when JTAG is not needed and the GPIO port needs to be fully utilized, JTAG needs to be turned off and set to GPIO mode.


GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); //Turn on the PA clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); //Turn on the PB clock


RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); //Turn on multiplexed clock----important

GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE); //Disable all SWJ----important

GPIO_InitStructure.GPIO_Pin =GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin =GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);

Then you can use it directly as a GPIO port --- high and low level settings ---

GPIO_SetBits(GPIOA,GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);        
GPIO_ResetBits(GPIOB,GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5);


Keywords:STM32 Reference address:STM32 turns off JTAG and uses the corresponding GPIO port to record simply

Previous article:LPC1788---Serial port settings
Next article:Simple understanding of STC15F204 analog serial port routines

Recommended ReadingLatest update time:2024-11-17 08:50

STM32 TIM1 output pulse example
TIM module timer overflow & output comparison First of all, we must affirm the strength of ST company and admit that STM32 is indeed a very good Cortex-M3 core microcontroller. However, its manual is really incomprehensible, especially the TIM module, which is disorganized. After reading it for two days, I still don’t
[Microcontroller]
STM32 bootloader IAP programming
First, let's talk about the differences and connections between ISP and IAP of stm32. ISP (In-System Programming) means that blank devices on the circuit board can be programmed with end-user code without removing the device from the circuit board. Programmed devices can also be erased or reprogrammed using ISP. IAP (
[Microcontroller]
The simplest implementation of BootLoader in stm32
In mature products, the BootLoader method is usually used to upgrade the product program. That is, IAP upgrade. After understanding the basic implementation principles, you can use the host computer to upgrade (most general products use this method, which seems very professional and has dedicated upgrade software. In
[Microcontroller]
STM32 I2C Difficulties
I2C bus is widely used in all embedded systems and is an industrial-grade bus. However, since STM32 is a 32-bit MCU, its I2C hardware interface is destined to be powerful, but also difficult to control, unlike 8-bit machines, such as AVR8-bit machine's TWI (which actually fully complies with the I2C standard). The fol
[Microcontroller]
STM32 I2C Difficulties
stm32 assembly lighting program
;RCC register address image             RCC_BASE EQU 0x40021000 RCC_CR EQU (RCC_BASE + 0x00) RCC_CFGR EQU (RCC_BASE + 0x04) RCC_CIR EQU (RCC_BASE + 0x08) RCC_APB2RSTR EQU (RCC_BASE + 0x0C) RCC_APB1RSTR EQU (RCC_BASE + 0x10) RCC_AHBENR EQU (RCC_BASE + 0x14) RCC_APB2ENR EQU (RCC_BASE + 0x18) RCC_APB1ENR EQU (RCC_BASE +
[Microcontroller]
STM32 peripheral driver - DHT11 temperature and humidity sensor
This example has been tested on STM32. This example uses the PC0 pin to connect the data pin of DHT11. Just call the DTH11_test function in the following code in the main function. //Data definition:       //----The following variables are all global variables--------       //----High 8 bits of temperature == U8T
[Microcontroller]
STM32 Notes: Using SysTick to measure program running time
This experiment is used to measure the running time of the delay function (as shown below) void Delay(__IO u32 nCount)   { for(; nCount != 0; nCount--); }  //SysTick.c #include "SysTick.h"   __IO u32 TimingDelay = 0;   void SysTick_Init(void) { /* SystemFrequency / 1000 1ms interrupt once * SystemFrequency / 1
[Microcontroller]
[STM32] Incompatibility and solutions when opening MDK4 project with MDK5
Problem Description I recently found a problem when using MDK5. Let's take a look at the existing MDK version information: When opening an MDK4 version project with MDK5, a window "Using an MDK Version 4 Project" will usually pop up: This is an MDK version 4 project ,require Device support for Cortex-M based de
[Microcontroller]
[STM32] Incompatibility and solutions when opening MDK4 project with MDK5
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号