Calculating Time-Out Values - Motorola ColdFire MCF5281 User Manual

Motorola microcontroller user's manual
Table of Contents

Advertisement

Using the DMA Timer Modules
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

21.3.2 Calculating Time-Out Values

The formula below determines time-out periods for various reference values:
Time-out period = (1/clock frequency) x (1 or 16) x (DTMRn[PS] + 1) x (DTRRn[REF])
When calculating time-out periods, add 1 to the prescaler to simplify calculating, because
DTMRn[PS] = 0x00 yields a prescaler of 1 and DTMRn[PS] = 0xFF yields a prescaler of
256. For example, if a 66-MHz timer clock is divided by 16, DTMRn[PS] = 0x7F, and the
timer is referenced at 0xFBC5 (64,453 decimal), the time-out period is as follows:
Time-out period = [1/(66 x 10
21-10
;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
6
) x (16) x (127 + 1) x (64,453) = 2.00 s
MCF5282 User's Manual
MOTOROLA

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfire mcf5282

Table of Contents