• Keine Ergebnisse gefunden

TIMER MODE DESCRIPTIONS

Im Dokument MICROPROCESSOR REAL-TIME INTERFACING (Seite 156-162)

RED� COM PLFMEIIJT

C TIMER 1 OUT

3.10 TIMER MODE DESCRIPTIONS

This section defines all six modes of the timer, includin� modes 0, 2 and 3 which have previously been discussed as well as the three modes that have been neglected.

The modes differ principally in the effect of the gate input and the behavior of the output.

Modes

0,4 2,3

1, 5

Modes

0,1

2,4,5

3

Low Disables Counting Disables Counting

Gate Input Rising Edge

Reloads counter with initial value and initiates counting.

Reloads counter with initial value and initiates counting Output Signal

Low while counting High at count = O High while counting

High Enables Counting Enables Counting

Low for one clock period High during first half cycle Low during second half cycle

INTERVAL TIMERS Modes 0,4

1, 5

2,3

After Terminal Count

Counting continues but output remains high

Counting stops until a new gate rising edge occurs

Counting starts again from the initial value and output pattern repeats for each full count cycle Figure 3-24 shows more detail of the gate effect and output timing, and the following sections define each mode in detail. Figure 3-25 indicates the timing relationships. Note that mode O and mode 4 are similar except for the output state during counting, but for a given count loaded to the timer, mode 4 will generate an interrupt one clock time later than mode O. The same relationship is true of modes 1 and 5

w I

Starts Output Output counting goes low goes high during counting.

Present period not affected.

INTERVAL TIMERS

MODE 0 Mode Set

Gate. Out

l I

MODE 1 (One Shot) Gate

Out

Load Count Program Count

= 0 = 0

I I I

Count

l

Count

Load

Count from 0

l

Count

1

Count

= 0 O Automatic Reload

_i ___ i u--__+_

full

Count No Countf Count partial

! Count full

r

MODE 2 (Rate Generator) Automatic Reload

t t

Automatic Reload

+ t

Gate

Out No Count Count

count

= 1 count

= f1 Count

r I

partial Stop full

Count Cotm.t

MODE 3 (Square Wave) Automatic Reload Gate

Out

MODE Gate Out

MODE

4

5

11/2 Count 1112 Count j1;2 Count

_I __ u

11;2 Count

L

Load Count Program Count

• I I

Count =

! 0

f1 CountAutomatic Reload from O load

r

Count =

+ lJ

f1

hJ

• I

Mode O

Mode 1

Mode 2

INT ERVAL TIMERS

Interrupt on Terminal Count

The timer counts down from the initial value and continues from zero. The output goes low when mode O is set or when new data is loaded. The output goes high when the count reaches zero. Counting starts when the final byte of the initial value is loaded. If a new value is loaded during counting, loading the first byte stops the count and sets the output low. Mode O is useful for generating a single time delay function or for measuring time from a programmed or external eve�t, providing that the time is less than the 32 millisecond capability of the 16 bit counter. It can be used to measure the duration of an external signal, since counting is enabled only when the gate input is high.

Programmable One Shot

Starts counting down from the initial value after a r1s1ng edge of the gate input. The output goes low at the first count after the gate rising edge, high at zero. Counting starts again from the initial value each time a rising edge occurs at the gate input. Mode 1 is useful for generating a time delay or measuring time from an external event, especially if the external event is a narrow pulse.

Rate Generator

The output goes high w en the mode is set. After the count has been loaded, the timer will repetitively count down from the initial value to zero. The output goes low when the count reaches one and high� it h s zero, so a 0.5 microsecond pulse is generated. Mode 2 is especially useful for timing functions where software counters are to be used f-� times greater than the 32 millisecond capacity of the timers. Counting restarts from the initial value immediately after zero is reached, so a delay before the program services the counter does not introduce any uncertainty in the timing.

If the counter register is reloaded during counting, the present period is not affected, but the new value is effective for subsequent periods. The gate input inhibits counting when it is low. A rising edge restarts the counter from the initial value.

Mode 3

Mode 4

Mode 5

INTERVAL TIMERS

Square Wave Rate Generator

The output goe� high when the mode is set. After the count has loaded, the timer will repetitively count down from the initial value to zero. The output will go low when the count reaches half the initial value and high when the count reaches zero, so a square wave is generated. If the initial value is odd, the output will be high for (n+l)/2 counts and low for (n-1 )/2 counts. If the counter register is reloaded during counting, the present half cycle is not affected, but the new value is effective for the next half cycle and subsequent periods. The gate input inhibits counting when it is low. A rising edge restarts the counter from the initial value.

Software Triggered Strobe

The timer counts down from the initial value. The output goes high when the mode is set, low when the count reaches zero, then high at the nevt clock pulse after zero. If the counter is reloaded while it is running, the new count is effective immediately after the final byte has been loaded. The gate input inhibits counting when it is low.

Hardware Triggered Strobe

Starts counting down from the initial value after a r1s1ng edge of the gate input. The output goes high when the mode is set, low when the count reaches zero, then high at the next clock pulse after zero. Counting starts again from the initial value each time a rising edge occurs at the gate input. If the count register is reloaded during counting,

The present period is not affected. The new count is effective when the next gate rising edge occurs.

MICROCOMPUTER INTERFACING WORKBOOK

Im Dokument MICROPROCESSOR REAL-TIME INTERFACING (Seite 156-162)