Seminar Topics & Project Ideas On Computer Science Electronics Electrical Mechanical Engineering Civil MBA Medicine Nursing Science Physics Mathematics Chemistry ppt pdf doc presentation downloads and Abstract

Full Version: 8051 Timers pdf
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
8051 Timers


[attachment=56755]

Timer/counters in 8051

The 8051 has two timers T0 and T1, which may be configured and used individ-
ually. The 8052 has an additional Timer T2.
All these counters count up on negative going edges at their inputs. These can
be used as event counters (where they count the number of negative transitions
on a pin connected to some external source), or as Timers, where they count up
once every twelfth clock cycle. A special use of timers is for generating baud rates
for the serial port.
The usage of these timers is somewhat different from common general pur-
pose timer/counters such as the 8253 and 8254. This difference stems partly from
the fact that we cannot afford to have a large numbers of pins dedicated to the
functioning of these timer counters. Thus, just two multifunction pins are used
as external inputs in 8051. Gating is accomplished by control bits in the special
function registers, and using the external interrupt pins as gate inputs. There are
no output pins associated with the timers. The processor can be interrupted by
the timers and as a part of the interrupt service routine, the processor can perform
any IO function through its ports. When used as baud rate generators, the output
goes directly to the serial port hardware within the microcomputer.

Timer Functions

When used as timers, the 8051 timers count up every 12th clock cycle. This is
selected by clearing the corresponding C/T flags in the TMOD special function
register, placed at the address 89H.

Interrupt Vectors for Timers

When an interrupt occurs, the updated PC is pushed on the stack and is loaded
with the vector address corresponding to the interrupt. The following table gives
the vector addresses. The order of entries in the table is also the order in which
the 8051 will poll these in case of multiple interrupts.

Use of gating

Gating is useful when we want an external source to start or stop the timer. If
the gate bit in TMOD is set, the timer would be enabled only if the corresponding
external interrupt pin is high. This can be used to measure pulse widths, by
appling the pulse to the external interrupt pin.