I. Overview
EXIT external interrupts are common in applications such as key or switch control, and low-power interrupt wakeup is also a common one. Therefore, EXIT is also a common one in actual project development.
The external interrupt EXIT in STM32F0 belongs to the chapter on interrupts and events. Please see Chapter 12 of the reference manual, but it needs to be operated in conjunction with the system configuration controller to allocate pins for interrupts. For details, please see Chapter 10 of the reference manual.
Ⅱ. Download
The "software engineering" provided in the article has been tested many times on the hardware board and uploaded to the 360 cloud disk only after it is guaranteed to be problem-free. Please feel free to download and test it. If there is any problem, please check whether there is any problem with your board.
ST standard peripheral libraries, reference manuals, data sheets, etc. can all be downloaded from the ST official website , or you can download them from my 360 cloud disk. There are multiple versions of the reference manual for the F0 series chips (for different F0 chips), but there is a universal version, "STM32F0x128 Reference Manual V8 (English) 2015-07". It is recommended to refer to this manual, which will be convenient for you to understand if you change to a different chip model in the future.
Today's software engineering download address (360 cloud disk):
https://yunpan.cn/cRJDddvF4hdXE Access password f0af
The information of STM32F0xx can be downloaded from my 360 cloud disk:
https://yunpan.cn/cS2PVuHn6X2Bj Access password 8c37
III. Preparation
For EXIT programming, it is recommended that you prepare Chapter 10 of the F0 reference manual and the data sheet for easy reference to relevant knowledge. If you don’t have it, please go to the ST official website or download it from my 360 cloud disk.
The software project summarized today is modified based on the "Detailed Process of TIM Basic Delay Configuration", so you need to download the software project and prepare it. I always provide the organized software project for everyone to download, but if you are a learner, it is recommended that you operate it step by step by yourself.
IV. Principle of External Interrupt
In fact, the principle of EXIT external pin interrupt is very simple. Configure the corresponding pin to input mode, see whether pull-up and pull-down resistors are needed according to the circuit, configure the pin as an interrupt line through SYSCFG, configure NVIC, and write interrupt handling.
V. Code Description
Please download the software project and view the source code, and understand each point of the summary in conjunction with the source code.
①RCC clock
This function is located above the bsp.c file;
I personally like to configure the clock first, and the routines provided by ST also put the configuration of the clock first. The configuration of the RCC clock is very important. There have been several times when I forgot to configure the corresponding RCC clock, which made me look for the problem for a long time, and finally found that the RCC clock was not configured.
Notice:
Do not add peripheral clocks casually, for example: RCC_APB1 peripherals should not be configured in RCC_APB2 clock [such as: RCC_APB2PeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); this can be compiled, but it is wrong]
I always remind people to use the RCC clock because many people have problems with software operation due to the clock. Therefore, I want to remind more people to pay attention to configuring RCC.
②EXIT configuration
This function is located under the bsp.c file;
This function divides EXIT into three parts: basic configuration of pins, external interrupt line configuration, and system controller configuration. Each step is required, otherwise the interrupt will not be responded.
③NVIC configuration
This function is located under the bsp.c file;
To respond to an interrupt, you need to assign it an interrupt priority level.
Notice:
The external interrupt channel entrance is not assigned one entrance for each interrupt. According to the manual and reference materials, it can be seen that the allocation is: EXTI0_1_IRQn, EXTI2_3_IRQn, EXTI4_15_IRQn; this means that external interrupts 0-1 have the same entrance, and the other principles are the same.
④Interrupt function
This function is located in the stm32f0xx_it.c file;
My operation here is relatively simple, one button press, one interrupt. Press the button, delay debounce, change the LED once, wait for the button to be released, and finally clear the interrupt flag.
Notice:
The red mark in the figure is the key point in actual application. If it is a large project and other people are involved, or some of the code in the project is from before the porting, it is very likely that other interrupts are enabled. If this judgment is not added here, the program may die in the interrupt.
VI. Description
Maybe your hardware chip is not the chip provided in the project, but the chip software compatibility of STM32F0 is very good, and it can be applied to many other types of F0 chips, even F2, F4 and other chips (please refer to the manual for details, or test it yourself).
The software project provided in this article is built based on the ST standard peripheral library, rather than using STM32CubeMX to build the project. I personally think that using ST's standard peripheral library is suitable for learners, and the STM32CubeMX project structure is complex, which is probably a headache for learners, especially beginners.
Today's project is modified based on the project "STM32F0xx_TIM basic delay configuration detailed process". The above example summary is for reference only. If there are any mistakes, please forgive me.
VII. Final
Follow us on WeChat and reply “more content” to get more content (such as UCOS instances, etc., constantly updated…).
If you like what I share and want to know more related content, please follow the WeChat public account at the beginning of the article. New content is continuously updated and there will be more exciting content in the future.
Previous article:STM32_EXIT interrupt
Next article:STM32_BKP backup data
- 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
- 【Child care machine】+ ESP32-S3-BOX+ESP32-S3-DevKitC-1 material unpacking and BOX basic demonstration
- [Free trial of Pingtouge Bluetooth Mesh Gateway Development Kit] + nRF Mesh and Light Experiment (Part 2)
- PCB learning
- Allwinner V853 development board Tina SDK LCD small resolution DCLK setting problem
- Unboxing
- How to choose resistors in circuit design?
- A time-delayed shutdown circuit
- Automotive 10V-80V Ultra-Wide Vin, 12V Vout Flyback Reference Design for 48V Car Battery
- Application of Single Pair Ethernet in Building Automation
- Small and exquisite open source Python learning board Mini SAM