General timer basic principle

Publisher:keiss2018Latest update time:2019-02-14 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. References

       "STM32F1 Development Guide - Library Function Version" - Chapter 13, 14, 15  

       "STM32 Chinese Reference Manual V10" - Chapter 14 General Timer


2. Overview of General Timer

      STM32 timer


  

      

Differences between three STM32 timers


 

      

·General timer function features description

        The general TIMx (TIM2, TIM3, TIM4 and TIM5) timer features of STM32 include:


        Located on the low-speed APB1 bus (APB1)


        16-bit up, down, up/down (center-aligned) counting modes with auto-reload counter (TIMx_CNT).


        16-bit programmable (can be modified in real time) prescaler (TIMx_PSC), the counter clock frequency division factor is any value between 1 and 65535.


         4 independent channels (TIMx_CH1~4), which can be used as:

               ① Input capture

               ② Output comparison

               ③PWM generation (edge ​​or center aligned mode)

               ④Single pulse mode output


        · Synchronous circuits that can use external signals (TIMx_ETR) to control timers and timer interconnections (one timer can be used to control another timer).


        Generate interrupts/DMA on the following events (6 independent IRQ/DMA request generators):

           ① Update: counter overflow/underflow, counter initialization (by software or internal/external trigger)

           ②Trigger event (counter start, stop, initialization or internal/external trigger counting)

           ③ Input capture

           ④ Output comparison

           ⑤Support incremental (orthogonal) encoder and Hall sensor circuits for positioning

           ⑥Trigger input as external clock or cycle-by-cycle current management


      The general-purpose timer of STM32 can be used to measure the pulse length of the input signal (input capture) or generate output waveforms (output comparison and PWM), etc.


      ·Using the timer prescaler and RCC clock controller prescaler, the pulse length and waveform period can be adjusted from a few microseconds to a few milliseconds. Each general-purpose timer of STM32 is completely independent and does not share any resources with each other.  


      Counter mode

         The general timer can count up, count down, and count in both up and down bidirectional modes.

         ① Up counting mode: The counter starts counting down from the automatically loaded value (TIMx_ARR) to 0, then starts counting again from 0 and generates a counter overflow event.

         ② Down counting mode: The counter starts counting down from the automatically loaded value (TIMx_ARR) to 0, then restarts from the automatically loaded value and generates a counter underflow event.

         ③ Center-aligned mode (up/down counting): The counter starts counting from 0 to the automatically loaded value -1, generates a counter overflow event, then counts down to 1 and generates a counter

             Overflow event; then restart the count from 0.


     


      ·General timer working process

       


      Count clock selection



      Time base unit



      Update events


   


      ·Capture comparison array introduction


 


      Input capture mode


 


      PWM mode


 


Reference address:General timer basic principle

Previous article:STM32 timer interrupt experiment-TIM3
Next article:STM32 clock system review

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号