
General-Purpose Timer Registers
MOTOROLA
Timer Module
11-7
11.5.6
TIMER INITIALIZATION EXAMPLE CODE
There are two timers on the MCF5249. With a 70MHZ clock, the maximum period is 3.8 seconds and a
resolution of 14.28 ns. The timers can be free running or count to a value and reset. The following
examples set up the timers:
Timer 0 will count to $AFAF, toggle its output, and reset back to $0000. This will continue infinitely until the
timer is disabled or a reset occurs. No interrupts are set. Prescale is set at 256 and the system clock is
divided by 16, therefore resolution is (16*(256))/70 MHz = 58.51us. Timeout period is
(16*256*44976)/70MHz = 2.63s ($0 - $AFAF = 44976 decimal).
Timer 1 will be free-running and send out a logic pulse every time it compares the count value in the TRR
register. value, which for now, is randomly chosen as $1234. Prescale is set at 127 with the sys_clock
initially divided by 16 (by setting bits 2&1 of the TMR register to 10 therefore, resolution is
(16*(127))/70MHz = 29us. Interrupts are NOT enabled.
Note: The timers were initialized in the SIM to have interrupt values. The following
examples have the interrupts disabled. The initialization in the SIM configuration
was for reference. The Timers CANNOT provide interrupt vectors, only autovectors.
Autovectors and ICRs have been set up as follows. The interrupt levels and priorities were chosen by
random for demonstrative purposes. Users should define the interrupt level and priorities for their specific
application.
11.5.6.1 TIMER 0 (TIMER MODE REGISTER)
Bits 15:8
sets the prescale to 256 ($FF)
Bits 7:6 set for no interrupt (“00”)
Bits 5:4 sets output mode for “toggle”. No interrupts(“10”)
Bits 3 set for “restart” (“1”)
Bits 2:1 set the clocking source to system clock/16 (“10”)
Bit 0 enables/disables the timer
(“0”)
move.w #$FF2C,D0;Setup the Timer mode register (TMR1)
Table 11-8 Timer Event Bit Descriptions
BIT NAME
DESCRIPTION
Bits 7–2
Reserved for future use. These bits are currently 0 when read.
CAP
If a one is read from the Capture Event bit, the counter value has been latched into
the TCR. The CE bit in the TMR enables the interrupt request caused by this event.
Writing a one to this bit will clear the event condition.
REF
If a one is read from the Output Reference Event bit, the counter has reached the
TRR value. The ORI bit in the TMR enables the interrupt request caused by this
event. Writing a one to this bit will clear the event condition.
F
re
e
sc
a
le
S
e
m
ic
o
n
d
u
c
to
r,
I
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
c
..
.