Hello! Welcome to Embedic!
This website uses cookies. By using this site, you consent to the use of cookies. For more information, please take a look at our Privacy Policy.
Home > Embedded Events > The timer function of MCU

The timer function of MCU

Date: 24-09-2022 ClickCount: 281

MCU is equivalent to a microcontroller, and the biggest feature compared to other chips is its programmable feature. Because of its programmable feature can be widely used in all aspects of life, such as cell phones, PC peripherals, remote controls, automobiles, electronics, smart homes, etc. But these are all achieved using MCU microcontrollers with different circuits.

 

The basic functions of an MCU microcontroller include TImer, IO port, external interrupt, communication interface, A/D conversion, PWM function, etc. Among them, the Timer function is the most basic function of MCU microcontroller, and the Timer function makes how to achieve it.

 

The timer is composed of two registers, one of which is used to determine the working form and function of the counter, the other Timer is used to control the start and stop of the microcontroller, and it is also a flag to set the overflow.

Although there are more types of TImer, they can be grouped into two main categories.

One type is the fixed interval TImer: that is, its timing time is set by the system, which the user program can not control; the system only provides several fixed time intervals for the user program to choose, such as 32Hz, 16Hz, 8Hz, etc. This type of TImer is more common in 4-bit MCU, so it can be used to achieve the clock, timing and other related functions.

 

Fixed time interval TImer has many applications in controlling industrial and household electrical equipment. For example, a single-chip microcontroller can be used to implement a building light switch with a button, which is automatically extinguished after the button is pressed once and the light is on for 3 minutes; when the button is pressed twice in a row, the light is always on and does not go out, and when the button is pressed for more than 2s, the light goes out.

Another category is the programmable Timer (Programmable Timer); as the name suggests, the timing time of this type of Timer can be controlled by the user's program. The control method includes the selection of the clock source, the frequency division (Prescale) selection, the setting of the number of pre-set, etc. Some MCUs have all three simultaneously, while some may be one or two of them. The application of such a Timer is very flexible, and the actual use is also very varied. Since the clock source can be freely selected, such a Timer is usually combined with an Event Counter (event counter).

 

MCU counting process

When the counter reaches full 1 (i.e. FFFFH), another pulse is input to return the counter to zero, and the overflow of the counter causes TF0 or TF1 in TCON to be set to 1, which sends an interrupt request to the CPU (when the timer/counter interrupt is allowed). If the timer/counter is working in timing mode, the timing time is up; if it is working in counting mode, it means the count value is full.

 

Digital integrated circuits can also implement timing circuits, programmable logic devices (PLDs) can implement timing circuits, and programmable logic controllers (PLCs) can implement timing circuits. Still, only microcontrollers are the simplest to implement and the lowest cost. Therefore, using a microcontroller timer is very important; mastering the logic plus time control programming is the basis for learning to use a microcontroller.

  • Is the next step for RISC-V a data center or a cell phone SoC?
  • [2022] Hardware-Based SOC Monitoring (Real Time) Solutions to CAVs

Hot Products

  • MSP430F1232IDWR

    Manufacturer: Texas Instruments

    IC MCU 16BIT 8KB FLASH 28SOIC

    Product Categories: 16bit MCU

    Lifecycle:

    RoHS:

  • PIC18LF25K22-I/SS

    Manufacturer: Microchip

    IC MCU 8BIT 32KB FLASH 28SSOP

    Product Categories: 8bit MCU

    Lifecycle:

    RoHS:

  • TMS320C6748BZCEA3

    Manufacturer: Texas Instruments

    IC DSP FIX/FLOAT POINT 361NFBGA

    Product Categories: DSP

    Lifecycle:

    RoHS:

  • TMS320DM335DZCE135

    Manufacturer: Texas Instruments

    IC DGTL MEDIA SOC 337NFBGA

    Product Categories: SOC

    Lifecycle:

    RoHS:

Customer Comments

  • Looking forward to your comment

  • Comment

    Verification Code * 

Compare products

Compare Empty