The importance of Timer_ for MCU, timer

EDITORIAL

  I have written many articles about the timer before, but there are still a lot of friends backstage to ask questions related to the given period, so, here we recommend the following information on this timer.

 

  I believe some of my friends have received a number of messages STM32 public, and I think that provides a relatively good information: STM32 timer training materials and the basic principles of the common problems.

 

  This information is the first time I downloaded a look, I feel very good finishing. Especially for beginners as well as learning a lot STM32 friends for some time, there are very helpful role in all aspects of the master timer.

 

  Taking into account many of my friends just know that there is such a material, there is no download to learn and master. So, here today to pick some points, lead the study.

 

  Download the ST Chinese network, (recently) to enter the home, you can see this message on the home page.

https://www.stmcu.com.cn/Designresource/design_resource_detail?file_name=STM32+%E5%AE%9A%E6%97%B6%E5%99%A8%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86%E5%8F%8A%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E4%B9%8B%E5%9F%B9%E8%AE%AD%E8%B5%84%E6%96%99&lang=EN&ver=3.1

 

This information is a total of 186. More content, but covered well.

 

 

 

 

2, the main content of the information

  • STM32 timer overview

  • Timer time base unit

  • Timer input capture function

  • Timer output compare function

  • Timer trigger synchronized with the cascade

  • Timer DMA bulk transfer

  • trigger outputs associated with other peripherals generated by the timer

  • STM32F334 / STM32F7 / STM32L4 new timer function, etc.

  • Case Studies interspersed in the above [in]

 

 

3, STM32 timer classification

  Overall speaking, many STM32 family timer, according to the nucleus, nucleus outside the standard roughly divided into two parts: 

  Nuclear Peripherals Timer timer +

  • nucleus Timer: Systick

  • Peripherals Timer: Timer + conventional application-specific timer

  • application-specific timer: LPTIM; RTC; WTD; HRTIM

  • General timer: basic timers, general-purpose timer, advanced timer [this introduction emphasis]

 

  Bit width by counter points:

  • 16-bit timer

  • 32-bit timer] [TIM2 TIM5

  • 24-bit timer] [Systick

 

  General Timer

  1 Basic Timer: almost no outside input / output, often used as a time base, basic counting, timing function.

 

  2. General timer: In addition to the basic functions of the timebase timer, also outside as input capture, output compare and the other connected to a sensor interface and a Hall sensor encoder [].

 

  3. Advanced Timer: this type of timer the most powerful, general-purpose timers addition to function, but also contains some associated with motor control and digital power applications function, for example, with dead-time control of the complementary output signal, emergency brake shutdown control input.

 

 

4, STM32 timer module

640?wx_fmt=png

STM32 [GM] or Advanced Timer roughly divided into six functional units:

  • the control unit from the mode: the source is responsible for the clock, the trigger signal source selection; start and stop the counter is reset and access control;

  • When the base unit: Timer core unit. Responsible for the clock source frequency, count, overflow reload the like.

  • input means: part of the clock signal, the capture signal, the trigger signal supply source.

  • comparing the output unit: By comparing the value of the counter matches the compare register achieve different output waveform.

  • trigger output unit: Output trigger signal to the timer or other peripherals.

  • Capture Compare Unit: input capture or output compare unit public execution.

 

From the perspective of a general understanding of the signal chain STM32 timer:

640?wx_fmt=png

 

STM32 timer There are several basic signal: the input signal, a clock signal, a trigger input signal, the trigger output signal, interrelated therebetween to form the corresponding signal chain, which have shown various functions of the timer.

 

 

5, STM32 timer function summary

(1) six functional unit

  [Time base, from the control mode, comparing the input, output, capture trigger output]

 

(2) four signal

  【时钟信号、外部输入信号、触发输入信号、触发输出信号】

 

(3) 四类事件

  【更新事件、捕捉、 比较事件、触发事件】

 

(4)一大特性

  【影子寄存器的预装载特性】

 

这上面的一些内容掌握了,对定时器基本就没多大问题了,资料中也有详细说明。

 

6、案例:定时器一使能就进中断的问题

问题描述: TIMER初始化阶段, 经常有人反馈一使能更新中断就就进中断服务程序?给开发带来些困扰,原因可能是什么?如何解决?

 

因为在定时器的初始化代码里有软件更新操作触发了更新事件,并置位了更新中断标志,当使能更新中断时就立刻进入更新中断服务程序。

 

在STM32标准库里的TIM_TimeBaseInit( )函数里都有这句代码:

TIMx->EGR = TIM_PSCReloadMode_Immediate;

 

 

• 在Cube库里的HAL_TIM_Base_Init( )函数里的 函数有这句代码:

TIMx->EGR = TIM_EGR_UG;

 

 

显然,这两行代码使用到了前面提到的软件更新操作,触发了更新事件,置位更新中断标志。所以我们在使能定时器更新中断之前,可以先做更新中断标志的清除操作。

 

说明:资料中提供了很多案例说明,以及分析,我觉得比较好,方便大家理解。请多理解一下这些案例。

 

 

7、时钟源问题思考

  1、几种时钟源?来自何处?

  2、来自TI1fp1与TIF_ED信号差别是什么?

  3、来自TI1/TI2的时钟是否可以直接像内部时钟一样被计数器用来计数?

  4、根据时钟源的介绍,你了解到了几种触发输入信号?

  5、TI3FP4可以作为通道2的输入捕捉信号吗?

  6、TI4FP4可以作为触发信号吗?

 

好了,篇幅有限,就写到这里。这个资料的内容我基本都看了一遍,可以结合《参考手册》一起学习,有部分内容来自《参考手册》。

希望还不知道,却又想学习并深入理解定时器的朋友尽快下载来看看。

 

文章作者:嵌入式资讯精选

Text Transfer: https://blog.csdn.net/dp29sym41zygndvf/article/details/85815086

Guess you like

Origin www.cnblogs.com/iriczhao/p/11803256.html