Recently, when I was writing a program, I found that there was a problem with setting the external interrupt. Why did the previous program not work? After a night of tossing and turning, I found that the problem was in the configuration of the AFIO clock. I did not enable the AFIO clock.
When should AFIO be enabled? Reference Manual:
It is very clear that the three types of registers of AFIO need to be turned on when operating:
1. Event control register (AFIO_EVCR)
2. Multiplexing remapping and debugging I/O configuration register (AFIO_MAPR)
3. External interrupt configuration register x (AFIO_EXTICRx)
These three types are actually all the registers of AFIO, AFIO_EVCR is related to events, AFIO_MAPR is related to remapping and debugging I/O, and AFIO_EXTICRx is related to external interrupts. Therefore, AFIO needs to be turned on when remapping and debugging I/O configuration, external interrupts, and events.
Looking back at the previous program, you can understand it. In the previous program, there are two lines of code in the initialization area of my main function:
RCC->APB2ENR |= 0x00000001; //Disable JTAG, enable SWD
AFIO->MAPR = (0x00FFFFFF & AFIO->MAPR)|0x02000000;
This code configures the JTAG and SWD pins, and also configures the AFIO clock. So the function can be realized without operating AFIO in the subsequent external interrupt configuration code. Finally, I added this sentence to the program, and the problem was solved perfectly. RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
Previous article:When does the STM32 AFIO clock start?
Next article:STM32 commonly used pins redefine peripherals
Recommended ReadingLatest update time:2024-11-16 20:37
- 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
- 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!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The stm32f103c8t6 core board is powered by two USB cables, and the program cannot start automatically
- [NUCLEO-F746ZG Learning] Construction Project-Based on RT-Thread
- I need help from a master who can use ADS software to make filters
- [Technical Tips] GigaDevice GD32VF103C-START Getting Started
- Beijing Excellence Communication is recruiting embedded developers with high salary!!!
- How to assign initial values to a continuous RAM range in C2000 chip
- TMS570 Learning 3-Internal Flash Programming
- First post by a newbie
- What is 4G DTU and what are its specific functions?
- CadenceLIVE China 2022 China Online User Conference invites you to attend