Tuesday, July 9, 2013


TIMING 

  • If a counter is programmed to be a timer, it will count the internal clock frequency of the 8051 oscillator divided by 12d. 
  • As an example, if the crystal frequency is 6.0 megahertz, then the timer clock will have a frequency of 500 kilohertz.
  • The resultant timer clock is gated to the timer by means of the circuit shown in Figure. 
  • In order for oscillator clock pulses to reach the timer, the C/(T)' bit in the TMOD register must be set to 0 (timer operation). 
  • Bit TRX in the TCON register must be set to 1 (timer run), and the gate bit in the TMOD register must be 0, or external pin (INTX)' must he a 1. 
  • In other words, the counter is configured as a timer, then the timer pulses are gated to the counter by the run bit and the gate bit or the external input bits (INTX)'

 

COUNTING

  • The only difference between counting and timing is the source of the clock pulses to the counters. When used as a timer, the clock pulses are sourced from the oscillator through the divide-by-12d circuit.
  • When used as a counter, pin T0 (P3.4) supplies pulses to counter 0. and pin T1 (P3.5) to counter 1.
  • The C/(T)' bit in TMOD must be set to 1 to enable pulses from the TX pin to reach the control circuit shown in above Figure .
  • The input pulse on TX is sampled during P2 of state 5 every machine cycle. A change on the input from high to low between samples will increment the counter.
  • Each high and low state of the input pulse must thus be held constant for at least one machine cycle to ensure reliable counting. Since this takes 24 pulses, the maximum input frequency that can be accurately counted is the oscillator frequency divided by 24. for our 6 megahertz crystal. the calculation yields a maximum external frequency of 250 kilohertz.





0 comments:

Related Posts Plugin for WordPress, Blogger...
Subscribe to RSS Feed Follow me on Twitter!