Using the DMA Timer Modules

NOTE

DTINn may not be configured as a clock source when the timer capture mode is selected or indeterminate operation will result.

The 8-bit DTMRn[PS] prescaler value is set

Using DTMRn[RST] the counter is cleared and started

Timer events are either handled with an interrupt service routine, a DMA request or by a software polling mechanism

21.3.1 Code Example

The following code provides an example of how to initialize DMA Timer0 and how to use the timer for counting time-out periods.

DTMR0 EQU IPSBARx+0x400;Timer0 mode register

DTMR1 EQU IPSBARx+0x440 ;Timer1 mode register

DTRR0 EQU IPSBARx+0x404 ;Timer0 reference register

DTRR1 EQU IPSBARx+0x444 ;Timer1 reference register

DTCR0 EQU IPSBARx+0x408 ;Timer0 capture register

DTCR1 EQU IPSBARx+0x448 ;Timer1 capture register

DTCN0 EQU IPSBARx+0x40C ;Timer0 counter register

DTCN1 EQU IPSBARx+0x44C ;Timer1 counter register

DTER0 EQU IPSBARx+0x403 ;Timer0 event register

DTER1 EQU IPSBARx+0x443 ;Timer1 event register

* TMR0

is defined as: *

 

*[PS] = 0xFF,

divide clock by

256

*[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,

system 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 #AFAF,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

MOTOROLA

Chapter 21. DMA Timers (DTIM0–DTIM3)

21-9

Page 455
Image 455
Motorola MCF5281, MCF5282 user manual Code Example