Philips Semiconductors Product data
XA-G30
XA 16-bit microcontroller family
512 B RAM, watchdog, 2 UARTs
2002 Mar 25
11
timer register is loaded with FFFF hex. The underflow also sets the
TF2 flag, which can generate an interrupt if enabled.
The external flag EXF2 toggles when Timer 2 underflows or
overflows. This EXF2 bit can be used as a 17th bit of resolution, if
needed. the EXF2 flag does not generate an interrupt in this mode.
As the baud rate generator, timer T2 is incremented by TCLK.
Baud Rate Generator Mode
By setting the TCLKn and/or RCLKn in T2CON or T2MOD, the
Timer 2 can be chosen as the baud rate generator for either or both
UARTs. The baud rates for transmit and receive can be
simultaneously different.
Programmable Clock-Out
A 50% duty cycle clock can be programmed to come out on P1.6.
This pin, besides being a regular I/O pin, has two alternate
functions. It can be programmed (1) to input the external clock for
Timer/Counter 2 or (2) to output a 50% duty cycle clock ranging from
3.58Hz to 3.75MHz at a 30MHz operating frequency.
To configure the Timer/Counter 2 as a clock generator, bit C/T2 (in
T2CON) must be cleared and bit T20E in T2MOD must be set. Bit
TR2 (T2CON.2) also must be set to start the timer.
The Clock-Out frequency depends on the oscillator frequency and
the reload value of Timer 2 capture registers (TCAP2H, TCAP2L) as
shown in this equation:
TCLK
2 (65536 * TCAP2H, TCAP2L)
In the Clock-Out mode Timer 2 roll-overs will not generate an
interrupt. This is similar to when it is used as a baud-rate generator.
It is possible to use Timer 2 as a baud-rate generator and a clock
generator simultaneously. Note, however, that the baud-rate will be
1/8 of the Clock-Out frequency.
Table 1. Timer 2 Operating Modes
TR2 CP/RL2 RCLK+TCLK DCEN MODE
0 X X X Timer off (stopped)
1 0 0 0 16-bit auto-reload, counting up
1 0 0 1 16-bit auto-reload, counting up or down depending on T2EX pin
1 1 0 X 16-bit capture
1 X 1 X Baud rate generator
T0OE
LSBMSB
BIT SYMBOL FUNCTION
TSTAT.2 T1OE When 0, this bit allows the T1 pin to clock Timer 1 when in the counter mode.
When 1, T1 acts as an output and toggles at every Timer 1 overflow.
TSTAT.0 T0OE When 0, this bit allows the T0 pin to clock Timer 0 when in the counter mode.
When 1, T0 acts as an output and toggles at every Timer 0 overflow.
SU00612B
T1OE
TSTAT Address:411
Bit Addressable
Reset Value: 00H
Figure 5. Timer 0 And 1 Extended Status (TSTAT)
DCEN
BIT SYMBOL FUNCTION
T2MOD.5 RCLK1 Receive Clock Flag.
T2MOD.4 TCLK1 Transmit Clock Flag. RCLK1 and TCLK1 are used to select Timer 2 overflow rate as a clock source
for UART1 instead of Timer T1.
T2MOD.1 T2OE When 0, this bit allows the T2 pin to clock Timer 2 when in the counter mode.
When 1, T2 acts as an output and toggles at every Timer 2 overflow.
T2MOD.0 DCEN Controls count direction for Timer 2 in autoreload mode.
DCEN=0 counter set to count up only
DCEN=1 counter set to count up or down, depending on T2EX (see text).
SU00610B
T2OETCLK1RCLK1
T2MOD Address:419
Bit Addressable
Reset Value: 00H
LSBMSB
Figure 6. Timer 2 Mode Control (T2MOD)
Philips Semiconductors Product data
XA-G30
XA 16-bit microcontroller family
512 B RAM, watchdog, 2 UARTs
2002 Mar 25
12
TCLK
C/T
2 = 0
C/T
2 = 1
TR2
Control
TL2
(8-bits)
TH2
(8-bits)
TF2
T2CAPL T2CAPH
EXEN2
Control
EXF2
Timer 2
Interrupt
T2EX Pin
Transition
Detector
T2 Pin
Capture
SU00704
Figure 7. Timer 2 in Capture Mode
TCLK
C/T2 = 0
C/T
2 = 1
TR2
Control
TL2
(8-bits)
TH2
(8-bits)
TF2
T2CAPL T2CAPH
EXEN2
Control
EXF2
Timer 2
Interrupt
T2EX Pin
Transition
Detector
T2 Pin
Reload
SU00705
Figure 8. Timer 2 in Auto-Reload Mode (DCEN = 0)
TCLK
C/T2 = 0
C/T
2 = 1
TL2 TH2
TR2
CONTROL
T2 PIN
SU00706
FFH FFH
T2CAPL T2CAPH
(UP COUNTING RELOAD VALUE) T2EX PIN
TF2
INTERRUPT
COUNT
DIRECTION
1 = UP
0 = DOWN
EXF2
OVERFLOW
(DOWN COUNTING RELOAD VALUE)
TOGGLE
Figure 9. Timer 2 Auto Reload Mode (DCEN = 1)
Philips Semiconductors Product data
XA-G30
XA 16-bit microcontroller family
512 B RAM, watchdog, 2 UARTs
2002 Mar 25
13
WATCHDOG TIMER
The watchdog timer subsystem protects the system from incorrect
code execution by causing a system reset when the watchdog timer
underflows as a result of a failure of software to feed the timer prior
to the timer reaching its terminal count. It is important to note that
the watchdog timer is running after any type of reset and must be
turned off by user software if the application does not use the
watchdog function.
Watchdog Function
The watchdog consists of a programmable prescaler and the main
timer. The prescaler derives its clock from the TCLK source that also
drives timers 0, 1, and 2. The watchdog timer subsystem consists of
a programmable 13-bit prescaler, and an 8-bit main timer. The main
timer is clocked (decremented) by a tap taken from one of the top
8-bits of the prescaler as shown in Figure 10. The clock source for
the prescaler is the same as TCLK (same as the clock source for
the timers). Thus the main counter can be clocked as often as once
every 32 TCLKs (see Table 2). The watchdog generates an
underflow signal (and is autoloaded from WDL) when the watchdog
is at count 0 and the clock to decrement the watchdog occurs. The
watchdog is 8 bits wide and the autoload value can range from 0 to
FFH. (The autoload value of 0 is permissible since the prescaler is
cleared upon autoload).
This leads to the following user design equations. Definitions: t
OSC
is the oscillator period, N is the selected prescaler tap value, W is
the main counter autoload value, P is the prescaler value from
Table 2, t
MIN
is the minimum watchdog time-out value (when the
autoload value is 0), t
MAX
is the maximum time-out value (when the
autoload value is FFH), t
D
is the design time-out value.
t
MIN
= t
OSC
× 4 × 32 (W = 0, N = 4)
t
MAX
= t
OSC
× 64 × 4096 × 256 (W = 255, N = 64)
t
D
= t
OSC
× N × P × (W + 1)
The watchdog timer is not directly loadable by the user. Instead, the
value to be loaded into the main timer is held in an autoload register.
In order to cause the main timer to be loaded with the appropriate
value, a special sequence of software action must take place. This
operation is referred to as feeding the watchdog timer.
To feed the watchdog, two instructions must be sequentially
executed successfully. No intervening SFR accesses are allowed,
so interrupts should be disabled before feeding the watchdog. The
instructions should move A5H to the WFEED1 register and then
5AH to the WFEED2 register. If WFEED1 is correctly loaded and
WFEED2 is not correctly loaded, then an immediate watchdog reset
will occur. The program sequence to feed the watchdog timer or
cause new WDCON settings to take effect is as follows:
clr ea ; disable global interrupts.
mov.b wfeed1,#A5h ; do watchdog feed part 1
mov.b wfeed2,#5Ah ; do watchdog feed part 2
setb ea ; re-enable global interrupts.
This sequence assumes that the XA interrupt system is enabled and
there is a possibility of an interrupt request occurring during the feed
sequence. If an interrupt was allowed to be serviced and the service
routine contained any SFR access, it would trigger a watchdog
reset. If it is known that no interrupt could occur during the feed
sequence, the instructions to disable and re-enable interrupts may
be removed.
The software must be written so that a feed operation takes place
every t
D
seconds from the last feed operation. Some tradeoffs may
need to be made. It is not advisable to include feed operations in
minor loops or in subroutines unless the feed operation is a specific
subroutine.
To turn the watchdog timer completely off, the following code
sequence should be used:
mov.b wdcon,#0 ; set WD control register to clear WDRUN.
mov.b wfeed1,#A5h ; do watchdog feed part 1
mov.b wfeed2,#5Ah ; do watchdog feed part 2
This sequence assumes that the watchdog timer is being turned off
at the beginning of initialization code and that the XA interrupt
system has not yet been enabled. If the watchdog timer is to be
turned off at a point when interrupts may be enabled, instructions to
disable and re-enable interrupts should be added to this sequence.
Watchdog Control Register (WDCON)
The reset values of the WDCON and WDL registers will be such that
the watchdog timer has a timeout period of 4 × 4096 × t
OSC
and the
watchdog is running. WDCON can be written by software but the
changes only take effect after executing a valid watchdog feed
sequence.
Table 2. Prescaler Select Values in WDCON
PRE2 PRE1 PRE0 DIVISOR
0 0 0 32
0 0 1 64
0 1 0 128
0 1 1 256
1 0 0 512
1 0 1 1024
1 1 0 2048
1 1 1 4096
Watchdog Detailed Operation
When external RESET is applied, the following takes place:
Watchdog run control bit set to ON (1).
Autoload register WDL set to 00 (min. count).
Watchdog time-out flag cleared.
Prescaler is cleared.
Prescaler tap set to the highest divide.
Autoload takes place.
When coming out of a hardware reset, the software should load the
autoload register and then feed the watchdog (cause an autoload).
If the watchdog is running and happens to underflow at the time the
external RESET is applied, the watchdog time-out flag will be
cleared.

4-1734260-3

Mfr. #:
Manufacturer:
TE Connectivity
Description:
Headers & Wire Housings WTB 1.25 PTH 30U GLD 13 POS
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union