Datasheet
ADuC7033
Rev. B | Page 75 of 140
T0
SYNC
T1
SYNC
T2
SYNC
T3
SYNC
T4
SYNC
T0
T1
T2
T3
T4
T0IRQ
T1IRQ
T2IRQ
T3IRQ
W
D
R
ST
T4IRQ
T0 REG
USER
MMR
INTERFACE
T1 REG
T2 REG
T3 REG
T4 REG
CORE
CLOCK
ARM7TDMI
AMBA
LOW
POWER
OSCILLATOR
HIGH
PRECISION
OSCILLATOR
GPIO
XTAL
0
1
2
4
AMBA
TIMER BLOCK
06847-059
Figure 32. Timer Block Diagram
UNSYNCHRONIZED
SIGNAL
SYNCHRONIZED
SIGNAL
TIMER 2
LOW POWER
CLOCK DOMAIN
SYNCHRONIZER
FLIP-FLOPS
CORE CLOCK
(F
CORE
)
DOMAIN
TARGET_CLOCK
06847-060
Figure 33. Synchronizer for Signals Crossing Clock Domains
As shown in Figure 32, the MMR logic and core timer logic
reside in separate and asynchronous clock domains. Any data
coming from the MMR core clock domain and being passed to
the internal timer domain must be synchronized to the internal
timer clock domain to ensure it is latched correctly into the core
timer clock domain. This is achieved by using two flip-flops as
shown in Figure 33 to not only synchronize but also to double
buffer the data and thereby ensuring data integrity in the timer
clock domain.
As a result of the synchronization block, while timer control
data is latched almost immediately (with the fast, core clock) in
the MMR clock domain, this data in turn will not reach the core
timer logic for at least two periods of the selected internal timer
domain clock.
PROGRAMMING THE TIMERS
Understanding synchronization across timer domains also
requires that the user code carefully program the timers when
stopping or starting them. The recommended code controls the
timer block when stopping and starting the timers and when
using different clock domains. This can be critical, especially if
the timers are enabled to generate an IRQ or FIQ exception. An
example using Timer2 follows.
Halting Timer2
When halting Timer2, it is recommended that the IRQEN
bit for Timer2 be masked (using IRQCLR). This prevents
unwanted IRQs from generating an interrupt in the MCU
before the T2CON control bits have been latched in the Timer2
internal logic.
IRQCLR = WAKEUP_TIMER_BIT; //Masking interrupts
T2CON = 0x00; //Halting the timer