Page 130 - Embedded Microprocessor Systems Real World Design
P. 130
out (rolls over), or it can be set to “1” or “0.” Like the prescaling function, these
features are software-selectable.
Most devices that provide an input capture function permit the input capture
pin to be programmed to capture the timer count on either the rising or falling
edge of the input signal. Some permit you to select rising, falling, or either edge,
and some provide an input noise filter to prevent false captures if the input signal
is noisy.
Some devices permit you to connect an external crystal instead of providing a
clock signal. This crystal is independent of the clock source for the microproces-
sor itself (although it often is internally synchronized to it). A typical application
for this feature is to implement a real-time clock using an external 32.768kHz
crystal .
Some devices have an input that gates the timer on and off. The 80188 micro-
processors have inputs that can be programmed to run the timer when the input
is high and stop the counter when the input is low.
This section has focused on 8-bit timers to keep the figures simple. The same
concepts apply to larger timers as well, and other timer lengths are provided on
many microprocessors. The Atmel AT9OS8515, for example, provides a simple &bit
timer as well as a 16bit timer with input capture and PWh4 capabilities.
Using Timers
Time-Based Temperature Measurement An example that illustrates some of
the important issues you must consider when using timers involves measurement
of temperature. The Maxim MAX6576 is an IC that measures temperature. As
shown in Figure 3.6, the MAX6576 has a single wire output and produces a square
wave with a period that is proportional to temperature in degrees Kelvin. The
MAX6576 can operate from -40°C to +125”C. By connecting the TSO and TS1
inputs to ground or Vcc in various combinations, the MAX6576 can be configured
so that the period varies 10, 40, 160, or 640ps per degree. In the configuration
shown, the period will vary by 40ps per degree. At 25”C, the period will be:
(25 + 273.15) x 40 = 11,926 microseconds, or 11.926ms
Say you connect this to an Atmel AT9OS8515 microprocessor using input capture
mode. Figure 3.6 shows a block diagram of this configuration. Here we are oper-
ating the AT9OS8515 with a 4.096MHz crystal and using a prescaler of 256, so the
timer gets a clock of 4.096MHz/256, or 16,000Hz. The counter increments every
62.5 ps. For this application, it doesn’t matter whether the input capture occurs on
the rising or falling edge of the MAX6576 output.
How accurately can you measure temperature with this arrangement? Since the
MAX6576 changes 40ps per degree and the clock to the counter is 16,00OHz, each
increment of the counter corresponds to 62.5/40 or 1.56 degrees. This is the best
Hardware Design 2 111