8.3.2
Setup Example
Prescaler Setup Example
Count clock source (IOCLK/32) which is output from the prescaler is selected to the count clock of the timer 0.
A setup procedure with a description of each step is shown below:
Setup Procedure
(1) Stop the counter
TM0MD(0x0000A180)
bp6: TM0LDE=0
bp7: TM0CNE=0
(2) Set the base register
TM0BR(0x0000A188)
(3) Set the prescaler
TM03PSC(0x0000A198)
bp7: TMPSCNE=1
(4) Select the count clock source
TM0MD(0x0000A180)
bp2-0: TM0CK2-0=010
(5) Initialize timer 0
TM0MD(0x0000A180)
bp6: TM0LDE=1
(6) Start timer operation
TM0MD(0x0000A180)
bp7: TM0CNE=1
(1) Set the TM0LDE flag and TM0CNE flag of timer 0 mode
register (TM0MD) to"0" to stop counting of timer 0.
(2) Set timer 0 base register (TM0BR) as needed.
(3) Set the TMPSCNE flag of the prescaler control register
(TM03PSC) to "1".
(4) Select the count clock source (IOCLK/32) by the
TM0CK2 to 0 flag of the TM0MD register.
(5) Set the TM0LDE flag of the TM0MD register to "1" to
initialize timer 0. The value of theTM0BR register is
loaded into the TM0BC counter. After setting, reset the
TM0LDE flag to "0".
(6) Set the TM0CNE flag of the TM0MD register to "1" to
operate timer 0.
Description
Prescaler
Chapter 8
8-bit Timer
VIII - 31