Programming and Application of Timer/Counter Mode 3

Publisher:runaway2000Latest update time:2018-03-09 Source: eefocusKeywords:Timer Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

  T0 and Tl are very different in mode 3. When T0 works in mode 3, TL0 and TH0 are divided into two independent 8-bit timer/counters. Among them, TL0 can be used as an 8-bit timer/counter, while TH0 can only be used as an 8-bit timer. At this time, T1 can only work in mode 0, 1 or 2.
  
  Generally, when timer Tl is used as a serial port baud rate generator, T0 is set to mode 3. At this time, timer Tl is often set to mode 2 and used as a baud rate generator.
  
  Assume that two external interrupt sources of an AT89S51 microcontroller application system are occupied, and timer Tl is set to work in mode 2 and used as a baud rate generator. Now it is required to add an external interrupt source and control the P1.0 pin to output a 5 kHz (period is 200μs) square wave. Assume that the system clock is 12 MHz.
  
  Basic idea: Set TL0 to work in mode 3 counting mode, the initial value of TL0 is set to 0FFH, when a negative transition is detected on the T0 pin signal, TL0 overflows and requests an interrupt to the CPU at the same time, where the T0 pin is used as an external interrupt request input terminal triggered by a negative transition. In the interrupt handling subroutine, start TH0, which is set to 100 μs timing of mode 3 in advance, thereby controlling P1.0 to output a square wave signal with a period of 200 μs, as shown in the figure below.

 1101 

      (1) Calculation of initial value X. The initial value of TL0 is set to 0FFH.
  
  The period of the 5 kHz square wave is 200 μs, so the timing time of TH0 is 100 μs. The initial value X of TH0 is calculated as follows:
  1102

        
  (2) Program design. The reference program is as follows:

      


Keywords:Timer Reference address:Programming and Application of Timer/Counter Mode 3

Previous article:Dual-machine serial communication software programming
Next article:Programming and Application of Timer/Counter Mode 2

Recommended ReadingLatest update time:2024-11-16 11:53

S3C2440 Timer Initialization Method
S3C2410 provides 5 16-bit Timers (Timer0~Timer4), of which Timer0~Timer3 support Pulse Width Modulation - PWM (Pulse Width Modulation). Timer4 is an internal timer (internal timer), PCLK is the signal source of the Timer, we convert PCLK into an input clock signal by setting the corresponding Prescaler and Clock Divid
[Microcontroller]
S3C2440 Timer Initialization Method
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号