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);
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- New breakthrough! Ultra-fast memory accelerates Intel Xeon 6-core processors
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Consolidating vRAN sites onto a single server helps operators reduce total cost of ownership
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Some methods to make mobile power pass EMI test
- How to lock the state machine diagram in IAR Visualstate to prevent modification
- My Journey of MCU Development (VIII)
- The microcontroller has its own PWM to control the brightness of the LED light. How to write it? ?
- My head hit a horn, it hurts so much
- 【MM32 eMiniBoard Review】+ Internal temperature detection and display
- List of common safety requirements for switching power supplies
- The BLUERNG-1 CODE is too large to implement OTA
- Is embedded software development easy to learn?
- Is there any Camera expert who can help explain the meaning of the tests in the log?