System Integration Block (SIB)
3-40
MC68302 USER’S MANUAL
MOTOROLA
REF—Output Reference Event
The counter has reached the TRR value. The ORI bit in the TMR is used to enable the
interrupt request caused by this event.
Bits 7–2—Reserved for future use.
3.5.2.6 General Purpose Timer Example
This section gives two examples on how to program the general purpose timers.
3.5.2.6.1 Timer Example 1
Generate an interrupt every 10 mS using the 20 MHz system clock.
1. Take the desired interrupt period and divide by the timer clock period to get an initial
count value to calculate prescaler.
Tout
Tin
1
20MHz
2. To calculate the value for the clock divider, divide the count by 65536 (2
16
).
3. The divider must be rounded up to the next integer value. A clock divider of 4 then
changes the input timer period to Tin*4. A new count is calculated based on the new
timer period, and this value will be written to the TRR. The prescaler in the TMR is
equal to the clock divider minus 1 (or 4-1 = 3).
4. Program the TRR to $C350 ( = 50000 decimal).
5. Program the TMR to $031B (prescaler = 3, ORI =1 to enable interrupt, FRR = 1 to re-
start counter after reference is reached, ICLK = 01 to use the master clock, and RST
= 1 to enabled the timer).
Fine adjustments can be made to the timer by varying the TRR up or down.
3.5.2.6.2 Timer Example 2
Generate a 100 Hz square wave using the 20 MHz system clock. As in Timer Example 1,
the period is 10 mS, so we can use the same Prescaler and Reference values. When OM
is set, the TOUT pin only toggles when the reference value is reached. Therefore the refer-
ence value must be divided by two in order to generate two edges every 100 mS.
1. Program the Port B control register to change the port pin from a general purpose input
pin to TOUT.
2. Program the TRR to $61A8 ( = 50000/2).
3. Program the TMR to $321B (prescaler = 3, OM =1 to toggle TOUT, FRR = 1 to restart
-------------
-10ms
-------------------
Count
200 000
,
=
=
=
Count
65536
-----------------
Divider
3.05176
=
=
Tout
Tin Divider
)
-------------------------------------
10ms
50ns 4
-----------------------
50 000
,
=
=