Solve the problem of entering an interrupt program immediately when the STM32 timer is turned on

Publisher:云淡风轻2014Latest update time:2018-12-10 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

When configuring the STM32 timer, the timer interrupt enable, timer enable, and clear update interrupt flag have different effects when the three programs are executed in different orders, as follows:


TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //Clear update interrupt request bit


    TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //Enable timer 1 update interrupt


TIM_Cmd(TIM1, ENABLE); //Start the timer


         (1) The update interrupt routine will not be entered immediately.


    TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //Clear update interrupt request bit


TIM_Cmd(TIM1, ENABLE); 


    TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //Enable timer 1 update interrupt


     (2) The update interrupt routine will not be entered immediately.

 

TIM_Cmd(TIM1, ENABLE);


   TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //Clear update interrupt request bit


  TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //Enable timer 1 update interrupt


   (3) The update interrupt procedure will not be entered immediately.



    TIM_Cmd(TIM1, ENABLE);


    TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //Enable timer 1 update interrupt


    TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //Clear update interrupt request bit


       (4) Immediately enter the update interrupt program.

 

     TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //Enable timer 1 update interrupt


   TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //Clear update interrupt request bit


TIM_Cmd(TIM1, ENABLE);  


  (5) . . . . . . Enter the update interrupt procedure immediately.

 

     TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE); //Enable timer 1 update interrupt


     TIM_Cmd(TIM1, ENABLE); 


     TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //Clear update interrupt request bit


  (6) . . . . . . Enter the update interrupt procedure immediately.


Reference: http://www.51hei.com/bbs/dpj-40940-1.html


         http://www.openedv.com/posts/list/41019.htm


Keywords:STM32 Reference address:Solve the problem of entering an interrupt program immediately when the STM32 timer is turned on

Previous article:[STM32] Basic principles of general timers (Example: timer interrupt)
Next article:stm32 timer response time calculation

Recommended ReadingLatest update time:2024-11-23 19:17

STM32 study notes_TIME timer detailed explanation 1
The timer of the STM32 microcontroller is indeed very powerful. It occupies more than 100 pages in the reference manual, which is more than 1/4 of the reference manual. The timers of STM32 are divided into several categories, and each category has different functions. There are: 1. Advanced timer 2. General timer 3
[Microcontroller]
STM32 study notes_TIME timer detailed explanation 1
About the implementation of AD sampling using Stm32 timer + ADC + DMA
Note: This STM32 microcontroller is the STM32F103 series. The ADC of Stm32 has DMA function. This is beyond doubt and is what we use most! However, if we want to sample a signal (such as a pulse signal) at a fixed time (that is, after a period of time, such as 2ms), there are three methods: 1. Use the timer interrupt
[Microcontroller]
Calculation of the baud rate of STM32 CAN
The CAN in STM32 supports 2.0A, 2.0B, with FIFO, interrupt, etc. Here we mainly mention the internal clock application. bxCAN is connected to the APB1 bus and uses the bus clock, so we need to know what the APB1 bus clock is. Let's take a look at the following figure to see the APB1 bus clock: The APB1 clock is t
[Microcontroller]
Calculation of the baud rate of STM32 CAN
STM32 timer dead zone setting at different main frequencies
According to the following instructions in the datasheet, the corresponding relationship between DTG assignment and specific dead time under various main frequencies is calculated for reference.   At 168M timer clock: DTS=1/168M=5.95238ns.  So the first formula, the dead time can be adjusted from 0 to 127*5.95=7
[Microcontroller]
STM32:STM32 learning record 6: IWDG
Configuration process: 1: System clock initialization, including the system clock and the clock configuration of the IO port or function to be opened. 2: IO port initialization, including pins, rates, input and output modes, etc. 3: Initialize the watchdog. Notice: Pay attention to how you feed your dog!!! #
[Microcontroller]
STM32 I/O as external interrupt input
 I/O port as external interrupt. general purpose input and output Each IO port of STM32 can be used as an interrupt input. To use an IO port as an external interrupt input, there are several steps: 1) Initialize the IO port as an input. This step sets the state of the IO port you want to use as an external interrupt i
[Microcontroller]
In-depth understanding of STM32 memory and bus architecture 1 (based on STM32F411)
This article is reproduced from http://blog.csdn.net/charmingsun/article/details/52258419 Official documentation:  STM32F411 Reference ManualSTM32F411   Data   SheetCortex™-M4F Programming ManualSTM32   Microcontroller System Memory Boot Mode Application NotesUSART   Protocol Used in STM32™ BootloaderARM   Cortex™-M
[Microcontroller]
LPC1788--TIMER match interrupt setting--register operation
Simple record of LPC1788 timer match interrupt settings - direct operation through registers #include "timer_lpc1788.h" #include "uart_lpc1788.h" void TIMER0_IRQHandler(void) //TIMER0 interrupt function {     if(((LPC_TIM0- IR) &(1 0))==(1 0)) //match interrupt occurs    {        UARTSendStr("CLOSrn");    }    LPC
[Microcontroller]
Latest Microcontroller Articles
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号