– Non-page oriented instructions
– Direct addressing
– Four 8-byte RAM register banks
– Stack depth limited only by available internal RAM
(maximum 256 bytes)
– Multiply, divide, subtract and compare instructions
• Modes of reduced activity: Power-down and Idle modes
SZF2002
• Wake-up via external interrupts at
• Frequency range: up to 16 MHz (only limited by external
memory and ADC performance)
• Supply voltage: 3.0 V
• Very low power consumption:
operational 0.65 mW/MHz; Idle 0.25 mW/MHz at 3.0 V
• Operating temperature: −40 to +85 °C.
2GENERAL DESCRIPTION
The SZF2002 low power system controller is
manufactured in an advanced 0.5 µm CMOS technology.
The instruction set of the SZF2002 is based on that of the
80C51 and consists of over 100 instructions: 49 one-byte,
46 two-byte, and 16 three-byte. The device has low power
consumption and two software selectable modes for
power reduction: Idle and Power-down.
This data sheet details the specific properties of the
SZF2002; for details of the 80C51 core and peripheral
functions such as timers, UART and I/O, see
“Data Handbook IC20”
I2C-bus and how to use it”
9398 393 40011.
3APPLICATIONS
The SZF2002 is an 8-bit general purpose microcontroller
especially suited for wireless telephone and battery
powered applications. The SZF2002 also functions as an
arithmetic processor having facilities for both binary and
BCD arithmetic plus bit-handling capabilities.
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
5BLOCK DIAGRAM
INT2 to INT8
INT0
INT1
PROGRAM
CPU
XCLK
RST
CE
OE
T0T1
TWO 16-BIT
TIMER/
EVENT
COUNTERS
(T0, T1)
V
DD
MEMORY
6-KBYTE
ROM
V
SS
33
DATA
MEMORY
6144 + 256
bytes RAM
V
PWM
PWMADC
V
DDA
SSA
SZF2002
ADC0 to ADC5
WE
RAMCE
EA
DEBUG
D0 to D7
A0 to A17
excluding
ROM/RAM
PARALLEL
I/O PORTS
AND
EXT. BUS
80C51
core
SERIAL
UART
PORT
RXDTXDP3P1
8-BIT
I/O
PORTS
P4
SZF2002
16-BIT
TIMER/
EVENT
COUNTER
T2
T2EX
I2C-BUS
INTERFACE
SDASCL
WATCHDOG
TIMER
(T3)
MGM180
(1) Address lines A0 to A5 have alternative functions during Debug; see Section 7.2.
Fig.1 Block diagram.
1998 Aug 264
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
6FUNCTIONAL DIAGRAM
handbook, full pagewidth
XCLK
WE
OE
CE
PWM
V
SSA
V
DDA
V
V
DD
SS
3
3
0
0
PORT 1
PORT 3
T2 INT2
T2EX INT3
SCL
SDA
RXD
TXD
INT0
INT1
T0
T1
INT4
INT5
INT6
INT7
INT8
SZF2002
RAMCE
PORT 4
DEBUG
ADC0
ADC1
ADC2
ADC3
ADC4
ADC5
RST
EA
SZF2002
0
data bus
00
address bus
RD
WR
ALE
PSEN
RST
TRUE_A15
MGM181
Fig.2 Functional diagram.
1998 Aug 265
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
7PINNING INFORMATION
7.1Pinning
handbook, full pagewidth
n.c.
A12
A7
A6
A5
A4
PWM
RST
XCLK
V
DD
V
SS
P3.7
P3.6
P3.5/T1
P3.4/T0
P3.3/INT1
P3.2/INT0
P3.1/TXD
P3.0/RXD
n.c. 20
n.c.
A15
A16
WE
A17
A14
A13
A8
80
79
78
77
76
75
74
73
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
A9
VSSVDDA11
72
71
SZF2002
SZF2002
OE
A10
CE
D7
D6
D5
D4
n.c.
70
69
68
67
66
65
64
63
62
61
60
n.c.
D3
59
D2
58
D1
57
D0
56
A0
55
A1
54
A2
53
A3
52
V
51
SS
V
50
DD
P4.0/RAMCE
49
P4.1
48
P4.2
47
P4.3
46
P4.4
45
P4.5
44
P4.6
43
P4.7
42
n.c.
41
21
22
23
24
25
26
27
28
29
30
n.c.
P1.7/SDA
P1.6/INT8/SCL
P1.5/INT7
P1.4/INT6
P1.3/INT5
P1.2/INT4
P1.1/INT3/T2EX
V
P1.0/INT2/T2
Fig.3 Pin configuration.
1998 Aug 266
DDA
31
SSA
V
32
ADC5
33
ADC4
34
ADC3
35
ADC2
36
ADC1
37
ADC0
38
EA
39
40
n.c.
DEBUG
MGM182
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
SZF2002
6-kbyte embedded RAM
7.2Pin description
Table 1 LQFP80 package
SYMBOLPINDESCRIPTION
Program memory interface; note 1
A055A0/
A154A1/
A253A2/ALE. Address line 2, used as ALE during Debug.
A352A3/
A46A4/RST. Address line 4, used as RST during Debug.
A55A5/TRUE_A15. Address line 5, used as A15 = P2.7 during Debug.
A64A6. Address line 6 (not needed during Debug, see D6).
A73A7. Address line 7 (not needed during Debug, see D7).
A873Address lines A8 to A14. During Debug these lines are used as P2.0 to P2.6.
A972
A1067
A1169
A122
A1374
A1475
A1579Address lines A15 to A17. Page selection; during Debug these lines are the page
A1678
A1776
D056Data bus. During Debug these line are P0.0 to P0.7.
D157
D258
D359
D462
D563
D664
D765
CE66Chip Enable. Enable strobe to external program memory.
OE68Output Enable. Output read strobe to external memory.
WE77Write Enable. Write strobe to external memory.
RD. Address line 0, used as RD during Debug.
WR. Address line 1, used as WR during Debug.
PSEN. Address line 3, used as PSEN during Debug.
register. Each bank is 32 kbytes.
1998 Aug 267
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
SZF2002
6-kbyte embedded RAM
SYMBOLPINDESCRIPTION
I/O Ports
INT2/T229Port 1 (P1.0 to P1.7). 8-bit bidirectional I/O port with internal pull-ups; INT2 to INT8:
P1.0/
P1.1/
INT3/T2EX28
P1.2/
INT427
P1.3/
INT526
INT625
P1.4/
P1.5/
INT724
P1.6/
INT8/SCL23
P1.7/SDA22
P3.0/RXD19Port 3 (P3.0 to P3.7). 8-bit bidirectional I/O port with internal pull-ups; RXD: serial
P3.1/TXD18
P3.2/INT017
P3.3/
Port 1 pins that have logic 1s written to them are pulled HIGH by the internal pull-ups,
and in that state can be used as inputs (note P1.6 and P1.7 are open-drain only).
As inputs, Port 1 pins that are externally pulled LOW will source current
(IIL, see Chapter 25) due to the internal pull-ups.
port receiver data input (asynchronous); TXD: serial port transmitter data output
(asynchronous);
T0: Timer 0 external input; T1: Timer 1 external input.
Port 3 pins that have logic 1s written to them are pulled HIGH by the internal pull-ups,
and in that state can be used as inputs. As inputs, Port 3 pins that are externally pulled
LOW will source current (IIL, see Chapter 25) due to the internal pull-ups.
RAM.
Port 4 pins that have logic 1s written to them are pulled HIGH by the internal pull-ups,
and in that state can be used as inputs. As inputs, Port 4 pins that are externally pulled
LOW will source current (IIL, see Chapter 25) due to the internal pull-ups.
ADC037Input channels to the ADC.
ADC136
ADC235
ADC334
ADC433
ADC532
1998 Aug 268
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
SZF2002
6-kbyte embedded RAM
SYMBOLPINDESCRIPTION
General
PWM7Pulse Width Modulation output.
RST8Reset. A HIGH level on this pin for at least 12 clock cycles resets the device.
XCLK9Clock input.
EA38External Access. When EA is HIGH the CPU executes out of internal program
memory (unless the program counter exceeds 7FFFH). A LOW EA forces the CPU to
execute out of external memory regardless of the value of the Program Counter. This
signal is latched at the falling edge of reset (RST pin). The EA pin has an internal
pull-down. When it is not connected the CPU executes from external memory.
DEBUG39DEBUG enable. If HIGH, forces standard 80C51 timing signals output at address and
databus. In this mode the databus is multiplexed with the lower 8 bits of the address
Power
V
DD
bus, and the A0 to A3 lines are used for the
allows a standard 80C51 in-circuit emulator to be connected. For normal operation
connect DEBUG to VSS.
10, 50,70Power supply digital core and digital I/O pads.
RD, WR, ALE and PSEN signals. This
V
SS
V
DDA
V
SSA
n.c.1, 20,
Note
1. The pin layout has been optimized for easy connection of 256 kbytes Flash ROM (e.g. ATMEL AT29LV010A,
SGS-Thomson M28V201, or AMD Am29F010).
11, 51,71Ground: circuit ground potential.
30Analog power.
31Analog ground.
Not connected.
21, 40,
41, 60,
61, 80
1998 Aug 269
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
8FUNCTIONAL DESCRIPTION
Detailed descriptions of each function are described in:
The SZF2002 is a stand-alone high-performance CMOS
microcontroller designed for use in real-time applications
such as wireless telephone and mobile communications,
instrumentation, industrial control, intelligent computer
peripherals and consumer products.
The device provides hardware features, architectural
enhancements and new instructions to function as a
controller for applications requiring up to 256 kbytes of
program memory and/or up to 6144 + 256 bytes of on-chip
data memory.
SZF2002
The SZF2002 contains a 6-kbyte program memory; a
static 6144 + 256 byte data memory (RAM); 24 I/O lines;
three 16-bit timer/event counters; a fifteen-source two
priority-level, nested interrupt structure, a 6-channel 8-bit
ADC, a Watchdog Timer and a Pulse Width Modulation
output.
Two serial interfaces are provided on-chip:
• A standard UART serial interface
2
• A standard I
of up to 400 kbits/s (depending on clock frequency).
The I2C-bus serial interface has byte oriented master
and slave functions allowing communication with the
whole family of I2C-bus compatible devices.
The device has two software selectable modes of reduced
activity for power reduction:
• Idle mode: freezes the CPU while allowing the
derivative functions (timers, serial I/O, RAM,
ADC and PWM) and interrupt system to continue
functioning
• Power-down mode: saves the RAM contents but stops
the clock causing all other chip functions to be
inoperative.
8.2CPU timing
A machine cycle consists of a sequence of 6 states. Each
state lasts one clock period, thus a machine cycle takes
6 clock periods or 1 µs if the clock frequency (f
6 MHz.
C-bus serial interface with a transfer speed
) is
clk
1998 Aug 2610
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
9MEMORY ORGANIZATION
The SZF2002 has 6 kbytes of program memory plus
6 kbytes + 256 bytes of data memory on chip. The device
has separate address spaces for program and data
memory (see Fig.4).
The SZF2002 can directly address up to 256 kbytes of
external data memory. The CPU generates the read
strobe (OE), the write strobe (WE) and chip select (CE) for
external program memory (Flash), and read strobe (OE)
and write strobe (WE) and chip select (RAMCE) for
external data memory.
9.1Program memory
The SZF2002 contains 6 kbytes of internal ROM and
6144 + 256 bytes of RAM. The lower 6 kbytes of program
memory can be implemented in either on-chip ROM or
external program memory. The 6 kbytes of program
memory is implemented as mask programmable ROM.
There are two modes for the program memory, depending
on the state of the
address range:
1. EA = 0. All program fetches are directed to the
external program memory. After reset the CPU begins
execution at location 8000H.
2. EA = 1. After reset the CPU begins execution at
location 0000H. Fetches from addresses
2000H to 37FFH are redirected to the Auxiliary RAM.
The processor can fill this RAM with normal write
operations to the data memory (MOVX to addresses
0000H to 17FFH). Program memory fetches from
addresses 0000H to 17FFH are directed to the
internal ROM.
Program Counter values greater than 7FFFH are
automatically addressed to external memory regardless of
the state of the EA pin.
9.2Data memory
The SZF2002 contains 6144 + 256 bytes of RAM and a
number of Special Function Registers (SFRs). All these
data spaces are addressed differently. Figure 4 shows the
internal data memory space divided into the lower
128 bytes, the upper 128 bytes, Auxiliary RAM, and the
SFRs space. Internal RAM locations 0 to 127 are directly
and indirectly addressed. Internal RAM locations
128 to 255 are only indirectly addressed.
EA pin (latched during reset) and on the
SZF2002
The Special Function Register locations 128 to 255 are
only directly addressed. Auxiliary RAM is accessible via
MOVX instructions to the lower 32-kbyte address space.
MOVX @R0/R1 instructions use SFR P2 as page
selector. The upper 32-kbyte address space is redirected
to the program memory, to accommodate flash
programming.
9.3Special Function Registers (SFRs)
The upper 128 bytes are the address locations of the
SFRs. Figures 6 and 7 show the Special Function
Registers space. The SFRs include the port latches,
timers, peripheral control, serial I/O registers, etc. These
registers are accessed by direct addressing. There are
128 directly addressed locations in the SFR address
space. Bit addressed SFRs are those that end in 000B.
9.4Addressing
The SZF2002 has five methods for addressing source
operands:
• Register
• Direct
• Indirect
• Immediate
• Base-Register plus Index-Register-Indirect.
The first three methods can be used for addressing
destination operands. Most instructions have a
‘destination/source’ field that specifies the data type,
addressing methods and operands involved.
For operations other than MOVs, the destination operand
is also a source operand.
Access to memory addressing is as follows:
• Registers in one of the four register banks through Direct
or Indirect (see Fig.5)
• Lower 128 bytes of internal RAM through Direct or
register Indirect; upper 128 bytes of internal RAM
through Indirect
• Special Function Registers through Direct
• Program memory look-up tables through Base-Register
plus Index-Register-Indirect
• Extended data memory access through register Indirect.
1998 Aug 2611
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
handbook, full pagewidth
FFFFH
EXTERNAL
FLASH ROM
(BANKED)
8000H
7FFFH
37FFH
INTERNAL
AUX RAM
6-KBYTE
INTERNAL
ROM
(4)
EA = 1
0000H
EXTERNAL
ROM
BANK 0
EA = 0
2000H
17FFH
0000H
FFFFH
8000H
7FFFH
1800H
17FFH
0000H
EXTERNAL
FLASH ROM
(BANKED)
EXTERNAL
RAM
INTERNAL
AUX RAM
(MOVX)
FFH
80H
00H
INTERNAL
RAM
(1)
(2)
overlapped space
FUNCTION
(3)
REGISTERS
SZF2002
SPECIAL
INTERNAL MEMORYDATA MEMORYPROGRAM MEMORY
(1) Accessible via indirect addressing only.
(2) Accessible via direct and indirect addressing.
(3) Accessible via direct addressing.
(4) Gaps in the address map are undefined, and should not be used.
Fig.4 Memory map.
Table 2 Memory spaces; note 1
MEMORY SPACEADDRESS MODEUSED SIGNAL
Internal RAM 00H to 7FHdirect and indirect−
Internal RAM 80H to FFHindirect−
SFRs 80H to FFHdirect−
Internal AUX RAM (on-chip) 0000H to 17FFHMOVX−
External RAM (off-chip) 1800H to 7FFFHMOVX
External ROM (off-chip) 0000H to FFFFH; note 2program execution
RAMCE, OE and WE
CE, OE
Internal AUX RAM (on-chip) 2000H to 37FFHprogram execution−
External Flash ROM write (off-chip) 8000H to FFFFH; note 2MOVX
CE, OE and WE
Notes
1. Execution from internal memory is only possible when
EA = 1 during reset.
2. Page select is used to access all 8 banks in the 256-kbyte address space.
MGM183
1998 Aug 2612
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
SZF2002
6-kbyte embedded RAM
9.5Paging logic
The SZF2002 contains paging logic to handle the extended address range.
1. During Debug A<17-15> are used to output the bank register. The TRUE_ A15 line is output at the A5 pin.
2. During Debug ROM and RAM access is done via
BANK SFR [2 : 0]A<17-15> PINSBANKREMARK
PSEN, WR and RD.
handbook, halfpage
R7
R0
R7
R0
R7
R0
R7
R0
7FH
30H
2FH
20H
1FH
18H
17H
10H
0FH
08H
07H
4 banks of 8 registers
0
MGD675
Fig.5 The lower 128 bytes of internal RAM.
(R0 to R7)
1998 Aug 2613
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
REGISTER
MNEMONIC
PWMP
PWM
IP1
WDTKEY
B
IX1
IEN1
BIT ADDRESS
FEFFFD FC FB FA F9 F8
F6F7F5 F4 F3 F2 F1 F0
EEEFED EC EB EA E9 E8
DIRECT
BYTE
ADDRESS (HEX)
FFHT3
FEH
FDH
FCH
F8H
F7H
F0H
EFH
EEH
EDH
ECH
EBH
EAH
E9H
E8H
SZF2002
ACC
S1ADR
S1DAT
S1STA
S1CON
PSW
TH2
TL2
RCAP2H
RCAP2L
T2MOD
T2CON
ADCH
ADCON
P4
IRQ1
E6E7E5 E4 E3 E2 E1 E0
DEDFDD DC DB DA D9 D8
D6D7D5 D4 D3 D2 D1 D0
CECFCD CC CB CA C9 C8
C6C7C5 C4 C3 C2 C1 C0
E0H
DBH
DAH
D9H
D8H
D0H
CFH
CEH
CDH
CCH
CBH
CAH
C9H
C8H
C5H
C4H
C1H
C0H
SFRs containing
directly addressable
bits
MGM184
Fig.6 Special Function Register memory map.
1998 Aug 2614
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
REGISTER
MNEMONIC
IP0
P3
IEN0
BIT ADDRESS
BE BD BC BB BA B9 B8
B6B7B5 B4 B3 B2 B1 B0
AEAFAD AC AB AA A9 A8
DIRECT
BYTE
ADDRESS
B8H
B0H
AFH
AEH
ADH
ACH
ABH
AAH
A9H
A8H
SZF2002
(used as
address bus)
S0BUF
S0CON
ROMBANK
TMOD
TCON
PCON
(used as
address bus)
P2
P1
TH1
TH0
TL1
TL0
DPH
DPL
SP
P0
A6A7A5 A4 A3 A2 A1 A0
9E9F9D 9C 9B 9A 99 98
969795 94 93 92 9190
8E8F8D 8C 8B 8A 89 88
868785 84 83 8281 80
A0H
9AH
99H
98H
91H
90H
8DH
8CH
8BH
8AH
89H
88H
87H
83H
82H
81H
80H
SFRs containing
directly addressable
bits
MGM185
Fig.7 Special Function Register memory map (continued from Fig.6).
1998 Aug 2615
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
SZF2002
6-kbyte embedded RAM
10 PROGRAM STATUS WORD (PSW)
The Program Status Word contains several status bits that
reflect the current state of the CPU. The PSW, shown in
Table 4, resides in the SFR memory space. It contains the
Carry bit, the Auxiliary Carry (for BCD operations), the two
register bank select bits, the Overflow flag, a Parity bit and
two user-definable status flags.
The Carry bit, other than serving the function of a Carry bit
in arithmetic operations, also serves as the Accumulator
for a number of boolean operations.
Bits RS0 and RS1 are used to select one of the four
register banks; see Table 5. A number of instructions refer
Table 4 Program Status Word (SFR address D0H)
76543210
CYACF0RS1RS0OVUSRP
Table 5 Description of PSW bits
to these RAM locations as R0 through to R7. The selection
of which of the four register banks is being referred to is
made on the basis of the state of RS0 and RS1 at
execution time.
The Parity bit reflects the number of 1s in the Accumulator:
P = 1, if the Accumulator contains an odd number of 1s,
and P = 0, if the Accumulator contains an even number of
1s. Thus, the number of 1s in the Accumulator plus P is
always even. The bits F0 and USR are uncommitted and
may be used as general purpose status flags.
BITSYMBOLDESCRIPTION
7CYCarry flag. The Carry flag receives carry out from bit 7 of ALU operands.
6ACAuxiliary Carry flag. The Auxiliary Carry flag receives carry out from bit 3 of addition
operands.
5F0General purpose status flag.
4RS1Register Bank Select 1. This bit selects Register Bank 1.
3RS0Register Bank Select 0. This bit selects Register Bank 0.
2OVOverflow flag. This flag is set by arithmetic operations.
1USRUSR. This is a user-definable flag.
0PParity. If the Accumulator contains an odd number of 1s this bit is set to a logic 1 by
hardware. Otherwise, the state of this bit is a logic 0.
1998 Aug 2616
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
11 I/O FACILITIES
11.1Ports
The SZF2002 has 24 I/O lines: ports P1, P3 and P4 of
which ports P1 and P3 are bit addressed (P0 and P2 are
always used as address/data bus). Ports 0 to 4 have the
following alternative functions:
Port 0 Used internally.
Port 1 Used for a number of special functions:
• Provides the inputs for the external interrupts:
INT2 to INT8
• The I2C-bus interface: SCL and SDA
• Counter inputs: T2 and T2EX.
Port 2 Used internally.
Port 3 Pins can be configured individually to provide:
• External interrupt request inputs: INT1 and INT0
• Counter input: T1 and T0
• UART input and output: RXD and TXD.
SZF2002
Port 4 Provides chip select for external data memory:
RAMCE.
To enable a port pin alternative function, the port bit latch
in its SFR must contain a logic 1.
Each port consists of a latch (SFRs P0 to P4), an output
driver and input buffer. Ports 1, 3 and 4 have internal
pull-ups (except P1.6 and P1.7). Figure 8 shows that the
strong transistor ‘p1’ is turned on for only 2 clock periods
after a LOW-to-HIGH transition in the port latch. When on,
it turns on ‘p3’ (a weak pull-up) through the inverter. This
inverter and ‘p3’ form a latch which holds the logic 1.
In Port 0 the pull-up ‘p1’ is only on when emitting logic 1s
for external memory access.
11.2Port configuration
The port pins (except for P1.6 and P1.7) are configured as
shown in Fig.8. This is a quasi-bidirectional I/O with
pull-up. The strong booster pull-up ‘p1’ is turned on for one
clock period after a LOW-to-HIGH transition in the port
latch. All port pins will be set to HIGH during reset.
handbook, full pagewidth
from port latch
read port pin
input data
2 clock
periods
Q
strong pull-up
INPUT
BUFFER
Fig.8 Port configuration.
1998 Aug 2617
V
DD
p2
p1
n
p3
I/O pin
MBK456
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
12 TIMER/EVENT COUNTERS
The SZF2002 contains three 16-bit timer/event counter
registers; Timer 0, Timer 1 and Timer 2 which can perform
the following functions:
• Measure time intervals and pulse duration
• Count events
• Generate interrupt requests.
In the ‘Timer’ operating mode the register increments
every machine cycle. Since a machine cycle consists of
6 clock periods, the count rate is1⁄6f
In the ‘Counter’ operating mode, the register increments in
response to a HIGH-to-LOW transition. Since it takes
2 machine cycles (12 clock periods) to recognize a
HIGH-to-LOW transition, the maximum count rate is
1
⁄12f
. To ensure a given level is sampled, it should be
clk
held for at least one complete machine cycle.
12.1Timer 0 and Timer 1
Timer 0 and Timer 1 can be programmed independently to
operate in four modes:
Mode 0 8-bit timer or 8-bit counter each with divide-by-32
prescaler.
Mode 1 16-bit time-interval or event counter.
Mode 2 8-bit time-interval or event counter with automatic
reload upon overflow.
Mode 3 Timer 0 establishes TL0 and TH0 as two
separate counters.
12.2Timer 2
Timer 2 is a 16-bit timer/up-down counter that can operate
(like Timer 0 and 1) either as a timer or as an event
counter. These functions are selected by the state of the
C/T2 bit in the T2CON register; see Section 12.3.
Three operating modes are available: Capture,
Auto-reload and Baud Rate Generator, which also are
selected via the T2CON register.
12.2.1C
Figure 9 shows the Capture mode. Two options in this
mode may be selected by the EXEN2 bit in T2CON:
• If EXEN2 = 0, then Timer 2 is a 16-bit timer or counter
that sets the Timer 2 overflow bit (TF2) on overflow, this
can be used to generate an interrupt.
APTURE MODE
clk
.
SZF2002
• If EXEN2 = 1, Timer 2 operates as already described
but with the additional feature that a HIGH-to-LOW
transition at external input T2EX causes the current
value in TL2 and TH2 to be captured into registers
RCAP2L and RCAP2H respectively. In addition, the
transition at T2EX causes the EXF2 bit in T2CON to be
set; this may also be used to generate an interrupt.
12.2.2A
Figure 10 shows the Auto-reload mode.
• Counting up (DCEN = 0)
In the Auto-reload mode and counting up, registers
RCAP2L/RCAP2H are used to hold a reload value for
TL2 /TH2 when Timer 2 rolls over. By setting/clearing bit
EXEN2 in T2CON the external trigger input pin T2EX
can be enabled/disabled. If EXEN2 = 0, then Timer 2 is
a 16-bit timer/counter which upon overflow sets TF2,
and reloads TL2/TH2 with the reload value held in
RCAP2L/RCP2H. If EXEN2 = 1, then Timer 2 performs
as above, but with the added feature that a
HIGH-to-LOW transition at pin T2EX causes the current
Timer 2 value (TL2/TH2 data) to be reloaded with the
value held in RCAP2L/RAP2H, and bit EXF2 in T2CON
to be set.
Timer 2 interrupt will be set if EXF2 is set or TF2 is set.
• Counting up (DCEN = 1 and T2EX = 1). In this mode
Timer 2 will count up. When the timer overflows (FFFFH
state), TF2 bit will be set. This will reload TL2 and TH2
with the contents of T2CAPL and T2CAPH, respectively.
Also bit EXF2 will be toggled. Bit EXF2 can be used as
the 17th bit if desired.
Timer 2 interrupt will be set only if TF2 is set.
• Counting down (DCEN = 1 and T2EX = 0.In this mode
Timer 2 will be counting down. Underflow will occur
when the contents of TL2/TH2 matches the contents of
RCAP2L/RCAP2H. A Timer 2 roll-over from
0000H to FFFFH is not considered as an underflow.
Upon underflow, bit TF2 will be set and registers
TL2/TH2 will be loaded with FFFFH. In addition, an
underflow will cause bit EXF2 to toggle, such that it can
be used as the 17th bit if desired.
Timer 2 interrupt will be set only if TF2 is set.
12.2.3B
The Baud Rate Generator mode is selected when
RCLK0 = 1 or TCLK0 = 1 or RCLK1 = 1 or TCLK1 = 1.
It will be described in conjunction with the serial port
(UART); see Section 17.3.2.
UTO-RELOAD MODE
AUD RATE GENERATOR MODE
1998 Aug 2618
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
handbook, full pagewidth
f
clk
6
T2 PIN
T2EX PIN
C/T2 = 0
C/T2 = 1
transition
detector
control
TR2
capture
control
EXEN2
TL2
(8 BITS)
RCAP2LRCAP2H
TH2
(8 BITS)
TF2
EXF2
MGM136
SZF2002
Timer 2
interrupt
handbook, full pagewidth
f
clk
T2EX PIN
T2 PIN
6
C/T2 = 0
C/T2 = 1
transition
detector
Fig.9 Timer 2 in Capture mode.
control
EXEN2
control
TR2
reload
TL2
(8 BITS)
RCAP2LRCAP2H
(8 BITS)
TH2
TF2
EXF2
MGM137
Timer 2
interrupt
Fig.10 Timer 2 in Auto-reload mode.
1998 Aug 2619
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
SZF2002
6-kbyte embedded RAM
12.3Timer/Counter 2 Control Register (T2CON)
Table 6 Timer/Counter 2 Control Register (SFR address C8H)
76543210
TF2EXF2RCLK0TCLK0EXEN2TR2C/
Table 7 Description of T2CON bits
BITSYMBOLDESCRIPTION
7TF2Timer 2 overflow flag. Set by a Timer 2 underflow or overflow and must be cleared by
software. TF2 will not be set when in either the Baud Rate generation mode or Clock out
mode.
6EXF2Timer 2 external flag. Set when either a capture or reload is caused by a negative
transition on T2EX and when EXEN2 = 1. In Auto-reload mode it is toggled on an
underflow or overflow. Cleared by software.
5RCLK0Receive clock 0 flag. When set, causes the UART to use Timer 2 overflow pulses.
RCLK0 = 0, causes Timer 1 overflow pulses to be used.
4TCLK0Transmit clock 0 flag. When set, causes the UART to use Timer 2 overflow pulses.
TCLK0 = 0, causes Timer 1 overflow pulses to be used.
3EXEN2Timer 2 external enable flag. When set, allows a capture or reload to occur, together
with an interrupt, as a result of a negative transition on input T2EX (if in Capture mode
or Auto-reload mode with DCEN reset). If in Auto-reload mode and DCEN is set, this bit
has no influence. In the other modes EXF2 is set and an interrupt is generated on a
HIGH-to-LOW transition on T2EX pin. In all modes EXEN2 = 0, causes Timer 2 to
ignore events at T2EX.
2TR2Timer 2 start/stop control. When TR2 = 1, Timer 2 is started.
1C/
0CP/
T2Timer or counter select for Timer 2. C/T2 = 0, selects the internal timer with a clock
frequency of1⁄6f
triggered.
RL2Capture/Reload flag. Selection of Capture or Auto-reload mode.
7−These 2 bits are reserved.
6−
5RCLK1Receive Clock 1 flag. Reserved for future UART2. When set, causes the UART to use
Timer 2 overflow pulses. RCLK1 = 0, causes Timer 1 overflow pulses to be used.
4TCLK1Transmit Clock 1 flag. Reserved for future UART2. When set, causes the UART to use
Timer 2 overflow pulses. TCLK1 = 0, causes Timer 1 overflow pulses to be used.
3−This bit is reserved.
2T2RDTimer 2 Read flag. This bit is set by hardware if following a TL2 read and before a TH2
read, TH2 is incremented. It is reset on the trailing edge of the next TL2 read.
1T2OETimer 2 Output Enable. When set, output is activated to output a clock at the T2 pin
(Clock output mode).
0DCENDown Count Enable. When set, this allows Timer 2 to be configured as an up/down
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
12.5Watchdog Timer (T3)
In addition to Timer 2 and the standard timers, a Watchdog
Timer (consisting of an 11-bit prescaler and an 8-bit timer)
is also available.
The Watchdog Timer is controlled by the Watchdog
Enable Register (WDTKEY). When WDTKEY = 55H, the
timer is disabled and the Power-down mode is enabled.
Otherwise, the timer is enabled and the Power-down mode
is disabled. In the Idle mode the Watchdog Timer and reset
circuitry remain active.
The Watchdog Timer is shown in Fig.11.
The timer frequency is derived from the clock frequency
using the formula shown below:
f
f
=
timer
------------------------------------------ -
When a timer overflow occurs, the microcontroller is reset.
To prevent a system reset the timer must be reloaded in
time by the application software.
clk
62048×()T3×
SZF2002
If the processor suffers a hardware/software malfunction,
the software will fail to reload the timer.This failure will
produce a reset upon overflow thus preventing the
processor running out of control.
The Watchdog Timer can only be reloaded if the condition
flag WLE (PCON.4) has been previously set by software.
At the moment the counter is loaded the condition flag is
automatically cleared. After reset the Watchdog Timer is
off. The Watchdog Timer is started by loading a value into
T3.
The time interval between the timer reloading and the
occurrence of a reset is dependent upon the reloaded
value. The time interval is derived from the clock and the
value programmed into T3 and may be calculated as
shown below:
T
reload
For example, this time period may range from 2 to 500 ms
when using a clock frequency f
256 T3–()
=
----------------------------f
timer
= 6 MHz.
clk
handbook, full pagewidth
SFR WDTKEY
INTERNAL BUS
overflow
internal
reset
LOADEN
PCON.1
MGM141
R
RST
RST
write
T3
PRESCALER
11-BIT
CLEAR
TIMER T3 (8-BIT)
LOAD
LOADEN
CLEAR
WLEPD
PCON.4
INTERNAL BUS
f
/6
clk
Fig.11 Functional diagram of the Watchdog Timer (T3).
1998 Aug 2622
Philips SemiconductorsProduct specification
Low voltage 8-bit microcontroller with
6-kbyte embedded RAM
13 PULSE WIDTH MODULATED OUTPUT
One Pulse Width Modulated output channel PWM is
provided which outputs pulses of programmable length
and interval. The repetition frequency is defined by an 8-bit
prescaler (PWMP) that generates the clock for the
counter. The 8-bit counter counts modulo 255, i.e. from
0 to 254 inclusive. The value held in the 8-bit counter is
compared to the contents of the register PWM. If a new
prescaler value is written in register PWMP the 8-bit
counter finishes uninterrupted, and the new prescaler
value is used in the next count cycle.
Provided the contents of this register are greater than the
counter value, the PWM output is set HIGH. If the contents
of register PWMP are equal to, or less than the counter
value, the PWM output is set LOW.
The pulse-width-ratio is therefore defined by the contents
of register PWM. The pulse-width-ratio will be in the range
frequency range of 92 Hz to 23.5 kHz.
By loading the PWM register with either 00H or FFH, the
PWM output can be retained at a constant LOW or HIGH
level respectively. When loading FFH into the PWM
register, the 8-bit counter will never actually reach this
value.
The PWM output pin is not shared with any other function.
.
) at the PWM output is given
PWM
handbook, full pagewidth
I
N
T
E
R
N
A
L
B
U
S
f
clk
PWMP
+
DIVIDE-BY-2
PWM
8-BIT COMPARATOR
8-BIT COUNTER
OUTPUT
BUFFER
Fig.12 Functional diagram of Pulse Width Modulated output (PWM).
PWM
MGM140
1998 Aug 2623
Loading...
+ 53 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.