AN202
V1.0 | Page 53/73
www.cmostek.com
prescaler). The T0SE bit of the OPTION register determines which edge to trigger. The software can set the
T0CS bit of OPTION register to 1 to enter the counter mode.
9.3.1
Software Configuring Prescaler Circuit
The chip has a prescaler circuit in front of the Timer0 and WDT timer, which can be assigned to Timer0 or
WDT timer, but the two can not use the prescaler at the same time. Specifically assigning to Timer0 or WDT is
determined by the PSA bit of the OPTION register. When the PSA is 0, the prescaler is assigned to Timer0. In
the Timer0 prescaler mode, there are 8 prescale rate (1:2 to 1:256). It can be set by the PS<2:0> bit of the
OPTION register.
Note:
1. The prescaler circuit is neither readable nor writable. Any write operation to the TMR0 register will clear
the prescaler circuit.
2. When the prescaler circuit is assigned to WDT, one CLRWDT instruction can clear the prescaler circuit.
3. The prescaler circuit can be assigned to Timer0 or WDT timer, the switching of the prescaler between the
timer0 and the WDT may result in a false reset.
When the prescaler assignment is switched from TMR0 to WDT, please execute the following instruction
sequence.
When the prescaler assignment is switched from WDT to TMR0, please execute the following instruction
sequence.
CLRWDT
;
Clear WDT and prescaler
BANKSEL OPTION_REG
LDWI b
’11110000’
;
Mask TMR0 select and prescaler bits
ANDWR OPTION_REG, W
IORWI b
’00000011’
;
Set prescaler to 1:16
STR OPTION_REG
BANKSEL TMR0
CLRWDT
;
Clear WDT
CLRR TMR0
;
Clear TMR0 and prescaler
BANKSEL OPTION_REG
BSR OPTION_REG, PSA
;
Select WDT
CLRWDT
LDWI b
’11111000’
;
Mask prescaler bits
ANDWR OPTION_REG, W
IORWI b
’00000101’
;
Set WDT prescaler to 1:32
LDWI OPTION_REG
Содержание CMT2189C
Страница 32: ...AN202 V1 0 Page 32 73 www cmostek com...