Calculating Time-Out Values - Freescale Semiconductor MCF54455 Reference Manual

Table of Contents

Advertisement

*[CE] = 00
disable capture event output
*[OM] = 0
output=active-low pulse
*[ORRI] = 0,
disable ref. match output
*[FRR] = 1,
restart mode enabled
*[CLK] = 10,
internal bus clock/16
*[RST] = 0,
timer0 disabled
move.w #0xFF0C,D0
move.w D0,TMR0
move.l #0x0000,D0;writing to the timer counter with any
move.l DO,TCN0 ;value resets it to zero
move.l #0xAFAF,DO ;set the timer0 reference to be
move.l #D0,TRR0 ;defined as 0xAFAF
The simple example below uses Timer0 to count time-out loops. A time-out occurs when the reference
value, 0xAFAF, is reached.
timer0_ex
clr.l DO
clr.l D1
clr.l D2
move.l #0x0000,D0
move.l D0,TCN0
move.b #0x03,D0
move.b D0,TER0
move.w TMR0,D0
bset #0,D0
move.w D0,TMR0
T0_LOOP
move.b TER0,D1
btst #1,D1
beq T0_LOOP
addi.l #1,D2
cmp.l #5,D2
beq T0_FINISH
move.b #0x02,D0
move.b D0,TER0
jmp T0_LOOP
T0_FINISH
HALT
30.4.2

Calculating Time-Out Values

Equation 30-1
determines time-out periods for various reference values:
Timeout period
=
When calculating time-out periods, add one to the prescaler to simplify calculating, because
DTMRn[PS] equal to 0x00 yields a prescaler of one, and DTMRn[PS] equal to 0xFF yields a prescaler of
256.
Freescale Semiconductor
;reset the counter to 0x0000
;writing ones to TER0[REF,CAP]
;clears the event flags
;save the contents of TMR0 while setting
;the 0 bit. This enables timer 0 and starts counting
;load the value back into the register, setting TMR0[RST]
;load TER0 and see if
;TER0[REF] has been set
;Increment D2
;Did D2 reach 5? (i.e. timer ref has timed)
;If so, end timer0 example. Otherwise jump back.
;writing one to TER0[REF] clears the event flag
;End processing. Example is finished
1 clock frequency
1 or 16
DTMRn[PS]
+
1
DTRRn[REF]
DMA Timers (DTIM0–DTIM3)
+
1
Eqn. 30-1
30-10

Advertisement

Table of Contents
loading

Table of Contents