![](http://datasheet.mmic.net.cn/30000/MC68307CFG16_datasheet_2368698/MC68307CFG16_144.png)
Dual Timer Module
6-8
MC68307 USER’S MANUAL
MOTOROLA
6.4 TIMER PROGRAMMING EXAMPLES
The programming examples below are written in M68000 assembly language. They refer to
symbolic names of MC68307 registers and bit fields within those registers. For access to on-
chip locations, the addressing mode Offset_From(A5) is used. Below is a list of the bit defi-
nitions used in the examples.
* TMRx bit definitions (non-zero cases only)
RST
EQU
$0001
TMRx RST
; enable timer
ICLK01 EQU
$0002
TMRx ICLK
; use system clock
ICLK10 EQU
$0004
TMRx ICLK
; use system clock divide by 16
ICLK11 EQU
$0006
TMRx ICLK
; use TINx as clock
FRR
EQU
$0008
TMRx FRR
; restart timer on ref. compare
ORI
EQU
$0010
TMRx ORI
; enable interrupt on ref. compare
OM
EQU
$0020
TMRx OM
; toggle TOUTx
CE01
EQU
$0040
TMRx CE
; capture on +ve edge clk + interrupt
CE10
EQU
$0080
TMRx CE
; capture on -ve edge clk + interrupt
CE11
EQU
$00C0
TMRx CE
; capture on both clk edges + interrupt
* TERx bit masks
REF
EQU
$02
; isolate TERx REF bit
CAP
EQU
$01
; isolate TERx CAP bit
The examples assume that the timer is in a reset state prior to execution of the code
sequence, that is, either this is the first timer access after a system reset or the timer mode
register RST bit has had a programmed transition from 1 to 0.
6.4.1 Initialization and Reference Compare Function
This code sequence starts both timers in an output reference compare mode, outputting a
repeating pulse on each channel’s TOUT pin after a preset period. The reference value and
prescale value have been made different in each case to demonstrate programming of dif-
ferent periods.
Interrupts are disabled in this example. If the ORI bit were also set, interrupts would be
enabled, one for each corresponding TOUTx pulse.
TOUTx is also set to output to a single clock pulse on each match. The alternate mode is
toggle mode, accomplished by also setting the OM bit of TMRx.
Note that the timer mode registers can be programmed in one operation. There is no need
to have separate writes to take the timer out of reset, to program the various modes and then
to finally start the clock.
* Enable timer output pins in port A control register
OR.B
#$18,PACNT(A5)
; TOUT1, 2 pins67 dedicated
* Setup timer 1 and timer 2 to run independently of each other
* Both counters reset (and repeat forever) after reference reached
* Both disabled interrupts for reference