STM32F0xx_EXIT interrupt configuration detailed process

Publisher:PeacefulAuraLatest update time:2017-09-15 Source: eefocusKeywords:STM32F0xx_  EXIT Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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;

Notice:

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.


Keywords:STM32F0xx_  EXIT Reference address:STM32F0xx_EXIT interrupt configuration detailed process

Previous article:STM32_EXIT interrupt
Next article:STM32_BKP backup data

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号