Showing posts with label mode3. Show all posts
Showing posts with label mode3. Show all posts

Monday, July 8, 2013

Counters and Timers

Many microcontroller applications require the counting of external events, such as the frequency of a pulse train, or the generation of precise internal time delays between com­puter actions. Both of these tasks can be accomplished using software techniques, but software loops for counting or timing keep the processor occupied so that other, perhaps more important, functions are not done. To relieve the processor of this burden, two 16-bit up counters, named T0 and T1, are provided for the general use of the programmer. Each counter may be programmed to count internal clock pulses, acting as a timer, or pro­grammed to count external pulses as a counter. 


 

TCON(TIMER/COUNTER CONTROL REGISTER)
  1. To control the timer/counter we need TCON register.
  2. its bit addressable
  3. address:88h
 

TMOD(THE TIMER MODE CONTROL REGISTER)
  1. it dedicated two timer.
  2. it is byte addressable
  3. address:89h
 

Timer Mode
The timers may operate in anyone of four modes that are determined by the mode bits, M I and MO, in the TMOD register. Figure 12 shows the four timer modes.

Timer Mode 0

  • Setting timer X mode bits to 00b in the TMOD register.
  • theTHX register as an 8-bit counter and TLX as a 5-bit counter.
  • As an example, the 6 megahertz oscillator frequency would result in a final frequency to TH of 15625 hertz. 
  • The timer flag is set whenever THX goes from FFh to 00h

Timer Mode 1

  • the mode bits are set to 0lb in TMOD
  • Mode 1 is similar to mode 0 except TLX is configured as a full 8-bit counter when .

Timer Mode 2

  • Setting the mode bits to l0b in TMOD configures.
  • the timer to use only the TLX counter as an 8-bit counter. 
  • THX is used to hold a value that is loaded into TLX every time TLX overflows from FFh to 00h. The timer flag is also set when TLX overflows.
  • This mode exhibits an auto-reload feature: TLX will count up from the number in THX. overflow. and be initialized again with the contents of THX.

Timer Mode 3

    • Timer 1 in mode-3 simply holds its count. The effect is same as setting TR1=0. Timer0 in mode-3 establishes TL0 and TH0 as two separate counters.
    • Control bits TR1 and TF1 are used by Timer-0 (higher 8 bits) (TH0) in Mode-3 while TR0 and TF0 are available to Timer-0 lower 8 bits(TL0). 
      figure of Timer Modes
      Related Posts Plugin for WordPress, Blogger...
      Subscribe to RSS Feed Follow me on Twitter!