PIC16F62X
6.3.1
SWITCHING PRESCALER ASSIGNMENT
To change prescaler from the WDT to the TMR0
module use the sequence shown in Example 6-2. This
precaution must be taken even if the WDT is disabled.
The prescaler assignment is fully under software
control (i.e., it can be changed “on the fly” during
program execution). To avoid an unintended device
EXAMPLE 6-2: CHANGING PRESCALER
RESET,
the
following
instruction
sequence
(WDT→TIMER0)
(Example 6-1) must be executed when changing the
prescaler assignment from Timer0 to WDT.
CLRWDT
;Clear WDT and
;prescaler
EXAMPLE 6-1: CHANGING PRESCALER
BSF
STATUS, RP0
(TIMER0→WDT)
STATUS, RP0 ;Skip if already in
MOVLW
b'xxxx0xxx' ;Select TMR0, new
;prescale value and
;clock source
1.BCF
; Bank 0
2.CLRWDT
3.CLRF
4.BSF
;Clear WDT
;Clear TMR0 & Prescaler
STATUS, RP0 ;Bank 1
MOVWF
BCF
OPTION_REG
STATUS, RP0
TMR0
5.MOVLW '00101111’b ;These 3 lines (5, 6, 7)
6.MOVWF OPTION
; are required only if
; desired PS<2:0> are
; 000 or 001
7.CLRWDT
8.MOVLW '00101xxx’b ;Set Postscaler to
9.MOVWF OPTION ; desired WDT rate
10.BCF STATUS, RP0 ;Return to Bank 0
TABLE 6-1:
REGISTERS ASSOCIATED WITH TIMER0
Value on
Value on
POR
Address
Name
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
All Other
Resets
01h
TMR0
Timer0 module register
GIE T0IE
xxxx xxxx uuuu uuuu
0000 000x 0000 000u
1111 1111 1111 1111
0Bh/8Bh/
10Bh/18Bh
INTCON
—
INTE
T0SE
RBIE
PSA
T0IF
PS2
INTF
PS1
RBIF
PS0
81h
85h
OPTION RBPU INTEDG T0CS
TRISA TRISA7 TRISA6
TRISA4 TRISA3 TRISA2 TRISA1 TRISA0 11-1 1111 11-1 1111
—
Legend: — = Unimplemented locations, read as ‘0’, u = unchanged, x = unknown
Note: Shaded bits are not used by TMR0 module.
1999 Microchip Technology Inc.
Preliminary
DS40300B-page 49