PHILIPS P89LV51RD2FA

P89LV51RB2/RC2/RD2
8-bit 80C51 3 V low power 16/32/64 kB flash microcontroller
with 1 kB RAM
Rev. 05 — 15 December 2009
Product data sheet
1. General description
The P89LV51RB2/RC2/RD2 are 80C51 microcontrollers with 16/32/64 kB flash and
1024 B of data RAM.
A key feature of the P89LV51RB2/RC2/RD2 is its X2 mode option. The design engineer
can choose to run the application with the conventional 80C51 clock rate (12 clocks per
machine cycle) or select the X2 mode (six clocks per machine cycle) to achieve twice the
throughput at the same clock frequency. Another way to benefit from this feature is to keep
the same performance by reducing the clock frequency by half, thus dramatically reducing
the EMI.
The flash program memory supports both parallel programming and in serial ISP. Parallel
programming mode offers gang-programming at high speed, reducing programming costs
and time to market. ISP allows a device to be reprogrammed in the end product under
software control. The capability to field/update the application firmware makes a wide
range of applications possible.
The P89LV51RB2/RC2/RD2 is also capable of IAP, allowing the flash program memory to
be reconfigured even while the application is running.
2. Features
n
n
n
n
n
n
n
n
n
n
n
n
n
80C51 CPU
3 V operating voltage from 0 MHz to 33 MHz
16/32/64 kB of on-chip flash user code memory with ISP and IAP
Supports 12-clock (default) or 6-clock mode selection via software or ISP
SPI and enhanced UART
PCA with PWM and capture/compare functions
Four 8-bit I/O ports with three high-current port 1 pins (16 mA each)
Three 16-bit timers/counters
Programmable watchdog timer
Eight interrupt sources with four priority levels
Second DPTR register
Low EMI mode (ALE inhibit)
TTL- and CMOS-compatible logic levels
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
n Brownout detection
n Low power modes
u Power-down mode with external interrupt wake-up
u Idle mode
n PLCC44 and TQFP44 packages
3. Ordering information
Table 1.
Ordering information
Type number
Package
Name
Description
Version
P89LV51RB2BA
PLCC44
plastic leaded chip carrier; 44 leads
SOT187-2
P89LV51RC2FBC
TQFP44
plastic thin quad flat package; 44 leads; body 10 × 10 × 1.0 mm
SOT376-1
P89LV51RD2FA
PLCC44
plastic leaded chip carrier; 44 leads
SOT187-2
P89LV51RD2BBC
TQFP44
plastic thin quad flat package; 44 leads; body 10 × 10 × 1.0 mm
SOT376-1
3.1 Ordering options
Table 2.
Ordering options
Type number
Flash memory
Temperature range
Frequency
P89LV51RB2BA
16 kB
0 °C to +70 °C
0 MHz to 40 MHz
P89LV51RC2FBC
32 kB
−40 °C to +85 °C
P89LV51RD2FA
64 kB
−40 °C to +85 °C
P89LV51RD2BBC
64 kB
0 °C to +70 °C
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
2 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
4. Block diagram
P89LV51RB2/RC2/RD2
16/32/64 kB
CODE FLASH
P3[7:0]
HIGH PERFORMANCE
80C51 CPU
TXD
RXD
UART
internal
bus
1 kB
DATA RAM
TIMER 0
TIMER 1
T0
T1
PORT 3
TIMER 2
T2
T2EX
SPICLK
MOSI
MISO
SS
P2[7:0]
PORT 2
SPI
P1[7:0]
PORT 1
PCA
PROGRAMMABLE
COUNTER ARRAY
P0[7:0]
PORT 0
WATCHDOG TIMER
CRYSTAL
OR
RESONATOR
CEX[4:0]
XTAL1
OSCILLATOR
XTAL2
002aaa506
Fig 1.
Block diagram
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
3 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
5. Pinning information
40 P0.3/AD3
41 P0.2/AD2
42 P0.1/AD1
43 P0.0/AD0
n.c.
1
7
39 P0.4/AD4
P1.6/MISO/CEX3
8
38 P0.5/AD5
P1.7/SPICLK/CEX4
9
37 P0.6/AD6
RST 10
36 P0.7/AD7
35 EA
P89LV51RB2BA
P89LV51RD2FA
n.c. 12
34 n.c.
P2.4/A12 28
P2.3/A11 27
P2.1/A9 25
P2.2/A10 26
n.c. 23
P2.0/A8 24
29 P2.5/A13
VSS 22
30 P2.6/A14
P3.5/T1 17
XTAL1 21
31 P2.7/A15
P3.4/T0 16
XTAL2 20
32 PSEN
P3.3/INT1 15
P3.7/RD 19
33 ALE/PROG
P3.2/INT0 14
P3.6/WR 18
P3.1/TXD 13
002aaa509
PLCC44 pin configuration
P89LV51RB2_RC2_RD2_5
Product data sheet
44 VDD
P1.1/T2EX
P1.0/T2
P1.2/ECI
4
2
P1.3/CEX0
5
P1.5/MOSI/CEX2
P3.0/RXD 11
Fig 2.
3
P1.4/SS/CEX1
6
5.1 Pinning
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
4 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
34 P0.3/AD3
35 P0.2/AD2
36 P0.1/AD1
37 P0.0/AD0
38 VDD
1
33 P0.4/AD4
P1.6/MISO/CEX3
2
32 P0.5/AD5
P1.7/SPICLK/CEX4
3
31 P0.6/AD6
RST
4
30 P0.7/AD7
P3.0/RXD
5
n.c.
6
P3.1/TXD
7
27 ALE/PROG
P3.2/INT0
8
26 PSEN
P3.3/INT1
9
25 P2.7/A15
P3.4/T0 10
24 P2.6/A14
P3.5/T1 11
23 P2.5/A13
29 EA
P2.4/A12 22
P2.3/A11 21
28 n.c.
P2.2/A10 20
P2.1/A9 19
P2.0/A8 18
n.c. 17
VSS 16
XTAL1 15
XTAL2 14
P3.7/RD 13
P89LV51RC2FBC
P89LV51RD2BBC
002aaa508
TQFP44 pin configuration
P89LV51RB2_RC2_RD2_5
Product data sheet
39 n.c.
40 P1.0/T2
41 P1.1/T2EX
42 P1.2/ECI
P1.5/MOSI/CEX2
P3.6/WR 12
Fig 3.
43 P1.3/CEX0
44 P1.4/SS/CEX1
8-bit microcontrollers with 80C51 core
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
5 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
5.2 Pin description
Table 3.
P89LV51RB2/RC2/RD2 pin description
Symbol
Pin
TQFP44
37
43
P0.1/AD1
36
42
P0.2/AD2
35
41
P0.3/AD3
34
40
P0.4/AD4
33
39
P0.5/AD5
32
38
P0.6/AD6
31
37
P0.7/AD7
30
36
P1.0 to P1.7
P1.0/T2
P1.1/T2EX
P1.2/ECI
40
41
42
Description
I/O
Port 0: Port 0 is an 8-bit open drain bidirectional I/O port. Port 0
pins that have ‘1’s written to them float, and in this state can be
used as high-impedance inputs. Port 0 is also the multiplexed
low-order address and data bus during accesses to external
code and data memory. In this application, it uses strong internal
pull-ups when transitioning to ‘1’s. Port 0 also receives the code
bytes during the external host mode programming, and outputs
the code bytes during the external host mode verification.
External pull-ups are required during program verification or as a
general purpose I/O port.
I/O
P0.0 — Port 0 bit 0.
I/O
AD0 — Address/data bit 0.
I/O
P0.1 — Port 0 bit 1.
I/O
AD1 — Address/data bit 1.
I/O
P0.2 — Port 0 bit 2.
I/O
AD2 — Address/data bit 2.
I/O
P0.3 — Port 0 bit 3.
I/O
AD3 — Address/data bit 3.
I/O
P0.4 — Port 0 bit 4.
I/O
AD4 — Address/data bit 4.
I/O
P0.5 — Port 0 bit 5.
I/O
AD5 — Address/data bit 5.
I/O
P0.6 — Port 0 bit 6.
I/O
AD6 — Address/data bit 6.
I/O
P0.7 — Port 0 bit 7.
I/O
AD7 — Address/data bit 7.
I/O with
internal
pull-up
Port 1: Port 1 is an 8-bit bidirectional I/O port with internal
pull-ups. The Port 1 pins are pulled high by the internal pull-ups
when ‘1’s are written to them and can be used as inputs in this
state. As inputs, Port 1 pins that are externally pulled LOW will
source current (IIL) because of the internal pull-ups. P1.5, P1.6,
P1.7 have a high current drive of 16 mA. Port 1 also receives the
low-order address bytes during the external host mode
programming and verification.
I
P1.0 — Port 1 bit 0.
I/O
T2 — External count input to Timer/counter 2 or Clock-out from
Timer/counter 2.
PLCC44
P0.0 to P0.7
P0.0/AD0
Type
2
3
4
I/O
P1.1 — Port 1 bit 1.
I
T2EX: Timer/counter 2 capture/reload trigger and direction
control input.
I/O
P1.2 — Port 1 bit 2.
I
ECI — External clock input. This signal is the external clock input
for the PCA.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
6 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 3.
P89LV51RB2/RC2/RD2 pin description …continued
Symbol
P1.3/CEX0
P1.4/SS/CEX1
P1.5/MOSI/
CEX2
P1.6/MISO/
CEX3
P1.7/SPICLK/
CEX4
Pin
TQFP44
PLCC44
43
5
44
1
2
3
6
7
8
9
P2.0 to P2.7
P2.0/A8
P2.1/A9
P2.2/A10
P2.3/A11
P2.4/A12
P2.5/A13
P2.6/A14
18
19
20
21
22
23
24
24
25
26
27
28
29
30
Type
Description
I/O
P1.3 — Port 1 bit 3.
I/O
CEX0 — Capture/compare external I/O for PCA Module 0. Each
capture/compare module connects to a Port 1 pin for external
I/O. When not used by the PCA, this pin can handle standard I/O.
I/O
P1.4 — Port 1 bit 4.
I
SS — Slave port select input for SPI.
I/O
CEX1 — Capture/compare external I/O for PCA Module 1.
I/O
P1.5 — Port 1 bit 5.
I/O
MOSI — Master Output Slave Input for SPI.
I/O
CEX2 — Capture/compare external I/O for PCA Module 2.
I/O
P1.6 — Port 1 bit 6.
I/O
MISO — Master Input Slave Output for SPI.
I/O
CEX3 — Capture/compare external I/O for PCA Module 3.
I/O
P1.7 — Port 1 bit 7.
I/O
SPICLK — Serial clock input/output for SPI.
I/O
CEX4 — Capture/compare external I/O for PCA Module 4.
I/O with
internal
pull-up
Port 2: Port 2 is an 8-bit bidirectional I/O port with internal
pull-ups. Port 2 pins are pulled HIGH by the internal pull-ups
when ‘1’s are written to them and can be used as inputs in this
state. As inputs, Port 2 pins that are externally pulled LOW will
source current (IIL) because of the internal pull-ups. Port 2 sends
the high-order address byte during fetches from external
program memory and during accesses to external Data Memory
that use 16-bit address (MOVX@DPTR). In this application, it
uses strong internal pull-ups when transitioning to ‘1’s. Port 2
also receives some control signals and a partial of high-order
address bits during the external host mode programming and
verification.
I/O
P2.0 — Port 2 bit 0.
O
A8 — Address bit 8.
I/O
P2.1 — Port 2 bit 1.
O
A9 — Address bit 9.
I/O
P2.2 — Port 2 bit 2.
O
A10 — Address bit 10.
I/O
P2.3 — Port 2 bit 3.
O
A11 — Address bit 11.
I/O
P2.4 — Port 2 bit 4.
O
A12 — Address bit 12.
I/O
P2.5 — Port 2 bit 5.
O
A13 — Address bit 13.
I/O
P2.6 — Port 2 bit 6.
O
A14 — Address bit 14.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
7 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 3.
P89LV51RB2/RC2/RD2 pin description …continued
Symbol
P2.7/A15
Pin
TQFP44
PLCC44
25
31
P3.0 to P3.7
P3.0/RXD
5
11
P3.1/TXD
7
13
P3.2/INT0
8
14
P3.3/INT1
9
15
P3.4/T0
10
16
P3.5/T1
11
17
Type
Description
I/O
P2.7 — Port 2 bit 7.
O
A15 — Address bit 15.
I/O with
internal
pull-up
Port 3: Port 3 is an 8-bit bidirectional I/O port with internal
pull-ups. Port 3 pins are pulled HIGH by the internal pull-ups
when ‘1’s are written to them and can be used as inputs in this
state. As inputs, Port 3 pins that are externally pulled LOW will
source current (IIL) because of the internal pull-ups. Port 3 also
receives some control signals and a partial of high-order address
bits during the external host mode programming and verification.
I
P3.0 — Port 3 bit 0.
I
RXD — Serial input port.
O
P3.1 — Port 3 bit 1.
O
TXD — Serial output port.
I
P3.2 — Port 3 bit 2.
I
INT0 — External interrupt 0 input.
I
P3.3 — Port 3 bit 3.
I
INT1 — External interrupt 1 input.
I/O
P3.4 — Port 3 bit 4.
I
T0 — External count input to Timer/counter 0.
I/O
P3.5 — Port 3 bit 5.
I
T1 — External count input to Timer/counter 1.
P3.6 — Port 3 bit 6.
P3.6/WR
12
18
O
O
WR — External data memory write strobe.
P3.7/RD
13
19
O
P3.7 — Port 3 bit 7.
O
RD — External data memory read strobe.
PSEN
26
32
I/O
Program Store Enable: PSEN is the read strobe for external
program memory. When the device is executing from internal
program memory, PSEN is inactive (HIGH). When the device is
executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN
activations are skipped during each access to external data
memory. A forced HIGH-to-LOW input transition on the PSEN pin
while the RST input is continually held HIGH for more than 10
machine cycles will cause the device to enter external host mode
programming.
RST
4
10
I
Reset: While the oscillator is running, a HIGH logic state on this
pin for two machine cycles will reset the device. If the PSEN pin
is driven by a HIGH-to-LOW input transition while the RST input
pin is held HIGH, the device will enter the external host mode,
otherwise the device will enter the normal operation mode.
EA
29
35
I
External Access Enable: EA must be connected to VSS in order
to enable the device to fetch code from the external program
memory. EA must be strapped to VDD for internal program
execution. The EA pin can tolerate a high voltage of 12 V.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
8 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 3.
P89LV51RB2/RC2/RD2 pin description …continued
Symbol
Pin
Type
Description
33
I/O
Address Latch Enable: ALE is the output signal for latching the
low byte of the address during an access to external memory.
This pin is also the programming pulse input (PROG) for flash
programming. Normally the ALE[1] is emitted at a constant rate of
1⁄ the crystal frequency[2] and can be used for external timing
6
and clocking. One ALE pulse is skipped during each access to
external data memory. However, if bit AO is set to ‘1’, ALE is
disabled.
6, 17, 28,
39
1, 12, 23,
34
I/O
not connected
XTAL1
15
21
I
Crystal 1: Input to the inverting oscillator amplifier and input to
the internal clock generator circuits.
XTAL2
14
20
O
Crystal 2: Output from the inverting oscillator amplifier.
VDD
38
44
I
Power supply
VSS
16
22
I
Ground
TQFP44
PLCC44
ALE/PROG
27
n.c.
[1]
ALE loading issue: When ALE pin experiences higher loading (> 30 pF) during the reset, the microcontroller may accidentally enter into
modes other than normal working mode. The solution is to connect a pull-up resistor of 3 kΩ to 50 kΩ from pin ALE to VDD.
[2]
For 6-clock mode, ALE is emitted at 1⁄3 of crystal frequency.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
9 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
6. Functional description
6.1 Special function registers
Remark: SFR accesses are restricted in the following ways:
• User must not attempt to access any SFR locations not defined.
• Accesses to any defined SFR locations must be strictly for the functions for the SFRs.
• SFR bits labeled ‘-’, ‘0’ or ‘1’ can only be written and read as follows:
– ‘-’ Unless otherwise specified, must be written with ‘0’, but can return any value
when read (even if it was written with ‘0’). It is a reserved bit and may be used in
future derivatives.
– ‘0’ must be written with ‘0’, and will return a ‘0’ when read.
– ‘1’ must be written with ‘1’, and will return a ‘1’ when read.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
10 of 76
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx
xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx
NXP Semiconductors
P89LV51RB2_RC2_RD2_5
Product data sheet
Table 4.
Special function registers
* Indicates SFRs that are bit addressable.
Name
Description
SFR
addr.
Bit address
Bit functions and addresses
MSB
LSB
E7
E6
E5
E4
E3
E2
E1
E0
ACC*
Accumulator
E0H
AUXR
Auxiliary function register
8EH
-
-
-
-
-
-
EXTRAM
AO
AUXR1
Auxiliary function register 1
A2H
-
-
-
-
GF2
0
-
DPS
F7
F6
F5
F4
F3
F2
F1
F0
Bit address
F0H
CCAP0H
Module 0 Capture HIGH
FAH
CCAP1H
Module 1 Capture HIGH
FBH
CCAP2H
Module 2 Capture HIGH
FCH
CCAP3H
Module 3 Capture HIGH
FDH
CCAP4H
Module 4 Capture HIGH
FEH
CCAP0L
Module 0 Capture LOW
EAH
CCAP1L
Module 1 Capture LOW
EBH
CCAP2L
Module 2 Capture LOW
ECH
CCAP3L
Module 3 Capture LOW
EDH
CCAP4L
Module 4 Capture LOW
EEH
CCAPM0
Module 0 Mode
DAH
-
ECOM_0
CAPP_0
CAPN_0
MAT_0
TOG_0
PWM_0
ECCF_0
CCAPM1
Module 1 Mode
DBH
-
ECOM_1
CAPP_1
CAPN_1
MAT_1
TOG_1
PWM_1
ECCF_1
CCAPM2
Module 2 Mode
DCH
-
ECOM_2
CAPP_2
CAPN_2
MAT_2
TOG_2
PWM_2
ECCF_2
CCAPM3
Module 3 Mode
DDH
-
ECOM_3
CAPP_3
CAPN_3
MAT_3
TOG_3
PWM_3
ECCF_3
CCAPM4
Module 4 Mode
DEH
-
ECOM_4
CAPP_4
CAPN_4
MAT_4
TOG_4
PWM_4
ECCF_4
DF
DE
DD
DC
DB
DA
D9
D8
CF
CR
-
CCF4
CCF3
CCF2
CCF1
CCF0
CIDL
WDTE
-
-
-
CPS1
CPS0
ECF
Bit address
11 of 76
© NXP B.V. 2009. All rights reserved.
CCON*
PCA Counter Control
D8H
CH
PCA Counter HIGH
F9H
CL
PCA Counter LOW
E9H
CMOD
PCA Counter Mode
D9H
DPTR
Data Pointer (2 B)
DPH
Data Pointer HIGH
83H
DPL
Data Pointer LOW
82H
8-bit microcontrollers with 80C51 core
B register
P89LV51RB2/RC2/RD2
Rev. 05 — 15 December 2009
B*
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx
xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx
Name
FST
Description
SFR
addr.
Flash Status Register
B6
Bit address
IEN0*
Interrupt Enable 0
A8H
Bit address
IEN1*
Interrupt Enable 1
E8H
Bit address
Bit functions and addresses
MSB
LSB
-
SB
-
-
EDC
-
-
-
AF
AE
AD
AC
AB
AA
A9
A8
EA
EC
ET2
ES
ET1
EX1
ET0
EX0
EF
EE
ED
EC
EB
EA
E9
E8
-
-
-
-
EBO
-
-
-
BF
BE
BD
BC
BB
BA
B9
B8
IP0*
Interrupt Priority
B8H
-
PPC
PT2
PS
PT1
PX1
PT0
PX0
IP0H
Interrupt Priority 0 HIGH
B7H
-
PPCH
PT2H
PSH
PT1H
PX1H
PT0H
PX0H
FF
FE
FD
FC
FB
FA
F9
F8
IP1*
Interrupt Priority 1
F8H
-
-
-
PBO
-
-
-
-
IP1H
Interrupt Priority 1 HIGH
F7H
-
-
-
PBOH
-
-
-
-
B1H
-
-
-
-
-
-
SWR
BSEL
Bit address
Bit address
P0*
Port 0
80H
Bit address
P1*
Port 1
90H
P2*
Port 2
A0H
Bit address
86
85
84
83
82
81
80
AD6
AD5
AD4
AD3
AD2
AD1
AD0
97
96
95
94
93
92
91
90
CEX4/
SPICLK
CEX3/
MISO
CEX2/
MOSI
CEX1/SS
CEX0
ECI
T2EX
T2
A7
A6
A5
A4
A3
A2
A1
A0
A15
A14
A13
A12
A11
A10
A9
A8
B7
B6
B5
B4
B3
B2
B1
B0
P3*
Port 3
B0H
RD
WR
T1
T0
INT1
INT0
TXD
RXD
PCON
Power Control Register
87H
SMOD1
SMOD0
BOF
POF
GF1
GF0
PD
IDL
D7
D6
D5
D4
D3
D2
D1
D0
CY
AC
F0
RS1
RS0
OV
F1
P
9F
9E
9D
9C
9B
9A
99
98
SM0/FE
SM1
SM2
REN
TB8
RB8
TI
RI
Bit address
12 of 76
© NXP B.V. 2009. All rights reserved.
PSW*
Program Status Word
D0H
RCAP2H
Timer2 Capture HIGH
CBH
RCAP2L
Timer2 Capture LOW
CAH
Bit address
SCON*
Serial Port Control
98H
SBUF
Serial Port Data Buffer Register
99H
8-bit microcontrollers with 80C51 core
Bit address
87
AD7
P89LV51RB2/RC2/RD2
Rev. 05 — 15 December 2009
FCF
NXP Semiconductors
P89LV51RB2_RC2_RD2_5
Product data sheet
Table 4.
Special function registers …continued
* Indicates SFRs that are bit addressable.
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxx x x x xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xx xx
xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxx xxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxx x x
xxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxx xxx
Name
Description
SFR
addr.
SADDR
Serial Port Address Register
A9H
SADEN
Serial Port Address Enable
B9H
Bit address
Bit functions and addresses
MSB
LSB
87[1]
86[1]
85[1]
84[1]
83[1]
82[1]
81[1]
80[1]
SPCTL
SPI Control Register
D5H
SPIE
SPEN
DORD
MSTR
CPOL
CPHA
PSC1
PSC0
SPCFG
SPI Configuration Register
AAH
SPIF
WCOL
-
-
-
-
-
-
SPDAT
SPI Data
86H
SP
Stack Pointer
81H
8F
8E
8D
8C
8B
8A
89
88
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
CF
CE
CD
CC
CB
CA
C9
C8
Bit address
TCON*
Timer Control Register
88H
Timer2 Control Register
C8H
TF2
EXF2
RCLK
TCLK
EXEN2
TR2
C/T2
CP/RL2
T2MOD
Timer2 Mode Control
C9H
-
-
ENT2
-
-
-
T2OE
DCEN
TH0
Timer 0 HIGH
8CH
TH1
Timer 1 HIGH
8DH
TH2
Timer 2 HIGH
CDH
TL0
Timer 0 LOW
8AH
TL1
Timer 1 LOW
8BH
TL2
Timer 2 LOW
CCH
TMOD
Timer 0 and 1 Mode
89H
T1GATE
T1C/T
T1M1
T1M0
T0GATE
T0C/T
T0M1
T0M0
WDTC
Watchdog Timer Control
C0H
-
-
-
WDOUT
WDRE
WDTS
WDT
SWDT
WDTD
Watchdog Timer Data/Reload
85H
[1]
Unimplemented bits in SFRs (labeled ’-’) are ‘X’s (unknown) at all times. Unless otherwise specified, ‘1’s should not be written to these bits since they may be used for other
purposes in future derivatives. The reset values shown for these bits are ‘0’s although they are unknown when read.
13 of 76
© NXP B.V. 2009. All rights reserved.
8-bit microcontrollers with 80C51 core
T2CON*
P89LV51RB2/RC2/RD2
Rev. 05 — 15 December 2009
Bit address
NXP Semiconductors
P89LV51RB2_RC2_RD2_5
Product data sheet
Table 4.
Special function registers …continued
* Indicates SFRs that are bit addressable.
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
6.2 Memory organization
The device has separate address spaces for program and data memory.
6.2.1 Flash program memory bank selection
There are two internal flash memory blocks in the device. Block 0 has 16/32/64 kB and is
organized as 128/256/512 sectors, each sector consists of 128 B. Block 1 contains the
IAP/ISP routines and may be enabled such that it overlays the first 8 kB of the user code
memory. The overlay function is controlled by the combination of the Software Reset Bit
(SWR) at FCF.1 and the Bank Select Bit (BSEL) at FCF.0. The combination of these bits
and the memory source used for instructions is shown in Table 5.
Table 5.
Code memory bank selection
SWR (FCF.1)
BSEL (FCF.0)
Addresses from
0000H to 1FFFH
Addresses above
1FFFH
0
0
boot code (in block 1)
user code (in block 0)
0
1
user code (in block 0)
1
0
1
1
Access to the IAP routines in block 1 may be enabled by clearing the BSEL bit (FCF.0),
provided that the SWR bit (FCF.1) is cleared. Following a power-on sequence, the boot
code is automatically executed and attempts to autobaud to a host. If no autobaud occurs
within approximately 400 ms and the SoftICE flag is not set, control will be passed to the
user code. A software reset is used to accomplish this control transfer and as a result the
SWR bit will remain set. Therefore the user's code will need to clear the SWR bit in
order to access the IAP routines in block 1. However, caution must be taken when
dynamically changing the BSEL bit. Since this will cause different physical memory to be
mapped to the logical program address space, the user must avoid clearing the BSEL bit
when executing user code within the address range 0000H to 1FFFH.
6.2.2 Power-on reset code execution
At initial power up, the port pins will be in a random state until the oscillator has started
and the internal reset algorithm has weakly pulled all pins high. Powering up the device
without a valid reset could cause the MCU to start executing instructions from an
indeterminate location. Such undefined states may inadvertently corrupt the code in the
flash. A system reset will not affect the 1 kB of on-chip RAM while the device is running,
however, the contents of the on-chip RAM during power up are indeterminate.
When power is applied to the device, the RST pin must be held high long enough for the
oscillator to start up (usually several milliseconds for a low frequency crystal), in addition
to two machine cycles for a valid power-on reset. An example of a method to extend the
RST signal is to implement a RC circuit by connecting the RST pin to VDD through a 10 µF
capacitor and to VSS through an 8.2 kΩ resistor as shown in Figure 4. Note that if an RC
circuit is used, provision should be made to ensure the VDD rise time does not exceed
1 ms and the oscillator start-up time does not exceed 10 ms.
For a low frequency oscillator with slow start-up time the reset signal must be extended in
order to account for the slow start-up time. This method maintains the necessary
relationship between VDD and RST to avoid programming at an indeterminate location,
which may cause corruption in the Flash code. The power-on detection is designed to
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
14 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
work during initial power up, before the voltage reaches the brownout detection level. The
POF flag in the PCON register is set to indicate an initial power up condition. The POF
flag will remain active until cleared by software.
Following a power-on or external reset the P89LV51RB2/RC2/RD2 will force the SWR and
BSEL bits (FCF[1:0]) to 00. This causes the boot block to be mapped into the lower 8 kB
of code memory and the device will execute the ISP code in the boot block and attempt to
autobaud to the host. If the autobaud is successful the device will remain in ISP mode. If,
after approximately 400 ms, the autobaud is unsuccessful the boot block code will check
to see if the SoftICE flag is set (from a previous programming operation). If the SoftICE
flag is set the device will enter SoftICE mode. If the SoftICE flag is cleared, the boot code
will execute a software reset causing the device to execute the user code from block 0
starting at address 0000H. Note that an external reset applied to the RST pin has the
same effect as a power-on reset.
VDD
10 µF
VDD
RST
8.2 kΩ
C2
XTAL2
XTAL1
C1
002aaa543
Fig 4.
Power-on reset circuit
6.2.3 Software reset
A software reset is executed by changing the SWR bit (FCF.1) from ‘0’ to ‘1’. A software
reset will reset the program counter to address 0000H and force both the SWR and BSEL
bits (FCF[1:0]) to 10. This will result in the lower 8 kB of the user code memory being
mapped into the user code memory space. Thus the user's code will be executed starting
at address 0000H. A software reset will not change bit WDTC.2 or RAM data. Other SFRs
will be set to their reset values.
6.2.4 Brownout detect reset
The device includes a brownout detection circuit to protect the system from severe supply
voltage fluctuations. The P89LV51RB2/RC2/RD2's brownout detection threshold is 2.35 V.
When VDD drops below this voltage threshold, the brownout detect triggers the circuit to
generate a brownout interrupt but the CPU still runs until the supplied voltage returns to
the brownout detection voltage Vbo. The default operation for a brownout detection is to
cause a processor reset.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
15 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
VDD must stay below Vbo at least four oscillator clock periods before the brownout
detection circuit will respond.
Brownout interrupt can be enabled by setting the EBO bit (IEN1.3). If EBO bit is set and a
brownout condition occurs, a brownout interrupt will be generated to execute the program
at location 004BH. It is required that the EBO bit is cleared by software after the brownout
interrupt is serviced. Clearing EBO bit when the brownout condition is active will properly
reset the device. If brownout interrupt is not enabled, a brownout condition will reset the
program to resume execution at location 0000H. A brownout detect reset will clear the
BSEL bit (FCF.0) but will not change the SWR bit (FCF.1) and therefore will not change the
banking of the lower 8 kB of user code memory space.
6.2.5 Watchdog reset
Like a brownout detect reset, the watchdog timer reset will clear the BSEL bit (FCF.0) but
will not change the SWR bit (FCF.1) and therefore will not change the banking of the lower
8 kB of user code memory space.
The state of the SWR and BSEL bits after different types of resets is shown in Table 6.
This results in the code memory bank selections as shown.
Table 6.
Effects of reset sources on bank selection
Reset source
SWR bit result
(FCF.1)
BSEL bit result
(FCF.0)
Addresses from 0000H to
1FFFH
Addresses above
1FFFH
External reset
0
0
Boot code (in block 1)
User code (in block 0)
x
0
Retains state of SWR bit. If
SWR, BSEL = 00 then uses
boot code. If SWR,
BSEL = 10 then uses user
code.
1
0
User code (in block 0)
Power-on reset
Watchdog reset
Brownout detect reset
Software reset
6.2.6 Data RAM memory
The data RAM has 1024 B of internal memory. The device can also address up to 64 kB
for external data memory.
6.2.7 Expanded data RAM addressing
The P89LV51RB2/RC2/RD2 has 1 kB of RAM. See Figure 5 “Internal and external data
memory structure” on page 19.
The device has four sections of internal data memory:
1. The lower 128 B of RAM (00H to 7FH) are directly and indirectly addressable.
2. The higher 128 B of RAM (80H to FFH) are indirectly addressable.
3. The special function registers (80H to FFH) are directly addressable only.
4. The expanded RAM of 768 B (00H to 2FFH) is indirectly addressable by the move
external instruction (MOVX) and clearing the EXTRAM bit (see ‘Auxiliary function
Register’ (AUXR) in Table 4 “Special function registers” on page 11).
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
16 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Since the upper 128 B occupy the same addresses as the SFRs, the RAM must be
accessed indirectly. The RAM and SFRs space are physically separate even though they
have the same addresses.
Table 7.
AUXR - Auxiliary register (address 8EH) bit allocation
Not bit addressable; reset value 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
-
-
-
-
-
EXTRAM
AO
Table 8.
AUXR - Auxiliary register (address 8EH) bit descriptions
Bit
Symbol
Description
7 to 2
-
Reserved for future use. Should be set to ‘0’ by user programs.
1
EXTRAM
Internal/External RAM access using MOVX @Ri/@DPTR.
When ‘0’, core attempts to access internal XRAM with address
specified in MOVX instruction. If address supplied with this instruction
exceeds on-chip available XRAM, off-chip XRAM is going to be
selected and accessed.
When ‘1’, every MOVX @Ri/@DPTR instruction targets external data
memory by default.
0
AO
ALE off: disables/enables ALE. AO = 0 results in ALE emitted at a
constant rate of 1⁄2 the oscillator frequency. In case of AO = 1, ALE is
active only during a MOVX or MOVC.
When instructions access addresses in the upper 128 B (above 7FH), the MCU
determines whether to access the SFRs or RAM by the type of instruction given. If it is
indirect, then RAM is accessed. If it is direct, then an SFR is accessed. See the examples
below.
Indirect access:
MOV@R0, #data; R0 contains 90H
Register R0 points to 90H which is located in the upper address range. Data in ‘#data’ is
written to RAM location 90H rather than port 1.
Direct access:
MOV90H, #data; write data to P1
Data in ‘#data’ is written to port 1. Instructions that write directly to the address, write to
the SFRs.
To access the expanded RAM, the EXTRAM bit must be cleared and MOVX instructions
must be used. The extra 768 B of memory is physically located on the chip and logically
occupies the first 768 B of external memory (addresses 000H to 2FFH).
When EXTRAM = 0, the expanded RAM is indirectly addressed using the MOVX
instruction in combination with any of the registers R0, R1 of the selected bank or DPTR.
Accessing the expanded RAM does not affect ports P0, P3.6 (WR), P3.7 (RD), or P2.
With EXTRAM = 0, the expanded RAM can be accessed as in the following example.
Expanded RAM access (indirect addressing only):
MOVX@DPTR, A DPTR contains 0A0H
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
17 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
DPTR points to 0A0H and data in ‘A’ is written to address 0A0H of the expanded RAM
rather than external memory. Access to external memory higher than 2FFH using the
MOVX instruction will access external memory (0300H to FFFFH) and will perform in the
same way as the standard 8051, with P0 and P2 as data/address bus, and P3.6 and P3.7
as write and read timing signals.
When EXTRAM = 1, MOVX@Ri and MOVX@DPTR will be similar to the standard 8051.
Using MOVX @Ri provides an 8-bit address with multiplexed data on Port 0. Other output
port pins can be used to output higher order address bits. This provides external paging
capabilities. Using MOVX@DPTR generates a 16-bit address. This allows external
addressing up to 64 kB. Port 2 provides the high-order eight address bits (DPH), and
Port 0 multiplexes the low-order eight address bits (DPL) with data. Both MOVX@Ri and
MOVX@DPTR generates the necessary read and write signals (P3.6, - WR and P3.7, RD) for external memory use. Table 9 shows external data memory RD, WR operation
with EXTRAM bit.
The stack pointer (SP) can be located anywhere within the 256 B of internal RAM (lower
128 B and upper 128 B). The stack pointer may not be located in any part of the expanded
RAM.
Table 9.
External data memory RD, WR with EXTRAM bit[1]
Register AUXR
MOVX @DPTR, A or MOVX A, @DPTR
ADDR < 0300H
ADDR ≥ 0300H
ADDR = any
EXTRAM = 0
RD/WR not asserted
RD/WR asserted
RD/WR not asserted
EXTRAM = 1
RD/WR asserted
RD/WR asserted
RD/WR asserted
[1]
Access limited to Expanded RAM address within 0 to 0FFH; cannot access 100H to 02FFH.
P89LV51RB2_RC2_RD2_5
Product data sheet
MOVX @Ri, A or
MOVX A, @Ri
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
18 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
2FFH
EXPANDED
RAM
768 B
FFH
80H
7FH
000H
(INDIRECT
ADDRESSING)
00H
FFFFH
(INDIRECT
ADDRESSING)
UPPER 128 B
INTERNAL RAM
FFH
80H
(DIRECT
ADDRESSING)
SPECIAL
FUNCTION
REGISTERS (SFRs)
LOWER 128 B
INTERNAL RAM
(INDIRECT AND
DIRECT
ADDRESSING)
(INDIRECT
ADDRESSING)
FFFFH
(INDIRECT
ADDRESSING)
EXTERNAL
DATA
MEMORY
EXTERNAL
DATA
MEMORY
0300H
2FFH
EXPANDED RAM
0000H
000H
EXTRAM = 0
EXTRAM = 1
002aaa517
Fig 5.
Internal and external data memory structure
6.2.8 Dual data pointers
The device has two 16-bit data pointers. The DPTR Select (DPS) bit in AUXR1
determines which of the two data pointers is accessed. When DPS = 0, DPTR0 is
selected; when DPS = 1, DPTR1 is selected. Quickly switching between the two data
pointers can be accomplished by a single INC instruction on AUXR1 (see Figure 6).
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
19 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
AUXR1 / bit0
DPS
DPTR1
DPS = 0 → DPTR0
DPS = 1 → DPTR1
DPTR0
DPH
83H
DPL
82H
external data memory
002aaa518
Fig 6. Dual data pointer organization
Table 10. AUXR1 - Auxiliary register 1 (address A2H) bit allocation
Not bit addressable; reset value 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
-
-
-
GF2
0
-
DPS
Table 11.
AUXR1 - Auxiliary register 1 (address A2H) bit descriptions
Bit
Symbol
Description
7 to 4
-
Reserved for future use. Should be set to ‘0’ by user programs.
3
GF2
General purpose user-defined flag.
2
0
This bit contains a hard-wired ‘0’. Allows toggling of the DPS bit by
incrementing AUXR1, without interfering with other bits in the register.
1
-
Reserved for future use. Should be set to ‘0’ by user programs.
0
DPS
Data pointer select. Chooses one of two Data Pointers for use by the
program. See text for details.
6.3 Flash memory IAP
6.3.1 Flash organization
The P89LV51RB2/RC2/RD2 program memory consists of a 16/32/64 kB block. ISP
capability, in a second 8 kB block, is provided to allow the user code to be programmed
in-circuit through the serial port. There are three methods of erasing or programming of
the flash memory that may be used. First, the flash may be programmed or erased in the
end-user application by calling low-level routines through a common entry point (IAP).
Second, the on-chip ISP bootloader may be invoked. This ISP bootloader will, in turn, call
low-level routines through the same common entry point that can be used by the end-user
application. Third, the flash may be programmed or erased using the parallel method by
using a commercially available EPROM programmer which supports this device.
6.3.2 Boot block (block 1)
When the microcontroller programs its own flash memory, all of the low level details are
handled by code that is contained in block 1. A user program calls the common entry point
in the block 1 with appropriate parameters to accomplish the desired operation. Boot block
operations include erase user code, program user code, program security bits, etc.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
20 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
A chip-erase operation can be performed using a commercially available parallel
programer. This operation will erase the contents of this boot block and it will be
necessary for the user to reprogram this boot block (block 1) with the NXP-provided
ISP/IAP code in order to use the ISP or IAP capabilities of this device. Go to
http://www.nxp.com/support for questions or to obtain the hex file for this device.
6.3.3 ISP
ISP is performed without removing the microcontroller from the system. The ISP facility
consists of a series of internal hardware resources coupled with internal firmware to
facilitate remote programming of the P89LV51RB2/RC2/RD2 through the serial port. This
firmware is provided by NXP and embedded within each P89LV51RB2/RC2/RD2 device.
The NXP ISP facility has made in-circuit programming in an embedded application
possible with a minimum of additional expense in components and circuit board area. The
ISP function uses five pins (VDD, VSS, TXD, RXD, and RST). Only a small connector
needs to be available to interface your application to an external circuit in order to use this
feature.
6.3.4 Using ISP
The ISP feature allows for a wide range of baud rates to be used in your application,
independent of the oscillator frequency. It is also adaptable to a wide range of oscillator
frequencies. This is accomplished by measuring the bit-time of a single bit in a received
character. This information is then used to program the baud rate in terms of timer counts
based on the oscillator frequency. The ISP feature requires that an initial character (an
uppercase U) be sent to the P89LV51RB2/RC2/RD2 to establish the baud rate. The ISP
firmware provides auto-echo of received characters. Once baud rate initialization has
been performed, the ISP firmware will only accept Intel Hex-type records. Intel Hex
records consist of ASCII characters used to represent hexadecimal values and are
summarized below:
:NNAAAARRDD..DDCC<crlf>
In the Intel Hex record, the ‘NN’ represents the number of data bytes in the record. The
P89LV51RB2/RC2/RD2 will accept up to 32 data bytes. The ‘AAAA’ string represents the
address of the first byte in the record. If there are zero bytes in the record, this field is often
set to 0000. The ‘RR’ string indicates the record type. A record type of ‘00’ is a data
record. A record type of ‘01’ indicates the end-of-file mark. In this application, additional
record types will be added to indicate either commands or data for the ISP facility.
The maximum number of data bytes in a record is limited to 32 (decimal). ISP commands
are summarized in Table 12. As a record is received by the P89LV51RB2/RC2/RD2, the
information in the record is stored internally and a checksum calculation is performed. The
operation indicated by the record type is not performed until the entire record has been
received. Should an error occur in the checksum, the P89LV51RB2/RC2/RD2 will send an
‘X’ out the serial port indicating a checksum error. If the checksum calculation is found to
match the checksum in the record, then the command will be executed. In most cases,
successful reception of the record will be indicated by transmitting a ‘.’ character out the
serial port.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
21 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 12.
ISP hex record formats
Record type
Command/data function
00
Program User Code Memory
:nnaaaa00dd..ddcc
Where:
nn = number of bytes to program
aaaa = address
dd..dd = data bytes
cc = checksum
Example:
:100000000102030405006070809cc
01
End of File (EOF), no operation
:xxxxxx01cc
Where:
xxxxxx = required field but value is a ‘don’t care’
cc = checksum
Example:
:00000001FF
02
Set SoftICE mode
Following the next reset the device will enter the SoftICE mode. Will erase user
code memory, and erase device serial number.
:00000002cc
Where:
xxxxxx = required field but value is a ‘don’t care’
cc = checksum
Example:
:00000002FE
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
22 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 12.
ISP hex record formats …continued
Record type
Command/data function
03
Miscellaneous Write functions
:nnxxxx03ffssddcc
Where:
nn = number of bytes in the record
xxxx = required field but value is a ‘don’t care’
ff = subfunction code
ss = selection code
dd = data (if needed)
cc = checksum
Subfunction code = 01 (Erase block 0)
ff = 01
Subfunction code = 05 (Program security bit, Double Clock)
ff = 05
ss = 01 program security bit
ss = 05 program double clock bit
Subfunction code = 08 (Erase sector, 128 B)
ff = 08
ss = high byte of sector address (A15:8)
dd = low byte of sector address (A7, A6:0 ]= 0)
Example:
:0300000308E000F2 (erase sector at E000H)
04
Display Device Data or Blank Check
:05xxxx04sssseeeeffcc
Where
05 = number of bytes in the record
xxxx = required field but value is a ‘don’t care’
04 = function code for display or blank check
ssss = starting address, MSB first
eeee = ending address, MSB first
ff = subfunction
00 = display data
01 = blank check
cc = checksum
Subfunction codes:
Example:
:0500000400001FFF00D9 (display from 0000H to 1FFFH)
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
23 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 12.
ISP hex record formats …continued
Record type
Command/data function
05
Miscellaneous Read functions
:02xxxx05ffsscc
Where:
02 = number of bytes in the record
xxxx = required field but value is a ‘don’t care’
05 = function code for misc read
ffss = subfunction and selection code
0000 = read manufacturer id
0001 = read device id 1
0002 = read boot code version
0700 = read security bit (00 SoftICE serial number match 0 SB 0 Double Clock)
cc = checksum
Example:
:020000050000F9 (display manufacturer id)
06
Direct load of baud rate
:02xxxx06HHLLcc
Where:
02 = number of bytes in the record
xxxx = required field but value is a ‘don’t care’
HH = high byte of timer
LL = low byte of timer
cc = checksum
Example:
:02000006FFFFcc (load T2 = FFFF)
07
Reset serial number, erase user code, clear SoftICE mode
:xxxxxx07cc
Where:
xxxxxx = required field but value is a ‘don’t care’
07 = reset serial number function
cc = checksum
Example:
:00000007F9
08
Verify serial number
:nnxxxx08ss..sscc
Where:
xxxxxx = required field but value is a ‘don’t care’
08 = verify serial number function
ss..ss = serial number contents
cc = checksum
Example:
:03000008010203EF (verify serial number = 010203)
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
24 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 12.
ISP hex record formats …continued
Record type
Command/data function
09
Write serial number
:nnxxxx09ss..sscc
Where:
xxxxxx = required field but value is a ‘don’t care’
09 = write serial number function
ss..ss = serial number contents
cc = checksum
Example:
:03000009010203EE (write serial number = 010203)
0A
Display serial number
:xxxxxx0Acc
Where:
xxxxxx = required field but value is a ‘don’t care’
0A = display serial number function
cc = checksum
Example:
:0000000AF6
0B
Reset and run user code
:xxxxxx0Bcc
Where:
xxxxxx = required field but value is a ‘don’t care’
0B = reset and run user code
cc = checksum
Example:
:0000000BF5
6.3.5 Using the serial number
This device has the option of storing a 31 B serial number along with the length of the
serial number (for a total of 32 B) in a non-volatile memory space. When ISP mode is
entered, the serial number length is evaluated to determine if the serial number is in use.
If the length of the serial number is programmed to either 00H or FFH, the serial number is
considered not in use. If the serial number is in use, reading, programming, or erasing of
the user code memory or the serial number is blocked until the user transmits a ‘verify
serial number’ record containing a serial number and length that matches the serial
number and length previously stored in the device. The user can reset the serial number
to all zeros and set the length to zero by sending the ‘reset serial number' record. In
addition, the ‘reset serial number’ record will also erase all user code.
6.3.6 IAP method
Several IAP calls are available for use by an application program to permit selective
erasing, reading and programming of flash sectors, security bit, configuration bytes, and
device id. All calls are made through a common interface, PGM_MTP. The programming
functions are selected by setting up the microcontroller’s registers before making a call to
PGM_MTP at 1FF0H. The IAP calls are shown in Table 13.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
25 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 13.
IAP function calls
IAP function
IAP call parameters
Read ID
Input parameters:
R1 = 00H
DPH = 00H
DPL = 00H = mfgr id
DPL = 01H = device id 1
DPL = 02H = boot code version number
Return parameter(s):
ACC = requested parameter
Erase block 0
Input parameters:
R1 = 01H
Return parameter(s):
ACC = 00 = pass
ACC = !00 = fail
Program User Code
Input parameters:
R1 = 02H
DPH = memory address MSB
DPL = memory address LSB
ACC = byte to program
Return parameter(s):
ACC = 00 = pass
ACC = !00 = fail
Read User Code
Input parameters:
R1 = 03H
DPH = memory address MSB
DPL = memory address LSB
Return parameter(s):
ACC = device data
Program Security Bit, Double
Clock
Input parameters:
R1 = 05H
DPL = 01H = security bit
DPL = 05H = Double Clock
Return parameter(s):
ACC = 00 = pass
ACC = !00 = fail
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
26 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 13.
IAP function calls …continued
IAP function
IAP call parameters
Read Security Bit, Double Clock,
SoftICE
Input parameters:
ACC = 07H
Return parameter(s):
ACC = 000 S/N-match 0 SB 0 DBL_CLK
Read Security Bit, Double Clock,
SoftICE
Input parameters:
ACC = 07H
Return parameter(s):
ACC = 00 SoftICE S/N-match 0 SB 0 DBL_CLK
Erase sector
Input parameters:
R1 = 08H
DPH = sector address high byte
DPL = sector address low byte
Return parameter(s):
ACC = 00 = pass
ACC = !00 = fail
6.4 Timers/counters 0 and 1
The two 16-bit Timer/counter registers: Timer 0 and Timer 1 can be configured to operate
either as timers or event counters (see Table 14 and Table 15).
In the ‘Timer’ function, the register is incremented every machine cycle. Thus, one can
think of it as counting machine cycles. Since a machine cycle consists of six oscillator
periods, the count rate is 1⁄6 of the oscillator frequency.
In the ‘Counter’ function, the register is incremented in response to a 1-to-0 transition at its
corresponding external input pin, T0 or T1. In this function, the external input is sampled
once every machine cycle.
When the samples show a HIGH in one cycle and a LOW in the next cycle, the count is
incremented. The new count value appears in the register in the machine cycle following
the one in which the transition was detected. Since it takes two machine cycles (12
oscillator periods) for 1-to-0 transition to be recognized, the maximum count rate is 1⁄12 of
the oscillator frequency. There are no restrictions on the duty cycle of the external input
signal, but to ensure that a given level is sampled at least once before it changes, it should
be held for at least one full machine cycle. In addition to the ‘Timer’ or ‘Counter’ selection,
Timer 0 and Timer 1 have four operating modes from which to select.
The ‘Timer’ or ‘Counter’ function is selected by control bits C/T in the special function
register TMOD. These two timer/counters have four operating modes, which are selected
by bit-pairs (M1, M0) in TMOD. Modes 0, 1, and 2 are the same for both timers/counters.
Mode 3 is different. The four operating modes are described in the following text.
Table 14. TMOD - Timer/counter mode control register (address 89H) bit allocation
Not bit addressable; reset value: 0000 0000B; reset source(s): any source.
Bit
Symbol
7
6
5
4
3
2
1
0
T1GATE
T1C/T
T1M1
T1M0
T0GATE
T0C/T
T0M1
T0M0
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
27 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 15.
Bit
Table 16.
TMOD - Timer/counter mode control register (address 89H) bit descriptions
Symbol
Description
T1/T0
Bits controlling Timer1/Timer0
GATE
Gating control when set. Timer/counter ‘x’ is enabled only while ‘INTx’
INTx pin is HIGH and ‘TRx’ control pin is set. When cleared, Timer ‘x’
is enabled whenever ‘TRx’ control bit is set.
C/T
Gating Timer or Counter Selector cleared for Timer operation (input
from internal system clock). Set for Counter operation (input from ‘Tx’
input pin).
TMOD - Timer/counter mode control register (address 89H) M1/M0 operating
mode
M1
M0
Operating mode
0
0
0
8048 timer ‘TLx’ serves as 5-bit prescaler
0
1
1
16-bit Timer/counter ‘THx’ and ‘TLx' are cascaded; there
is no prescaler.
1
0
2
8-bit auto-reload Timer/counter ‘THx’ holds a value which
is to be reloaded into ‘TLx’ each time it overflows.
1
1
3
(Timer 0) TL0 is an 8-bit Timer/counter controlled by the
standard Timer 0 control bits. TH0 is an 8-bit timer only
controlled by Timer 1 control bits.
1
1
3
(Timer 1) Timer/counter 1 stopped.
Table 17. TCON - Timer/counter control register (address 88H) bit allocation
Bit addressable; reset value: 0000 0000B; reset source(s): any reset.
Bit
Symbol
Table 18.
7
6
5
4
3
2
1
0
TF1
TR1
TF0
TR0
IE1
IT1
IE0
IT0
TCON - Timer/counter control register (address 88H) bit descriptions
Bit
Symbol
Description
7
TF1
Timer 1 overflow flag. Set by hardware on Timer/counter overflow.
Cleared by hardware when the processor vectors to Timer 1 Interrupt
routine, or by software.
6
TR1
Timer 1 Run control bit. Set/cleared by software to turn Timer/counter 1
on/off.
5
TF0
Timer 0 overflow flag. Set by hardware on Timer/counter overflow.
Cleared by hardware when the processor vectors to Timer 0 Interrupt
routine, or by software.
4
TR0
Timer 0 Run control bit. Set/cleared by software to turn Timer/counter 0
on/off.
3
IE1
Interrupt 1 Edge flag. Set by hardware when external interrupt 1
edge/low level is detected. Cleared by hardware when the interrupt is
processed, or by software.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
28 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 18.
TCON - Timer/counter control register (address 88H) bit descriptions …continued
Bit
Symbol
Description
2
IT1
Interrupt 1 Type control bit. Set/cleared by software to specify falling
edge/low level that triggers external interrupt 1.
1
IE0
Interrupt 0 Edge flag. Set by hardware when external interrupt 0
edge/low level is detected. Cleared by hardware when the interrupt is
processed, or by software.
0
IT0
Interrupt 0 Type control bit. Set/cleared by software to specify falling
edge/low level that triggers external interrupt 0.
6.4.1 Mode 0
Putting either Timer into mode 0 makes it look like an 8048 Timer, which is an 8-bit
counter with a fixed divide-by-32 prescaler. Figure 7 shows mode 0 operation.
overflow
osc/6
Tn pin
C/T = 0
C/T = 1
control
TLn
(5-bits)
THn
(8-bits)
TFn
interrupt
TRn
TnGate
INTn pin
002aaa519
Fig 7. Timer/counter 0 or 1 in mode 0 (13-bit counter)
In this mode, the Timer register is configured as a 13-bit register. As the count rolls over
from all 1s to all 0s, it sets the Timer interrupt flag TFn. The count input is enabled to the
Timer when TRn = 1 and either GATE = 0 or INTn = 1. Setting GATE = 1 allows the Timer
to be controlled by external input INTn, to facilitate pulse width measurements. TRn is a
control bit in the Special Function Register TCON (Figure 6). The GATE bit is in the TMOD
register.
The 13-bit register consists of all 8 bits of THn and the lower 5 bits of TLn. The upper
3 bits of TLn are indeterminate and should be ignored. Setting the run flag (TRn) does not
clear the registers.
Mode 0 operation is the same for Timer 0 and Timer 1 (see Figure 7). There are two
different GATE bits, one for Timer 1 (TMOD.7) and one for Timer 0 (TMOD.3).
6.4.2 Mode 1
Mode 1 is the same as mode 0, except that all 16 bits of the timer register (THn and TLn)
are used. See Figure 8.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
29 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
overflow
C/T = 0
osc/6
Tn pin
C/T = 1
control
TLn
(8-bits)
THn
(8-bits)
TFn
interrupt
TRn
TnGate
INTn pin
002aaa520
Fig 8. Timer/counter 0 or 1 in mode 1 (16-bit counter)
6.4.3 Mode 2
Mode 2 configures the Timer register as an 8-bit Counter (TLn) with automatic reload, as
shown in Figure 9. Overflow from TLn not only sets TFn, but also reloads TLn with the
contents of THn, which must be preset by software. The reload leaves THn unchanged.
Mode 2 operation is the same for Timer 0 and Timer 1.
C/T = 0
osc/6
Tn pin
C/T = 1
control
TLn
(8-bits)
overflow
TFn
interrupt
reload
TRn
TnGate
THn
(8-bits)
INTn pin
002aaa521
Fig 9. Timer/counter 0 or 1 in mode 2 (8-bit auto-reload)
6.4.4 Mode 3
When timer 1 is in mode 3 it is stopped (holds its count). The effect is the same as setting
TR1 = 0.
Timer 0 in mode 3 establishes TL0 and TH0 as two separate 8-bit counters. The logic for
mode 3 and Timer 0 is shown in Figure 10. TL0 uses the Timer 0 control bits: T0C/T,
T0GATE, TR0, INT0, and TF0. TH0 is locked into a timer function (counting machine
cycles) and takes over the use of TR1 and TF1 from Timer 1. Thus, TH0 now controls the
‘Timer 1’ interrupt.
Mode 3 is provided for applications that require an extra 8-bit timer. With Timer 0 in mode
3, the P89LV51RB2/RC2/RD2 can look like it has an additional Timer.
Note: When Timer 0 is in mode 3, Timer 1 can be turned on and off by switching it into
and out of its own mode 3. It can still be used by the serial port as a baud rate generator,
or in any application not requiring an interrupt.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
30 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
C/T = 0
osc/6
T0 pin
control
C/T = 1
TL0
(8-bits)
overflow
TH0
(8-bits)
overflow
TF0
interrupt
TF1
interrupt
TR0
TnGate
INT0 pin
osc/2
control
TR1
002aaa522
Fig 10. Timer/counter 0 mode 3 (two 8-bit counters)
6.5 Timer 2
Timer 2 is a 16-bit Timer/counter which can operate as either an event timer or an event
counter, as selected by C/T2 in the special function register T2CON. Timer 2 has four
operating modes: Capture, Auto-reload (up or down counting), Clock-out, and Baud Rate
Generator which are selected according to Table 19 using T2CON (Table 20 and
Table 21) and T2MOD (Table 22 and Table 23).
Table 19.
Timer 2 operating mode
RCLK + TCLK CP/RL2
TR2
T2OE
Mode
0
0
1
0
16-bit auto reload
0
1
1
0
16-bit capture
0
0
1
1
programmable clock-out
1
X
1
0
baud rate generator
X
X
0
X
off
Table 20. T2CON - Timer/counter 2 control register (address C8H) bit allocation
Bit addressable; reset value: 00H.
Bit
Symbol
Table 21.
7
6
5
4
3
2
1
0
TF2
EXF2
RCLK
TCLK
EXEN2
TR2
C/T2
CP/RL2
T2CON - Timer/counter 2 control register (address C8H) bit descriptions
Bit
Symbol
Description
7
TF2
Timer 2 overflow flag set by a Timer 2 overflow and must be cleared by
software. TF2 will not be set when either RCLK or TCLK = 1 or when
Timer 2 is in Clock-out mode.
6
EXF2
Timer 2 external flag is set when Timer 2 is in capture, reload or
baud-rate mode, EXEN2 = 1 and a negative transition on T2EX occurs.
If Timer 2 interrupt is enabled, EXF2 = 1 causes the CPU to vector to
the Timer 2 interrupt routine. EXF2 must be cleared by software.
5
RCLK
Receive clock flag. When set, causes the UART to use Timer 2
overflow pulses for its receive clock in modes 1 and 3. RCLK = 0
causes Timer 1 overflow to be used for the receive clock.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
31 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 21.
T2CON - Timer/counter 2 control register (address C8H) bit descriptions
Bit
Symbol
Description
4
TCLK
Transmit clock flag. When set, causes the UART to use Timer 2
overflow pulses for its transmit clock in modes 1 and 3. TCLK = 0
causes Timer 1 overflows to be used for the transmit clock.
3
EXEN2
Timer 2 external enable flag. When set, allows a capture or reload to
occur as a result of a negative transition on T2EX if Timer 2 is not being
used to clock the serial port. EXEN2 = 0 causes Timer 2 to ignore
events at T2EX.
2
TR2
Start/stop control for Timer 2. A logic ‘1’ enables the timer to run.
1
C/T2
Timer or counter select. (Timer 2)
0 = internal timer (fosc / 6)
1 = external event counter (falling edge triggered; external clock’s
maximum rate = fosc /12
0
CP/RL2
Capture/Reload flag. When set, captures will occur on negative
transitions at T2EX if EXEN2 = 1. When cleared, auto-reloads will
occur either with Timer 2 overflows or negative transitions at T2EX
when EXEN2 = 1. When either RCLK = 1 or TCLK = 1, this bit is
ignored and the timer is forced to auto-reload on Timer 2 overflow.
Table 22. T2MOD - Timer 2 mode control register (address C9H) bit allocation
Not bit addressable; Reset value: XX00 0000B.
Bit
7
6
5
4
3
2
1
0
Symbol
-
-
-
-
-
-
T2OE
DCEN
Table 23.
T2MOD - Timer 2 mode control register (address C9H) bit descriptions
Bit
Symbol
Description
7 to 2
-
Reserved for future use. Should be set to ‘0’ by user programs.
1
T2OE
Timer 2 Output Enable bit. Used in programmable clock-out mode only.
0
DCEN
Down Count Enable bit. When set, this allows Timer 2 to be configured
as an up/down counter.
6.5.1 Capture mode
In the Capture mode there are two options which are selected by bit EXEN2 in T2CON. If
EXEN2 = 0, Timer 2 is a 16-bit timer or counter (as selected by C/T2 in T2CON) which
upon overflowing sets bit TF2, the Timer 2 overflow bit.
The capture mode is illustrated in Figure 11.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
32 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
OSC
÷6
C/T2 = 0
TL2
(8-bits)
TF2
control
C/T2 = 1
T2 pin
TH2
(8-bits)
TR2
capture
transition
detector
timer 2
interrupt
RCAP2L RCAP2H
T2EX pin
EXF2
control
EXEN2
002aaa523
Fig 11. Timer 2 in Capture mode
This bit can be used to generate an interrupt (by enabling the Timer 2 interrupt bit in the
IEN0 register). If EXEN2 = 1, Timer 2 operates as described above, but with the added
feature that a 1-to-0 transition at external input T2EX causes the current value in the
Timer 2 registers, TL2 and TH2, to be captured into registers RCAP2L and RCAP2H,
respectively.
In addition, the transition at T2EX causes bit EXF2 in T2CON to be set, and EXF2 like
TF2 can generate an interrupt (which vectors to the same location as Timer 2 overflow
interrupt). The Timer 2 interrupt service routine can interrogate TF2 and EXF2 to
determine which event caused the interrupt.
There is no reload value for TL2 and TH2 in this mode. Even when a capture event occurs
from T2EX, the counter keeps on counting T2 pin transitions or fosc / 6 pulses. Since once
loaded contents of RCAP2L and RCAP2H registers are not protected, once Timer2
interrupt is signalled it has to be serviced before a new capture event on T2EX pin occurs.
Otherwise, the next falling edge on T2EX pin will initiate reload of the current value from
TL2 and TH2 to RCAP2L and RCAP2H and consequently corrupt their content related to
the previously reported interrupt.
6.5.2 Auto-reload mode (up or down counter)
In the 16-bit auto-reload mode, Timer 2 can be configured as either a timer or counter (via
C/T2 in T2CON), then programmed to count up or down. The counting direction is
determined by bit DCEN (Down Counter Enable) which is located in the T2MOD register
(see Table 22 and Table 23). When reset is applied, DCEN = 0 and Timer 2 will default to
counting up. If the DCEN bit is set, Timer 2 can count up or down depending on the value
of the T2EX pin.
Figure 12 shows Timer 2 counting up automatically (DCEN = 0).
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
33 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
OSC
÷6
C/T2 = 0
TL2
(8-bits)
TF2
control
C/T2 = 1
T2 pin
TH2
(8-bits)
TR2
reload
transition
detector
timer 2
interrupt
RCAP2L RCAP2H
T2EX pin
EXF2
control
EXEN2
002aaa524
Fig 12. Timer 2 in auto-reload mode (DCEN = 0)
In this mode, there are two options selected by bit EXEN2 in T2CON register. If
EXEN2 = 0, then Timer 2 counts up to 0FFFFH and sets the TF2 (Overflow Flag) bit upon
overflow. This causes the Timer 2 registers to be reloaded with the 16-bit value in
RCAP2L and RCAP2H. The values in RCAP2L and RCAP2H are preset by software
means.
Auto reload frequency when Timer 2 is counting up can be determined from this formula:
Supply Frequency
-------------------------------------------------------------------------------( 65536 ∠( RCAP2H , RCAP2L ) )
(1)
Where Supply frequency is either fosc (C/T2 = 0) or frequency of signal on T2 pin
(C/T2 = 1).
If EXEN2 = 1, a 16-bit reload can be triggered either by an overflow or by a 1-to-0
transition at input T2EX. This transition also sets the EXF2 bit. The Timer 2 interrupt, if
enabled, can be generated when either TF2 or EXF2 is ‘1’.
Microcontroller’s hardware will need three consecutive machine cycles in order to
recognize the falling edge on T2EX and to set EXF2 = 1: in the first machine cycle pin
T2EX has to be sampled as ‘1’; in the second machine cycle it has to be sampled as ‘0’,
and in the third machine cycle EXF2 will be set to ‘1’.
In Figure 13, DCEN = 1 and Timer 2 is enabled to count up or down. This mode allows pin
T2EX to control the direction of count. When a logic ‘1’ is applied at pin T2EX Timer 2 will
count up. Timer 2 will overflow at 0FFFFH and sets the TF2 flag, which can then generate
an interrupt, if the interrupt is enabled. This timer overflow also causes the 16-bit value in
RCAP2L and RCAP2H to be reloaded into the timer registers TL2 and TH2.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
34 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
toggle
(down-counting reload value)
÷6
OSC
T2 pin
FFH
FFH
TL2
(8-bits)
TH2
(8-bits)
EXF2
C/T2 = 0
control
C/T2 = 1
underflow
timer 2
interrupt
TF2
overflow
TR2
RCAP2L RCAP2H
count direction
1 = up
0 = down
(up-counting reload value)
T2EX pin
002aaa525
Fig 13. Timer 2 in Auto Reload mode (DCEN = 1)
A logic 0 applied at pin T2EX causes Timer 2 to count down. The timer will underflow
when TL2 and TH2 become equal to the value stored in RCAP2L and RCAP2H. Timer 2
underflow sets the TF2 flag and causes 0FFFFH to be reloaded into the timer registers
TL2 and TH2. 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.
6.5.3 Programmable clock-out
A 50 % duty cycle clock can be programmed to come out on pin T2 (P1.0). This pin,
besides being a I/O pin, has two additional functions. It can be programmed:
• To input the external clock for Timer/counter 2, or
• To output a 50 % duty cycle clock ranging from 122 Hz to 8 MHz at a 16 MHz
operating frequency.
To configure the Timer/counter 2 as a clock generator, bit C/T2 (in T2CON) must be
cleared and bit T2OE 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 (RCAP2H, RCAP2L) as shown in Equation 2:
Oscillator Frequency
------------------------------------------------------------------------------------2 × ( 65536 ∠( RCAP2H, RCAP2L ) )
(2)
Where (RCAP2H, RCAP2L) = the content of RCAP2H and RCAP2L taken as a 16-bit
unsigned integer.
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.
6.5.4 Baud rate generator mode
Bits TCLK and/or RCLK in T2CON allow the UART transmit and receive baud rates to be
derived from either Timer 1 or Timer 2 (See Section 6.6 “UART” on page 37 for details).
When TCLK = 0, Timer 1 is used as the UART transmit baud rate generator. When
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
35 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
TCLK = 1, Timer 2 is used as the UART transmit baud rate generator. RCLK has the same
effect for the UART receive baud rate. With these two bits, the serial port can have
different receive and transmit baud rates – Timer 1 or Timer 2.
Figure 14 shows Timer 2 in baud rate generator mode.
OSC
÷2
C/T2 = 0
TL2
(8-bits)
TX/RX baud rate
control
C/T2 = 1
T2 pin
TH2
(8-bits)
reload
TR2
transition
detector
RCAP2L RCAP2H
T2EX pin
EXF2
timer 2
interrupt
control
EXEN2
002aaa526
Fig 14. Timer 2 in Baud Rate Generator mode
The baud rate generation mode is like the auto-reload mode, when a rollover in TH2
causes the Timer 2 registers to be reloaded with the 16-bit value in registers RCAP2H and
RCAP2L, which are preset by software.
The baud rates in modes 1 and 3 are determined by Timer 2’s overflow rate given below:
Modes 1 and 3 baud rates = Timer 2 Overflow Rate / 16
The timer can be configured for either ‘timer’ or ‘counter’ operation. In many applications,
it is configured for ‘timer' operation (C/T2 = 0). Timer operation is different for Timer 2
when it is being used as a baud rate generator.
Usually, as a timer it would increment every machine cycle (i.e., 1⁄6 the oscillator
frequency). As a baud rate generator, it increments at the oscillator frequency. Thus the
baud rate formula is as follows:
Modes 1 and 3 baud rates =
Oscillator Frequency
-----------------------------------------------------------------------------------------------( 16 × ( 65536 – ( RCAP2H , RCAP2L ) ) )
(3)
Where: (RCAP2H, RCAP2L) = the content of RCAP2H and RCAP2L taken as a 16-bit
unsigned integer.
The Timer 2 as a baud rate generator mode is valid only if RCLK and/or TCLK = 1 in
T2CON register. Note that a rollover in TH2 does not set TF2, and will not generate an
interrupt. Thus, the Timer 2 interrupt does not have to be disabled when Timer 2 is in the
baud rate generator mode. Also if the EXEN2 (T2 external enable flag) is set, a 1-to-0
transition in T2EX (Timer/counter 2 trigger input) will set EXF2 (T2 external flag) but will
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
36 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Therefore when Timer 2 is in
use as a baud rate generator, T2EX can be used as an additional external interrupt, if
needed.
When Timer 2 is in the baud rate generator mode, one should not try to read or write TH2
and TL2. Under these conditions, a read or write of TH2 or TL2 may not be accurate. The
RCAP2 registers may be read, but should not be written to, because a write might overlap
a reload and cause write and/or reload errors. The timer should be turned off (clear TR2)
before accessing the Timer 2 or RCAP2 registers. Table 24 shows commonly used baud
rates and how they can be obtained from Timer 2.
6.5.5 Summary of baud rate equations
Timer 2 is in baud rate generating mode. If Timer 2 is being clocked through pin T2(P1.0)
the baud rate is:
Baud rate = Timer 2 overflow rate / 16
If Timer 2 is being clocked internally, the baud rate is:
Baud rate = fosc / (16 × (65536 − (RCAP2H, RCAP2L)))
Where fosc = oscillator frequency
To obtain the reload value for RCAP2H and RCAP2L, the above equation can be rewritten
as:
RCAP2H, RCAP2L = 65536 − fosc / (16 × baud rate)
Table 24.
Rate
Timer 2 generated commonly used baud rates
Oscillator frequency
Timer 2
RCAP2H
RCAP2L
750 kBd
12 MHz
FF
FF
19.2 kBd
12 MHz
FF
D9
9.6 kBd
12 MHz
FF
B2
4.8 kBd
12 MHz
FF
64
2.4 kBd
12 MHz
FE
C8
600 Bd
12 MHz
FB
1E
220 Bd
12 MHz
F2
AF
600 Bd
6 MHz
FD
8F
220 Bd
6 MHz
F9
57
6.6 UART
The UART operates in all standard modes. Enhancements over the standard 80C51
UART include Framing Error detection, and automatic address recognition.
6.6.1 Mode 0
Serial data enters and exits through RXD, and TXD outputs the shift clock. Only 8 bits are
transmitted or received, LSB first. The baud rate is fixed at 1⁄6 of the CPU clock frequency.
The UART is configured to operate in this mode and outputs serial clock on TXD line no
matter whether it sends or receives data on the RXD line.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
37 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
6.6.2 Mode 1
10 bits are transmitted (through TXD) or received (through RXD): a start bit (logical 0), 8
data bits (LSB first), and a stop bit (logical 1). When data is received, the stop bit is stored
in RB8 in Special Function Register SCON. The baud rate is variable and is determined
by the Timer 1⁄2 overflow rate.
6.6.3 Mode 2
11 bits are transmitted (through TXD) or received (through RXD): start bit (logical 0), 8
data bits (LSB first), a programmable 9th data bit, and a stop bit (logical 1). When data is
transmitted, the 9th data bit (TB8 in SCON) can be assigned the value of 0 or (e.g. the
parity bit (P, in the PSW) could be moved into TB8). When data is received, the 9th data
bit goes into RB8 in Special Function Register SCON, while the stop bit is ignored. The
baud rate is programmable to either 1⁄16 or 1⁄32 of the CPU clock frequency, as determined
by the SMOD1 bit in PCON.
6.6.4 Mode 3
11 bits are transmitted (through TXD) or received (through RXD): a start bit (logical 0), 8
data bits (LSB first), a programmable 9th data bit, and a stop bit (logical 1). In fact, mode 3
is the same as mode 2 in all respects except baud rate. The baud rate in mode 3 is
variable and is determined by the Timer 1⁄2 overflow rate.
Table 25. SCON - Serial port control register (address 98H) bit allocation
Bit addressable; reset value: 00H.
Bit
Symbol
Table 26.
7
6
5
4
3
2
1
0
SM0/FE
SM1
SM2
REN
TB8
RB8
TI
RI
SCON - Serial port control register (address 98H) bit descriptions
Bit
Symbol
Description
7
SM0/FE
The usage of this bit is determined by SMOD0 in the PCON register. If
SMOD0 = 0, this bit is SM0, which with SM1, defines the serial port
mode. If SMOD0 = 1, this bit is FE (Framing Error). FE is set by the
receiver when an invalid stop bit is detected. Once set, this bit cannot
be cleared by valid frames but can only be cleared by software. (Note:
It is recommended to set up UART mode bits SM0 and SM1 before
setting SMOD0 to ‘1’.)
6
SM1
With SM0, defines the serial port mode (see Table 27).
5
SM2
Enables the multiprocessor communication feature in modes 2 and 3.
In mode 2 or 3, if SM2 is set to ‘1’, then Rl will not be activated if the
received 9th data bit (RB8) is ‘0’. In mode 1, if SM2 = 1 then RI will not
be activated if a valid stop bit was not received. In mode 0, SM2 should
be ‘0’.
4
REN
Enables serial reception. Set by software to enable reception. Clear by
software to disable reception.
3
TB8
The 9th data bit that will be transmitted in modes 2 and 3. Set or clear
by software as desired.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
38 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 26.
SCON - Serial port control register (address 98H) bit descriptions …continued
Bit
Symbol
Description
2
RB8
In modes 2 and 3, is the 9th data bit that was received. In mode 1, if
SM2 = 0, RB8 is the stop bit that was received. In mode 0, RB8 is
undefined.
1
TI
Transmit interrupt flag. Set by hardware at the end of the 8th bit time in
mode 0, or at the stop bit in the other modes, in any serial transmission.
Must be cleared by software.
0
RI
Receive interrupt flag. Set by hardware at the end of the 8th bit time in
mode 0, or approximately halfway through the stop bit time in all other
modes. (See SM2 for exceptions). Must be cleared by software.
Table 27.
SCON - Serial port control register (address 98H) SM0/SM1 mode definitions
SM0, SM1
UART mode
Baud rate
00
0: shift register
CPU clock / 6
01
1: 8-bit UART
variable
10
2: 9-bit UART
CPU clock / 32 or CPU
clock / 16
11
3: 9-bit UART
variable
6.6.5 Framing error
Framing error (FE) is reported in the SCON.7 bit if SMOD0 (PCON.6) = 1. If SMOD0 = 0,
SCON.7 is the SM0 bit for the UART, it is recommended that SM0 is set up before SMOD0
is set to ‘1’.
6.6.6 More about UART mode 1
Reception is initiated by a detected 1-to-0 transition at RXD. For this purpose RXD is
sampled at a rate of 16 times whatever baud rate has been established. When a transition
is detected, the divide-by-16 counter is immediately reset to align its rollovers with the
boundaries of the incoming bit times.
The 16 states of the counter divide each bit time into 16ths. At the 7th, 8th, and 9th
counter states of each bit time, the bit detector samples the value of RXD. The value
accepted is the value that was seen in at least 2 of the 3 samples. This is done for noise
rejection. If the value accepted during the first bit time is not 0, the receive circuits are
reset and the unit goes back to looking for another 1-to-0 transition. This is to provide
rejection of false start bits. If the start bit proves valid, it is shifted into the input shift
register, and reception of the rest of the frame will proceed.
The signal to load SBUF and RB8, and to set RI, will be generated if, and only if, the
following conditions are met at the time the final shift pulse is generated: (a) RI = 0, and
(b) either SM2 = 0, or the received stop bit = 1.
If either of these two conditions is not met, the received frame is irretrievably lost. If both
conditions are met, the stop bit goes into RB8, the 8 data bits go into SBUF, and RI is
activated.
6.6.7 More about UART modes 2 and 3
Reception is performed in the same manner as in mode 1.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
39 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
The signal to load SBUF and RB8, and to set RI, will be generated if, and only if, the
following conditions are met at the time the final shift pulse is generated: (a) RI = 0, and
(b) either SM2 = 0, or the received 9th data bit = 1.
If either of these conditions is not met, the received frame is irretrievably lost, and RI is not
set. If both conditions are met, the received 9th data bit goes into RB8, and the first 8 data
bits go into SBUF.
6.6.8 Multiprocessor communications
UART modes 2 and 3 have a special provision for multiprocessor communications. In
these modes, 9 data bits are received or transmitted. When data is received, the 9th bit is
stored in RB8. The UART can be programmed so that when the stop bit is received, the
serial port interrupt will be activated only if RB8 = 1. This feature is enabled by setting bit
SM2 in SCON. One way to use this feature in multiprocessor systems is as follows:
When the master processor wants to transmit a block of data to one of several slaves, it
first sends out an address byte which identifies the target slave. An address byte differs
from a data byte in a way that the 9th bit is ‘1’ in an address byte and ‘0’ in the data byte.
With SM2 = 1, no slave will be interrupted by a data byte, i.e. the received 9th bit is ‘0’.
However, an address byte having the 9th bit set to ‘1’ will interrupt all slaves, so that each
slave can examine the received byte and see if it is being addressed or not. The
addressed slave will clear its SM2 bit and prepare to receive the data (still 9 bits long) that
follow. The slaves that weren’t being addressed leave their SM2 bits set and ignore the
subsequent data bytes.
SM2 has no effect in mode 0, and in mode 1 can be used to check the validity of the stop
bit, although this is better done with the Framing Error flag. When the UART receives data
in mode 1 and SM2 = 1, the receive interrupt will not be activated unless a valid stop bit is
received.
6.6.9 Automatic address recognition
Automatic Address Recognition is a feature which allows the UART to recognize certain
addresses in the serial bit stream by using hardware to make the comparisons. This
feature saves a great deal of software overhead by eliminating the need for the software to
examine every serial address which passes by the serial port. This feature is enabled for
the UART by setting the SM2 bit in SCON. In the 9 bit UART modes, mode 2 and mode 3,
the Receive Interrupt flag (RI) will be automatically set when the received byte contains
either the ‘Given’ address or the ‘Broadcast' address. The 9 bit mode requires that the 9th
information bit is a ‘1’ to indicate that the received information is an address and not data.
Using the Automatic Address Recognition feature allows a master to selectively
communicate with one or more slaves by invoking the Given slave address or addresses.
All of the slaves may be contacted by using the Broadcast address. Two Special Function
Registers are used to define the slave’s address, SADDR, and the address mask,
SADEN. SADEN is used to define which bits in the SADDR are to be used and which bits
are ‘don’t care’. The SADEN mask can be logically ANDed with the SADDR to create the
‘Given’ address which the master will use for addressing each of the slaves. Use of the
Given address allows multiple slaves to be recognized while excluding others.
This device uses the methods presented in Figure 15 to determine if a ‘Given’ or
‘Broadcast’ address has been received or not.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
40 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
rx_byte(7)
saddr(7)
saden(7)
.
.
.
rx_byte(0)
saddr(0)
given_address_match
saden(0)
logic used by UART to detect 'given address' in received data
saddr(7)
saden(7)
rx_byte(7)
.
.
.
saddr(0)
saden(0)
broadcast_address_match
rx_byte(0)
logic used by UART to detect 'given address' in received data
002aaa527
Fig 15. Schemes used by the UART to detect ‘given’ and ‘broadcast’ addresses when multiprocessor
communications is enabled
The following examples help to show the versatility of this scheme.
Example 1, slave 0:
SADDR = 1100 0000
SADEN = 1111 1101
---------------------------------------------------Given = 1100 00X0
(4)
Example 2, slave 1:
SADDR = 1100 0000
SADEN = 1111 1110
---------------------------------------------------Given = 1100 000X
(5)
In the above example value SADDR is the same and the SADEN data is used to
differentiate between the two slaves. Slave 0 requires a ‘0’ in bit 0 and it ignores bit 1.
Slave 1 requires a ‘0’ in bit 1 and bit 0 is ignored. A unique address for Slave 0 would be
1100 0010 since slave 1 requires a ‘0’ in bit 1. A unique address for slave 1 would be 1100
0001 since a ‘1’ in bit 0 will exclude slave 0. Both slaves can be selected at the same time
by an address which has bit 0 = 0 (for slave 0) and bit 1 = 0 (for slave 1). Thus, both could
be addressed with 1100 0000.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
41 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
In a more complex system the following could be used to select slaves 1 and 2 while
excluding slave 0:
Example 1, slave 0:
SADDR = 1100 0000
SADEN = 1111 1001
---------------------------------------------------Given = 1100 0XX0
(6)
Example 2, slave 1:
SADDR = 1110 0000
SADEN = 1111 1010
---------------------------------------------------Given = 1110 0X0X
(7)
Example 3, slave 2:
SADDR = 1100 0000
SADEN = 1111 1100
---------------------------------------------------Given = 1100 00XX
(8)
In the above example the differentiation among the 3 slaves is in the lower 3 address bits.
Slave 0 requires that bit 0 = 0 and it can be uniquely addressed by 1110 0110. Slave 1
requires that bit 1 = 0 and it can be uniquely addressed by 1110 0101. Slave 2 requires
that bit 2 = 0 and its unique address is 1110 0011. To select Slaves 0 and 1 and exclude
Slave 2 use address 1110 0100, since it is necessary to make bit 2 = 1 to exclude slave 2.
The Broadcast Address for each slave is created by taking the logical OR of SADDR and
SADEN. Zeros in this result are treated as don’t-cares. In most cases, interpreting the
don’t-cares as ones, the broadcast address will be FF hexadecimal. Upon reset SADDR
and SADEN are loaded with 0s. This produces a given address of all ‘don’t cares’ as well
as a Broadcast address of all ‘don’t cares'. This effectively disables the Automatic
Addressing mode and allows the microcontroller to use standard UART drivers which do
not make use of this feature.
6.7 SPI
6.7.1 SPI features
•
•
•
•
•
•
•
Master or slave operation
10 MHz bit frequency (maximum)
LSB first or MSB first data transfer
Four programmable bit rates
End of transmission (SPIF)
Write collision flag protection (WCOL)
Wake-up from Idle mode (slave mode only)
6.7.2 SPI description
The SPI allows high-speed synchronous data transfer between the
P89LV51RB2/RC2/RD2 and peripheral devices or between several
P89LV51RB2/RC2/RD2 devices. Figure 16 shows the correspondence between master
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
42 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
and slave SPI devices. The SPICLK pin is the clock output and input for the master and
slave modes, respectively. The SPI clock generator will start following a write to the
master devices SPI data register. The written data is then shifted out of the MOSI pin on
the master device into the MOSI pin of the slave device. Following a complete
transmission of one byte of data, the SPI clock generator is stopped and the SPIF flag is
set. An SPI interrupt request will be generated if the SPI Interrupt Enable bit (SPIE) and
the Serial Port Interrupt Enable bit (ES) are both set.
An external master drives the Slave Select input pin, SS/P1[4], low to select the SPI
module as a slave. If SS/P1[4] has not been driven low, then the slave SPI unit is not
active and the MOSI/P1[5] port can also be used as an input port pin.
CPHA and CPOL control the phase and polarity of the SPI clock. Figure 17 and Figure 18
show the four possible combinations of these two bits.
MSB master LSB
MISO
MSB slave LSB
MISO
8-BIT SHIFT REGISTER
8-BIT SHIFT REGISTER
MOSI
MOSI
SPICLK
SPI
CLOCK GENERATOR
SS
SPICLK
SS
VDD
VSS
002aaa528
Fig 16. SPI master-slave interconnection
Table 28. SPCTL - SPI control register (address D5H) bit allocation
Bit addressable; reset source(s): any reset; reset value: 0000 0000B.
Bit
Symbol
Table 29.
7
6
5
4
3
2
1
0
SPIE
SPEN
DORD
MSTR
CPOL
CPHA
PSC1
PSC0
SPCTL - SPI control register (address D5H) bit descriptions
Bit
Symbol
Description
7
SPIE
If both SPIE and ES are set to one, SPI interrupts are enabled.
6
SPEN
SPI enable bit. When set enables SPI.
5
DORD
Data transmission order. 0 = MSB first; 1 = LSB first in data
transmission.
4
MSTR
Master/slave select. 1 = master mode, 0 = slave mode.
3
CPOL
Clock polarity. 1 = SPICLK is high when idle (active LOW), 0 = SPICLK
is low when idle (active HIGH).
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
43 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 29.
SPCTL - SPI control register (address D5H) bit descriptions …continued
Bit
Symbol
Description
2
CPHA
Clock Phase control bit. 1 = shift triggered on the trailing edge of the
clock; 0 = shift triggered on the leading edge of the clock.
1
PSC1
SPI Clock Rate Select bit 1. Along with PSC0 controls the SPICLK rate
of the device when a master. PSC1 and PSC0 have no effect on the
slave. See Table 30.
0
PSC0
SPI Clock Rate Select bit 0. Along with PSC1 controls the SPICLK rate
of the device when a master. PSC1 and PSC0 have no effect on the
slave. See Table 30.
Table 30.
SPCTL - SPI control register (address D5H) clock rate selection
PSC1
PSC0
SPICLK = fosc divided by
0
0
4
0
1
16
1
0
64
1
1
128
Table 31. SPCFG - SPI status register (address AAH) bit allocation
Bit addressable; reset source(s): any reset; reset value: 0000 0000B.
Bit
Symbol
Table 32.
7
6
5
4
3
2
1
0
SPIF
WCOL
-
-
-
-
-
-
SPCFG - SPI status register (address AAH) bit descriptions
Bit
Symbol
Description
7
SPIF
SPI interrupt flag. Upon completion of data transfer, this bit is set to ‘1’.
If SPIE = 1 and ES = 1, an interrupt is then generated. This bit is
cleared by software.
6
WCOL
Write Collision Flag. Set if the SPI data register is written to during data
transfer. This bit is cleared by software.
5 to 0
-
Reserved for future use. Should be set to ‘0’ by user programs.
SPICLK cycle #
(for reference)
1
2
3
4
5
6
7
8
SPICLK (CPOL = 0)
SPICLK (CPOL = 1)
MOSI
(from master)
MISO
(from slave)
MSB
MSB
6
5
4
3
2
1
LSB
6
5
4
3
2
1
LSB
SS (to slave)
002aaa529
Fig 17. SPI transfer format with CPHA = 0
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
44 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
SPICLK cycle #
(for reference)
1
2
3
4
5
6
7
8
SPICLK (CPOL = 0)
SPICLK (CPOL = 1)
MOSI
(from master)
MISO
(from slave)
MSB
6
5
4
3
2
1
MSB
6
5
4
3
2
1
LSB
LSB
SS (to slave)
002aaa530
Fig 18. SPI transfer format with CPHA = 1
6.8 Watchdog timer
The device offers a programmable Watchdog Timer (WDT) for fail safe protection against
software deadlock and automatic recovery.
To protect the system against software deadlock, the user software must refresh the WDT
within a user-defined time period. If the software fails to do this periodical refresh, an
internal hardware reset will be initiated if enabled (WDRE = 1). The software can be
designed such that the WDT times out if the program does not work properly.
The WDT in the device uses the system clock (XTAL1) as its time base. So strictly
speaking, it is a Watchdog counter rather than a WDT. The WDT register will increment
every 344064 crystal clocks. The upper 8-bits of the time base register (WDTD) are used
as the reload register of the WDT.
The WDTS flag bit is set by WDT overflow and is not changed by WDT reset. User
software can clear WDTS by writing ‘1' to it.
Figure 19 provides a block diagram of the WDT. Two SFRs (WDTC and WDTD) control
WDT operation. During Idle mode, WDT operation is temporarily suspended, and
resumes upon an interrupt exit from idle.
The time-out period of the WDT is calculated as follows:
Period = (255 − WDTD) × 344064 × 1 / fCLK (XTAL1)
where WDTD is the value loaded into the WDTD register and fosc is the oscillator
frequency.
CLK (XTAL1)
COUNTER
344064
clks
WDT
UPPER BYTE
WDT reset
internal reset
external reset
WDTC
WDTD
002aaa531
Fig 19. Block diagram of programmable WDT
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
45 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 33. WDTC - Watchdog control register (address COH) bit allocation
Bit addressable; reset value: 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
-
-
WDOUT
WDRE
WDTS
WDT
SWDT
Table 34.
WDTC - Watchdog control register (address COH) bit descriptions
Bit
Symbol
Description
7 to 5
-
Reserved for future use. Should be set to ‘0’ by user programs.
4
WDOUT
Watchdog output enable. When this bit and WDRE are both set, a
Watchdog reset will drive the reset pin active for 32 clocks.
3
WDRE
Watchdog timer reset enable. When set enables a watchdog timer
reset.
2
WDTS
Watchdog timer reset flag, when set indicates that a WDT reset
occurred. Reset in software.
1
WDT
Watchdog timer refresh. Set by software to force a WDT reset.
0
SWDT
Start watchdog timer, when set starts the WDT. When cleared, stops
the WDT.
6.9 PCA
The PCA includes a special 16-bit Timer that has five 16-bit capture/compare modules
associated with it. Each of the modules can be programmed to operate in one of four
modes: rising and/or falling edge capture, software timer, high-speed output, or PWM.
Each module has a pin associated with it in port 1. Module 0 is connected to P1.3 (CEX0),
module 1 to P1.4 (CEX1), etc. Registers CH and CL contain the current values of the free
running up counting 16-bit PCA timer. The PCA timer is a common time base for all five
modules and can be programmed to run at: 1⁄6 the oscillator frequency, 1⁄2 the oscillator
frequency, the Timer 0 overflow, or the input on the ECI pin (P1.2). The timer count source
is determined from the CPS1 and CPS0 bits in the CMOD SFR (see Table 35 and
Table 36).
16 bits
MODULE0
P1.3/CEX0
MODULE1
P1.4/CEX1
MODULE2
P1.5/CEX2
MODULE3
P1.6/CEX3
MODULE4
P1.7/CEX4
16 bits
PCA TIMER/COUNTER
time base for PCA modules
Module functions:
- 16-bit capture
- 16-bit timer
- 16-bit high speed output
- 8-bit PWM
- watchdog timer (module 4 only)
002aaa532
Fig 20. Programmable counter array
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
46 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
In the CMOD SFR there are three additional bits associated with the PCA. They are CIDL
which allows the PCA to stop during Idle mode, WDTE which enables or disables the
Watchdog function on module 4, and ECF which when set causes an interrupt and the
PCA overflow flag CF (in the CCON SFR) to be set when the PCA timer overflows.
The watchdog timer function is implemented in module 4 of PCA.
The CCON SFR contains the run control bit (CR) for the PCA and the flags for the PCA
timer (CF) and each module (CCF4:0). To run the PCA the CR bit (CCON.6) must be set
by software. The PCA is shut off by clearing this bit. The CF bit (CCON.7) is set when the
PCA counter overflows and an interrupt will be generated if the ECF bit in the CMOD
register is set. The CF bit can only be cleared by software. Bits 0 through 4 of the CCON
register are the flags for the modules (bit 0 for module 0, bit 1 for module 1, etc.) and are
set by hardware when either a match or a capture occurs. These flags can only be cleared
by software. All the modules share one interrupt vector. The PCA interrupt system is
shown in Figure 21.
Each module in the PCA has a special function register associated with it. These registers
are: CCAPM0 for module 0, CCAPM1 for module 1, etc. The registers contain the bits that
control the mode that each module operates in.
The ECCFn bit (from CCAPMn.0 where n = 0, 1, 2, 3, or 4 depending on the module)
enables the CCFn flag in the CCON SFR to generate an interrupt when a match or
compare occurs in the associated module (see Figure 21).
PWM (CCAPMn.1) enables the pulse width modulation mode.
The TOGn bit (CCAPMn.2) when set causes the CEX output associated with the module
to toggle when there is a match between the PCA counter and the module’s
capture/compare register.
The match bit MATn (CCAPMn.3) when set will cause the CCFn bit in the CCON register
to be set when there is a match between the PCA counter and the module’s
capture/compare register.
The next two bits CAPNn (CCAPMn.4) and CAPPn (CCAPMn.5) determine the edge that
a capture input will be active on. The CAPN bit enables the negative edge, and the
CAPPn bit enables the positive edge. If both bits are set, both edges will be enabled and a
capture will occur for either transition.
The last bit in the register ECOMn (CCAPMn.6) when set enables the comparator
function.
There are two additional registers associated with each of the PCA modules. They are
CCAPnH and CCAPnL and these are the registers that store the 16-bit count when a
capture occurs or a compare should occur. When a module is used in the PWM mode
these registers are used to control the duty cycle of the output.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
47 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
CF
CR
-
CCF4
CCF3
CCF2
CCF1
CCON
(D8H)
CCF0
PCA TIMER/COUNTER
MODULE0
IE.6
EC
MODULE1
IE.7
EA
to
interrupt
priority
decoder
MODULE2
MODULE3
MODULE4
CMOD.0
CCAPMn.0
ECF
ECCFn
002aaa533
Fig 21. PCA interrupt system
Table 35. CMOD - PCA counter mode register (address D9H) bit allocation
Not bit addressable; reset value: 00H.
Bit
Symbol
Table 36.
7
6
5
4
3
2
1
0
CIDL
WDTE
-
-
-
CPS1
CPS0
ECF
CMOD - PCA counter mode register (address D9H) bit descriptions
Bit
Symbol
Description
7
CIDL
Counter Idle Control: CIDL = 0 programs the PCA Counter to continue
functioning during Idle mode. CIDL = 1 programs it to be gated off
during idle.
6
WDTE
Watchdog Timer Enable: WDTE = 0 disables watchdog timer function
on module 4. WDTE = 1 enables it.
5 to 3
-
Reserved for future use. Should be set to ‘0’ by user programs.
2 to 1
CPS1,
CPS0
PCA Count Pulse Select (see Table 37 below).
0
ECF
PCA Enable Counter Overflow Interrupt: ECF = 1 enables CF bit in
CCON to generate an interrupt. ECF = 0 disables that function.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
48 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 37.
CMOD - PCA counter mode register (address D9H) count pulse select
CPS1
CPS0
Select PCA input
0
0
0 Internal clock, fosc / 6
0
1
1 Internal clock, fosc / 2
1
0
2 Timer 0 overflow
1
1
3 External clock at ECI/P1.2 pin (maximum rate = fosc / 4)
Table 38. CCON - PCA counter control register (address 0D8H) bit allocation
Bit addressable; reset value: 00H.
Bit
Symbol
Table 39.
7
6
5
4
3
2
1
0
CF
CR
-
CCF4
CCF3
CCF2
CCF1
CCF0
CCON - PCA counter control register (address 0D8H) bit descriptions
Bit
Symbol
Description
7
CF
PCA Counter Overflow Flag. Set by hardware when the counter rolls
over. CF flags an interrupt if bit ECF in CMOD is set. CF may be set by
either hardware or software but can only be cleared by software.
6
CR
PCA Counter Run Control Bit. Set by software to turn the PCA counter
on. Must be cleared by software to turn the PCA counter off.
5
-
Reserved for future use. Should be set to ‘0’ by user programs.
4
CCF4
PCA Module 4 Interrupt Flag. Set by hardware when a match or
capture occurs. Must be cleared by software.
3
CCF3
PCA Module 3 Interrupt Flag. Set by hardware when a match or
capture occurs. Must be cleared by software.
2
CCF2
PCA Module 2 Interrupt Flag. Set by hardware when a match or
capture occurs. Must be cleared by software.
1
CCF1
PCA Module 1 Interrupt Flag. Set by hardware when a match or
capture occurs. Must be cleared by software.
0
CCF0
PCA Module 0 Interrupt Flag. Set by hardware when a match or
capture occurs. Must be cleared by software.
Table 40.
CCAPMn - PCA modules compare/capture register (address CCAPM0: 0DAH,
CCAPM1: 0DBH, CCAPM2: 0DCH, CCAPM3: 0DDH, CCAPM4: 0DEH) bit
allocation
Not bit addressable; reset value: 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
ECOMn
CAPPn
CAPNn
MATn
TOGn
PWMn
ECCFn
Table 41.
CCAPMn - PCA modules compare/capture register (address CCAPM0: 0DAH,
CCAPM1: 0DBH, CCAPM2: 0DCH, CCAPM3: 0DDH, CCAPM4: 0DEH) bit
descriptions
Bit
Symbol
Description
7
-
Reserved for future use. Should be set to ‘0’ by user programs.
6
ECOMn
Enable Comparator. ECOMn = 1 enables the comparator function.
5
CAPPn
Capture Positive, CAPPn = 1 enables positive edge capture.
4
CAPNn
Capture Negative, CAPNn = 1 enables negative edge capture.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
49 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 41.
CCAPMn - PCA modules compare/capture register (address CCAPM0: 0DAH,
CCAPM1: 0DBH, CCAPM2: 0DCH, CCAPM3: 0DDH, CCAPM4: 0DEH) bit
descriptions …continued
Bit
Symbol
Description
3
MATn
Match. When MATn = 1 a match of the PCA counter with this module’s
compare/capture register causes the CCFn bit in CCON to be set,
flagging an interrupt.
2
TOGn
Toggle. When TOGn = 1, a match of the PCA counter with this
module’s compare/capture register causes the CEXn pin to toggle.
1
PWMn
Pulse Width Modulation mode. PWMn = 1 enables the CEXn pin to be
used as a pulse-width modulated output.
0
ECCFn
Enable CCF Interrupt. Enables compare/capture flag CCFn in the
CCON register to generate an interrupt.
Table 42.
PCA module modes (CCAPMn register)
ECOMn
CAPPn
CAPNn
MATn
TOGn
PWMn
ECCFn
0
0
0
0
0
0
0
no operation
X
1
0
0
0
0
X
16-bit capture by a positive-edge trigger on
CEXn
X
0
1
0
0
0
X
16-bit capture by a negative-edge trigger on
CEXn
X
1
1
0
0
0
X
16-bit capture by any transition on CEXn
1
0
0
1
0
0
X
16-bit software timer
1
0
0
1
1
0
X
16-bit high-speed output
1
0
0
0
0
1
0
8-bit PWM
1
0
0
1
X
0
X
Watchdog timer
Module function
6.9.1 PCA capture mode
To use one of the PCA modules in the capture mode (Figure 22) either one or both of the
CCAPM bits CAPNn and CAPPn for that module must be set. The external CEX input for
the module (on port 1) is sampled for a transition. When a valid transition occurs the PCA
hardware loads the value of the PCA counter registers (CH and CL) into the module’s
capture registers (CCAPnL and CCAPnH).
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
50 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
CF
CR
-
CCF4
CCF3
CCF2
CCF1
CCF0
CCON
(D8H)
PCA
interrupt
(to CCFn)
PCA timer/counter
CH
CL
capture
CEXn
CCAPnH CCAPnL
-
ECOMn
0
CAPPn
CAPNn
MATn
TOGn
PWMn
0
0
0
ECCFn
CCAPMn, n = 0 to 4
(DAH to DEH)
002aaa538
Fig 22. PCA capture mode
If the CCFn bit for the module in the CCON SFR and the ECCFn bit in the CCAPMn SFR
are set then an interrupt will be generated.
6.9.2 16-bit software timer mode
The PCA modules can be used as software timers (Figure 23) by setting both the ECOMn
and MATn bits in the modules CCAPMn register. The PCA timer will be compared to the
module’s capture registers and when a match occurs an interrupt will occur if the CCFn
(CCON SFR) and the ECCFn (CCAPMn SFR) bits for the module are both set.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
51 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
CF
write to
CCAPnH
0
1
-
CCF4
reset
CCAPnH
write to
CCAPnL
CR
CCF3
CCF2
CCF1
CCF0
(to CCFn)
CCAPnL
enable
CCON
(D8H)
PCA
interrupt
match
16-BIT COMPARATOR
CH
CL
PCA timer/counter
-
ECOMn
CAPPn
CAPNn
MATn
TOGn
PWMn
0
0
1
0
0
ECCFn
CCAPMn, n = 0 to 4
(DAH to DEH)
002aaa539
Fig 23. PCA compare mode
6.9.3 High-speed output mode
In this mode (Figure 24) the CEX output (on port 1) associated with the PCA module will
toggle each time a match occurs between the PCA counter and the module’s capture
registers. To activate this mode the TOGn, MATn, and ECOMn bits in the module’s
CCAPMn SFR must be set.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
52 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
CF
write to
CCAPnH
CR
0
1
CCF4
reset
CCAPnH
write to
CCAPnL
-
CCF3
CCF2
CCF1
CCF0
CCON
(D8H)
(to CCFn)
CCAPnL
enable
PCA
interrupt
match
16-BIT COMPARATOR
CH
CL
PCA timer/counter
toggle
CEXn
-
ECOMn
CAPPn
CAPNn
MATn
TOGn
PWMn
0
0
1
0
0
ECCFn
CCAPMn, n = 0 to 4
(DAH to DEH)
002aaa540
Fig 24. PCA high-speed output mode
6.9.4 PWM mode
All of the PCA modules can be used as PWM outputs (Figure 25). Output frequency
depends on the source for the PCA timer.
CCAPnH
0
CCAPnL
CL < CCAPnL
enable
CEXn
8-BIT COMPARATOR
CL ≥ CCAPnL
1
CL
PCA timer/counter
-
ECOMn
CAPPn
CAPNn
MATn
TOGn
PWMn
ECCFn
1
0
0
0
0
1
1
CCAPMn, n = 0 to 4
(DAH to DEH)
002aaa541
Fig 25. PCA PWM mode
All of the modules will have the same frequency of output because they all share only one
PCA timer. The duty cycle of each module is independently variable using the module’s
capture register CCAPnL. When the value of the PCA CL SFR is less than the value in the
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
53 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
module’s CCAPnL SFR the output will be LOW, when it is equal to or greater than, the
output will be HIGH. When CL overflows from FF to 00, CCAPnL is reloaded with the
value in CCAPnH. This allows updating the PWM without glitches. The PWMn and
ECOMn bits in the module’s CCAPMn register must be set to enable the PWM mode.
6.9.5 PCA watchdog timer
An on-board watchdog timer is available with the PCA to improve the reliability of the
system without increasing chip count. Watchdog timers are useful for systems that are
susceptible to noise, power glitches, or electrostatic discharge. Module 4 is the only PCA
module that can be programmed as a Watchdog. However, this module can still be used
for other modes if the Watchdog is not needed. Figure 25 shows a diagram of how the
Watchdog works. The user pre-loads a 16-bit value in the compare registers. Just like the
other compare modes, this 16-bit value is compared to the PCA timer value. If a match is
allowed to occur, an internal reset will be generated. This will not cause the RST pin to be
driven HIGH.
User’s software then must periodically change (CCAP4H, CCAP4L) to keep a match from
occurring with the PCA timer (CH, CL). This code is given in the WATCHDOG routine
shown below.
In order to hold off the reset, the user has three options:
• Periodically change the compare value so it will never match the PCA timer.
• Periodically change the PCA timer value so it will never match the compare values.
• Disable the Watchdog by clearing the WDTE bit before a match occurs and then
re-enable it.
The first two options are more reliable because the watchdog timer is never disabled as in
option #3. If the program counter ever goes astray, a match will eventually occur and
cause an internal reset. The second option is also not recommended if other PCA
modules are being used. Remember, the PCA timer is the time base for all modules;
changing the time base for other modules would not be a good idea. Thus, in most
applications the first solution is the best option.
;CALL the following WATCHDOG subroutine periodically.
CLR
EA
;Hold off interrupts
MOV
CCAP4L,#00 ;Next compare value is within 255 counts of
current PCA timer value
MOV
CCAP4H,CH
SETB EA
;Re-enable interrupts
RET
This routine should not be part of an interrupt service routine, because if the program
counter goes astray and gets stuck in an infinite loop, interrupts are still serviced and the
Watchdog continues to reset. Thus, the purpose of the Watchdog would be defeated.
Instead, call this subroutine from the main program within 216 count of the PCA timer.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
54 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
6.10 Security bit
The Security Bit protects against software piracy and prevents the contents of the flash
from being read by unauthorized parties in Parallel Programmer mode. It also protects
against code corruption resulting from accidental erasing and programming to the internal
flash memory.
When the Security Bit is activated, all parallel programming commands except for
Chip-Erase are ignored (thus the device cannot be read). However, ISP reading, writing,
or erasing of the user’s code can still be performed if the serial number and length has not
been programmed. Therefore, when a user requests to program the Security Bit, the
programmer should prompt the user and program a serial number into the device.
6.11 Interrupt priority and polling sequence
The device supports eight interrupt sources under a four level priority scheme. Table 43
summarizes the polling sequence of the supported interrupts. Note that the SPI serial
interface and the UART share the same interrupt vector. (See Figure 26).
Table 43.
Interrupt polling sequence
Description
Interrupt flag
Vector address Interrupt
enable bit
Interrupt
priority bit
Service
priority
Wake-up
power-down
External
interrupt 0
IE0
0003H
EX0
PX0/H
1 (highest)
yes
Brownout
-
004BH
EBO
PBO/H
2
no
T0
TF0
000BH
ET0
PT0/H
3
no
External
interrupt 1
IE1
0013H
EX1
PX1/H
4
yes
T1
TF1
001BH
ET1
PT1/H
5
no
PCA
CF/CCFn
0033H
EC
PPCH
6
no
UART/SPI
TI/RI/SPIF
0023H
ES
PS/H
7
no
T2
TF2, EXF2
002BH
ET2
PT2/H
8
no
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
55 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
highest
priority
interrupt
IP/IPH/IPA/IPAH
registers
IE and IEA
registers
0
INT0#
IT0
IE0
1
brownout
interrupt
polling
sequence
TF0
0
INT1#
IT1
IE1
1
TF1
ECF
CF
CCFn
ECCFn
RI
TI
SPIF
SPIE
TF2
EXF2
lowest
priority
interrupt
global
disable
individual
enables
002aaa544
Fig 26. Interrupt structure
Table 44. IEN0 - Interrupt enable register 0 (address A8H) bit allocation
Bit addressable; reset value: 00H.
Bit
Symbol
7
6
5
4
3
2
1
0
EA
EC
ET2
ES
ET1
EX1
ET0
EX0
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
56 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 45.
IEN0 - Interrupt enable register 0 (address A8H) bit descriptions
Bit
Symbol
Description
7
EA
Interrupt Enable Bit: EA = 1 interrupt(s) can be serviced, EA = 0
interrupt servicing disabled.
6
EC
PCA Interrupt Enable bit.
5
ET2
Timer 2 Interrupt Enable.
4
ES
Serial Port Interrupt Enable.
3
ET1
Timer 1 Overflow Interrupt Enable.
2
EX1
External Interrupt 1 Enable.
1
ET0
Timer 0 Overflow Interrupt Enable.
0
EX0
External Interrupt 0 Enable.
Table 46. IEN1 - Interrupt enable register 1 (address E8H) bit allocation
Bit addressable; reset value: 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
-
-
-
EBO
-
-
-
Table 47.
IEN1 - Interrupt enable register 1 (address E8H) bit descriptions
Bit
Symbol
Description
7 to 4
-
Reserved for future use. Should be set to ‘0’ by user programs.
3
EBO
Brownout Interrupt Enable. 1 = enable, 0 = disable.
2 to 0
-
Reserved for future use. Should be set to ‘0’ by user programs.
Table 48. IP0 - Interrupt priority 0 low register (address B8H) bit allocation
Bit addressable; reset value: 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
PPC
PT2
PS
PT1
PX1
PT0
PX0
Table 49.
IP0 - Interrupt priority 0 low register (address B8H) bit descriptions
Bit
Symbol
Description
7
-
Reserved for future use. Should be set to ‘0’ by user programs.
6
PPC
PCA interrupt priority LOW bit.
5
PT2
Timer 2 interrupt priority LOW bit.
4
PS
Serial Port interrupt priority LOW bit.
3
PT1
Timer 1 interrupt priority LOW bit.
2
PX1
External interrupt 1 priority LOW bit.
1
PT0
Timer 0 interrupt priority LOW bit.
0
PX0
External interrupt 0 priority LOW bit.
Table 50. IP0H - Interrupt priority 0 high register (address B7H) bit allocation
Not bit addressable; reset value: 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
PPCH
PT2H
PSH
PT1H
PX1H
PT0H
PX0H
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
57 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 51.
IP0H - Interrupt priority 0 high register (address B7H) bit descriptions
Bit
Symbol
Description
7
-
Reserved for future use. Should be set to ‘0’ by user programs.
6
PPCH
PCA interrupt priority HIGH bit.
5
PT2H
Timer 2 interrupt priority HIGH bit.
4
PSH
Serial Port interrupt priority HIGH bit.
3
PT1H
Timer 1 interrupt priority HIGH bit.
2
PX1H
External interrupt 1 priority HIGH bit.
1
PT0H
Timer 0 interrupt priority HIGH bit.
0
PX0H
External interrupt 0 priority HIGH bit.
Table 52. IP1 - Interrupt priority 1 register (address F8H) bit allocation
Bit addressable; reset value: 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
-
-
PBO
-
-
-
-
Table 53.
IP1 - Interrupt priority 1 register (address F8H) bit descriptions
Bit
Symbol
Description
7 to 5
-
Reserved for future use. Should be set to ‘0’ by user programs.
4
PBO
Brownout interrupt priority bit.
3 to 0
-
Reserved for future use. Should be set to ‘0’ by user programs.
Table 54. IP1H - Interrupt priority 1 high register (address F7H) bit allocation
Not bit addressable; reset value: 00H.
Bit
7
6
5
4
3
2
1
0
Symbol
-
-
-
PBOH
-
-
-
-
Table 55.
IP1H - Interrupt priority 1 high register (address F7H) bit descriptions
Bit
Symbol
Description
7 to 5
-
Reserved for future use. Should be set to ‘0’ by user programs.
4
PBOH
Brownout interrupt priority bit.
3 to 0
-
Reserved for future use. Should be set to ‘0’ by user programs.
6.12 Power-saving modes
The device provides two power saving modes of operation for applications where power
consumption is critical. The two modes are Idle and Power-down, see Table 56.
6.12.1 Idle mode
Idle mode is entered by setting the IDL bit in the PCON register. In Idle mode, the Program
Counter (PC) is stopped. The system clock continues to run and all interrupts and
peripherals remain active. The on-chip RAM and the special function registers hold their
data during this mode.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
58 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
The device exits Idle mode through either a system interrupt or a hardware reset. When
exiting Idle mode via system interrupt, the start of the interrupt clears the IDL bit and exits
Idle mode. After exiting the Interrupt Service Routine, the interrupted program resumes
execution beginning at the instruction immediately following the instruction which invoked
the Idle mode. A hardware reset starts the device similar to a power-on reset.
6.12.2 Power-down mode
The Power-down mode is entered by setting the PD bit in the PCON register. In the
Power-down mode, the clock is stopped and external interrupts are active for level
sensitive interrupts only. SRAM contents are retained during Power-down mode, and the
minimum VDD level is 2.0 V.
The device exits Power-down mode through either an enabled external level sensitive
interrupt or a hardware reset. The start of the interrupt clears the PD bit and exits
Power-down. Holding the external interrupt pin low restarts the oscillator, the signal must
hold low at least 1024 clock cycles before bringing back high to complete the exit. Upon
interrupt signal restored to logic VIH, the interrupt service routine program execution
resumes beginning at the instruction immediately following the instruction which invoked
Power-down mode. A hardware reset starts the device similar to power-on reset.
To exit properly out of Power-down mode, the reset or external interrupt should not be
executed before the VDD line is restored to its normal operating voltage. Be sure to hold
VDD voltage long enough at its normal operating level for the oscillator to restart and
stabilize (normally less than 10 ms).
Table 56.
Power-saving modes
Mode
Initiated by
State of MCU
Idle mode
Software (Set IDL bit in
Clock is running. Interrupts,
PCON) MOV PCON, #01H serial port and timers/counters
are active. Program Counter is
stopped. ALE and PSEN
signals are HIGH level during
Idle. All registers remain
unchanged.
Enabled interrupt or hardware reset. Start of
interrupt clears IDL bit and exits Idle mode,
after the ISR (Interrupt Service Routine)
RETI (Return from Interrupt) instruction,
program resumes execution beginning at
the instruction following the one that invoked
Idle mode. A user could consider placing
two or three NOP (No Operation)
instructions after the instruction that invokes
Idle mode to eliminate any problems. A
hardware reset restarts the device similar to
a power-on reset.
Power-down
mode
Software (Set PD bit in
Clock is stopped. On-chip
PCON) MOV PCON, #02H SRAM and SFR data is
maintained. ALE and PSEN
signals are LOW level during
power-down. External
Interrupts are only active for
level sensitive interrupts, if
enabled.
Enabled external level sensitive interrupt or
hardware reset. Start of interrupt clears PD
bit and exits Power-down mode, after the
ISR RETI instruction program resumes
execution beginning at the instruction
following the one that invoked Power-down
mode. A user could consider placing two or
three NOP instructions after the instruction
that invokes Power-down mode to eliminate
any problems. A hardware reset restarts the
device similar to a power-on reset.
P89LV51RB2_RC2_RD2_5
Product data sheet
Exited by
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
59 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
6.13 System clock and clock options
6.13.1 Clock input options and recommended capacitor values for oscillator
Shown in Figure 27 are the input and output (XTAL1, XTAL2) of an internal inverting
amplifier, which can be configured for use as an on-chip oscillator.
When driving the device from an external clock source, XTAL2 should be left disconnected
and XTAL1 should be driven.
At start-up, the external oscillator may encounter a higher capacitive load at XTAL1 due to
interaction between the amplifier and its feedback capacitance. However, the capacitance
will not exceed 15 pF once the external signal meets the VIL and VIH specifications.
Crystal manufacturer, supply voltage, and other factors may cause circuit performance to
differ from one application to another. C1 and C2 should be adjusted appropriately for
each design. Table 57 shows the typical values for C1 and C2 vs. crystal type for various
frequencies.
Table 57.
Recommended values for C1 and C2 by crystal type
Crystal
C1 = C2
Quartz
20 pF to 30 pF
Ceramic
40 pF to 50 pF
More specific information about on-chip oscillator design can be found in the FlashFlex51
Oscillator Circuit Design Considerations application note.
6.13.2 Clock doubling option
By default, the device runs at 12 clocks per machine cycle (X1 mode). The device has a
clock doubling option to speed up to 6 clocks per machine cycle (see Table 58). Clock
double mode can be enabled either by an external programmer or using IAP. When set,
the EDC bit in FST register will indicate 6-clock mode.
The clock double mode is only for doubling the internal system clock and the internal flash
memory, i.e. EA = 1. To access the external memory and the peripheral devices, careful
consideration must be taken. Also note that the crystal output (XTAL2) frequency will not
be doubled.
C2
XTAL2
n.c.
XTAL2
XTAL1
external
oscillator
signal
XTAL1
C1
VSS
VSS
002aaa545
On-chip oscillator
002aaa546
External clock drive
Fig 27. Oscillator characteristics
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
60 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 58.
Clock doubling features
Device
Standard mode (X1)
Clock double mode (X2)
Clocks per
Maximum
Clocks per
Maximum
machine cycle external clock
machine cycle external clock
frequency (MHz)
frequency (MHz)
P89LV51RB2/RC2/RD2 12
33
6
16
Table 59. FST - Flash status register (address B6) bit allocation
Not Bit addressable; reset value: xxxx x0xxB.
Bit
7
6
5
4
3
2
1
0
Symbol
-
SB
-
-
EDC
-
-
-
Table 60.
FST - Flash status register (address B6) bit descriptions
Bit
Symbol
Description
7
-
Reserved for future use. Should be set to ‘0’ by user programs.
6
SB
Security bit.
5 to 4
-
Reserved for future use. Should be set to ‘0’ by user programs.
3
EDC
Enable double clock.
2 to 0
-
Reserved for future use. Should be set to ‘0’ by user programs.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
61 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
7. Limiting values
Table 61. Limiting values
In accordance with the Absolute Maximum Rating System (IEC 60134).
Parameters are valid over operating temperature range unless otherwise specified. All voltages are with respect to VSS unless
otherwise noted.
Symbol
Parameter
Min
Max
Unit
Tamb(bias)
bias ambient temperature
−55
+125
°C
Tstg
storage temperature
−65
+150
°C
VI
input voltage
on EA pin to VSS
−0.5
+14
V
Vn
voltage on any other pin
except VSS; with respect to
VDD
−0.5
VDD + 0.5
V
IOL(I/O)
LOW-level output current per
input/output pin
pins P1.5, P1.6, P1.7
-
20
mA
all other pins
-
15
mA
total power dissipation per package
based on package heat
transfer, not device power
consumption
-
1.5
W
Max
Unit
Ptot(pack)
Conditions
8. Static characteristics
Table 62. Static characteristics
Tamb = 0 °C to +70 °C or −40 °C to +85 °C; VDD = 2.7 V to 3.6 V; VSS = 0 V.
Symbol
Parameter
Conditions
Min
nendu(fl)
endurance of flash memory
JEDEC Standard A117
[1]
10000
-
cycles
tret(fl)
flash memory retention time
JEDEC Standard A103
[1]
100
-
years
[1]
100 + IDD
-
mA
Ilatch
I/O latch-up current
JEDEC Standard 78
VIL
LOW-level input voltage
2.7 V < VDD < 3.6 V
−0.5
+0.7
V
VIH
HIGH-level input voltage
2.7 V < VDD < 3.6 V
0.2VDD + 0.9
VDD + 0.5
V
0.7VDD
VDD + 0.5
V
-
1.0
V
IOL = 100 µA
-
0.3
V
IOL = 1.6 mA
-
0.45
V
IOL = 3.5 mA
-
1.0
V
XTAL1, RST
VOL
LOW-level output voltage
VDD = 2.7 V; ports 1.5, 1.6,
1.7
IOL = 16 mA
VDD = 2.7 V; ports 1, 2, 3,
except PSEN, ALE
[2][3][4]
VDD = 2.7 V; port 0, PSEN,
ALE
IOL = 200 µA
-
0.3
V
IOL = 3.2 mA
-
0.45
V
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
62 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 62. Static characteristics …continued
Tamb = 0 °C to +70 °C or −40 °C to +85 °C; VDD = 2.7 V to 3.6 V; VSS = 0 V.
Symbol
VOH
Parameter
HIGH-level output voltage
Conditions
Min
Max
Unit
IOH = −10 µA
VDD − 0.3
-
V
IOH = −30 µA
VDD − 0.7
-
V
IOH = −60 µA
VDD − 1.5
-
V
IOH = −200 µA
VDD − 0.3
-
V
IOH = −3.2 mA
VDD − 0.7
-
V
2.35
2.55
V
VDD = 2.7 V; ports 1, 2, 3,
ALE, PSEN
[5]
VDD = 2.7 V; port 0 in
External Bus mode
Vbo
brownout trip voltage
IIL
LOW-level input current
VI = 0.4 V; ports 1, 2, 3
ITHL
HIGH-LOW transition current
VI = 2 V; ports 1, 2, 3
ILI
input leakage current
0.45 V < VI < VDD − 0.3 V;
port 0
Rpd
pull-down resistance
on pin RST
Ciss
input capacitance
1 MHz; Tamb = 25 °C
IDD(oper)
operating supply current
IDD(idle)
IDD(pd)
Idle mode supply current
Power-down mode supply
current
[6]
-
−75
µA
-
−650
µA
-
±10
µA
-
225
kΩ
-
15
pF
fosc = 12 MHz
-
11.5
mA
fosc = 33 MHz
-
30
mA
fosc = 12 MHz
-
8.5
mA
fosc = 33 MHz
-
21
mA
Tamb = 0 °C to +70 °C
-
45
µA
Tamb = −40 °C to +85 °C
-
55
µA
[7]
minimum VDD = 2 V
[1]
This parameter is measured only for initial qualification and after a design or process change that could affect this parameter.
[2]
Under steady state (non-transient) conditions, IOL must be externally limited as follows:
a) Maximum IOL per 8-bit port: 26 mA
b) Maximum IOL total for all outputs: 71 mA
c) If IOL exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to sink current greater than the
listed test conditions.
[3]
Capacitive loading on Ports 0 and 2 may cause spurious noise to be superimposed on the VOL of ALE and Ports 1 and 3. The noise due
to external bus capacitance discharging into the Port 0 and 2 pins when the pins make 1-to-0 transitions during bus operations. In the
worst cases (capacitive loading > 100 pF), the noise pulse on the ALE pin may exceed 0.8 V. In such cases, it may be desirable to
qualify ALE with a Schmitt trigger, or use an address latch with a Schmitt trigger STROBE input.
[4]
Load capacitance for Port 0, ALE and PSEN = 100 pF, load capacitance for all other outputs = 80 pF.
[5]
Capacitive loading on Ports 0 and 2 may cause the VOH on ALE and PSEN to momentarily fall below the VDD − 0.7 V specification when
the address bits are stabilizing.
[6]
Pins of Ports 1, 2 and 3 source a transition current when they are being externally driven from 1 to 0. The transition current reaches its
maximum value when VI is approximately 2 V.
[7]
Pin capacitance is characterized but not tested. Pin EA = 25 pF (max).
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
63 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
001aak852
30
(1)
IDD
(mA)
20
(2)
10
(3)
(4)
0
0
5
10
15
20
25
30
35
internal clock frequency (MHz)
(1) Maximum IDD(oper)
(2) Maximum IDD(idle)
(3) Typical IDD(oper)
(4) Typical IDD(idle)
Fig 28. Supply current versus frequency
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
64 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
9. Dynamic characteristics
Table 63. Dynamic characteristics
Over operating conditions: load capacitance for Port 0, ALE, and PSEN = 100 pF; load capacitance for all other
outputs = 80 pF; Tamb = 0 °C to +70 °C or −40 °C to +85 °C; VDD = 2.7 V to 3.6 V at 33 MHz; VSS = 0 V.[1][2]
Symbol
Parameter
fosc
oscillator frequency
Conditions
Min
Typ
Max
Unit
X1 mode
0
-
33
MHz
X2 mode
0
-
16
MHz
IAP
0.25
-
33
MHz
tLHLL
ALE pulse width
2Tcy(clk) − 15
-
-
ns
tAVLL
address valid to ALE LOW time
Tcy(clk) − 25
-
-
ns
tLLAX
address hold after ALE LOW time
Tcy(clk) − 25
-
-
ns
tLLIV
ALE LOW to valid instruction in time
-
-
4Tcy(clk) − 65
ns
tLLPL
ALE LOW to PSEN LOW time
Tcy(clk) − 25
-
-
ns
tPLPH
PSEN pulse width
Tcy(clk) − 25
-
-
ns
tPLIV
PSEN LOW to valid instruction in time
-
-
3Tcy(clk) − 55
ns
tPXIX
input instruction hold after PSEN time
0
-
-
ns
tPXIZ
input instruction float after PSEN time
-
-
Tcy(clk) − 5
ns
tPXAV
PSEN to address valid time
Tcy(clk) − 8
-
-
ns
tAVIV
address to valid instruction in time
-
-
5Tcy(clk) − 80
ns
tPLAZ
PSEN LOW to address float time
-
-
10
ns
tRLRH
RD LOW pulse width
6Tcy(clk) − 40
-
-
ns
tWLWH
WR LOW pulse width
6Tcy(clk) − 40
-
-
ns
tRLDV
RD LOW to valid data in time
-
-
5Tcy(clk) − 90
ns
tRHDX
data hold after RD time
0
-
-
ns
tRHDZ
data float after RD time
-
-
2Tcy(clk) − 25
ns
tLLDV
ALE LOW to valid data in time
-
-
8Tcy(clk) − 90
ns
tAVDV
address to valid data in time
-
-
9Tcy(clk) − 90
ns
tLLWL
ALE LOW to RD or WR LOW time
3Tcy(clk) − 25
-
3Tcy(clk) + 25
ns
tAVWL
address to RD or WR LOW time
4Tcy(clk) − 75
-
-
ns
tWHQX
data hold after WR time
Tcy(clk) − 27
-
-
ns
tQVWH
data output valid to WR HIGH time
7Tcy(clk) − 70
-
-
ns
tRLAZ
RD LOW to address float time
-
-
0
ns
tWHLH
RD or WR HIGH to ALE HIGH time
Tcy(clk) − 25
-
Tcy(clk) + 25
ns
[1]
Tcy(clk) = 1 / fosc.
[2]
Calculated values are for 6-clock mode only.
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
65 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
9.1 Explanation of symbols
Each timing symbol has 5 characters. The first character is always a ‘T’ (stands for time).
The other characters, depending on their positions, stand for the name of a signal or the
logical status of that signal. The characters are described below:
A — Address
C — Clock
D — Input data
H — Logic level HIGH
I — Instruction (program memory contents)
L — Logic level LOW or ALE
P — PSEN
Q — Output data
R — RD signal
T — Time
V — Valid
W — WR signal
X — No longer a valid logic level
Z — High impedance (Float)
Example:
tAVLL = Address valid to ALE LOW time
tLLPL = ALE LOW to PSEN LOW time
tLHLL
ALE
tPLPH
tAVLL
tLLIV
tLLPL
tPLIV
PSEN
tPXAV
tPLAZ
tLLAX
port 0
tPXIZ
tPXIX
A0 to A7
INSTR IN
A0 to A7
tAVIV
port 2
A8 to A15
A8 to A15
002aaa548
Fig 29. External program memory read cycle
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
66 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
ALE
tWHLH
PSEN
tLLDV
tLLWL
RD
tAVLL
tRLRH
tLLAX
tRHDZ
tRLAZ
tRHDX
tRLDV
A0 to A7
from RI to DPL
port 0
DATA IN
A0 to A7 from PCL
INSTR IN
tAVWL
tAVDV
P2.0 to P2.7 or A8 to A15 from DPH
port 2
A0 to A15 from PCH
002aaa549
Fig 30. External data memory read cycle
tLHLL
ALE
tWHLH
PSEN
tLLWL
WR
tWLWH
tLLAX
tWHQX
tAVLL
tQVWH
port 0
A0 to A7 from RI or DPL
DATA OUT
A0 to A7 from PCL
INSTR IN
tAVWL
port 2
P2[7:0] or A8 to A15 from DPH
A8 to A15 from PCH
002aaa550
Fig 31. External data memory write cycle
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
67 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
Table 64.
External clock drive
Symbol
Parameter
Oscillator
Unit
12 MHz
Variable
Min
Max
Min
Max
fosc
oscillator frequency
-
-
0
33
MHz
Tcy(clk)
clock cycle time
83
-
-
-
ns
tCHCX
clock HIGH time
-
-
0.35Tcy(clk)
0.65Tcy(clk)
ns
tCLCX
clock LOW time
-
-
0.35Tcy(clk)
0.65Tcy(clk)
ns
tCLCH
clock rise time
-
20
-
-
ns
tCHCL
clock fall time
-
20
-
-
ns
tCHCL
tCHCX
tCLCH
tCLCX
Tcy(clk)
002aaa907
Fig 32. External clock drive waveform
Table 65.
Symbol
Serial port timing
Parameter
Oscillator
Unit
12 MHz
Variable
Min
Max
Min
Max
TXLXL
serial port clock cycle time
1.0
-
12Tcy(clk)
-
µs
tQVXH
output data set-up to clock rising edge 700
time
-
10Tcy(clk) − 133
-
ns
tXHQX
output data hold after clock rising
edge time
50
-
2Tcy(clk) − 50
-
ns
tXHDX
input data hold after clock rising edge
time
0
-
0
-
ns
tXHDV
input data valid to clock rising edge
time
-
700
-
10Tcy(clk) − 133
ns
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
68 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
instruction
0
1
2
3
4
5
6
7
8
ALE
TXLXL
clock
tXHQX
tQVXH
output data
0
write to SBUF
input data
1
2
3
4
5
6
7
tXHDX
set TI
tXHDV
valid
valid
valid
valid
valid
valid
valid
valid
clear RI
set RI
002aaa552
Fig 33. Shift register mode timing waveforms
to tester
to DUT
CL
002aaa555
Fig 34. Test load example
VDD
P0
VDD
RST
VDD
IDD
VDD
8
EA
DUT
clock
signal
(n.c.)
XTAL2
XTAL1
VSS
002aaa556
All other pins disconnected
Fig 35. IDD test condition, Active mode
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
69 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
VDD
IDD
VDD
8
P0
RST
VDD
EA
DUT
clock
signal
XTAL2
XTAL1
VSS
(n.c.)
002aaa557
All other pins disconnected
Fig 36. IDD test condition, Idle mode
VDD = 2 V
VDD
P0
RST
DUT
(n.c.)
VDD
IDD
8
VDD
EA
XTAL2
XTAL1
VSS
002aaa558
All other pins disconnected
Fig 37. IDD test condition, Power-down mode
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
70 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
10. Package outline
PLCC44: plastic leaded chip carrier; 44 leads
SOT187-2
eD
eE
y
X
39
A
29
28
40
bp
ZE
b1
w M
44
1
E
HE
pin 1 index
A
A4 A1
e
(A 3)
6
β
18
Lp
k
7
detail X
17
e
v M A
ZD
D
B
HD
v M B
0
5
10 mm
scale
DIMENSIONS (mm dimensions are derived from the original inch dimensions)
A4
A1
e
UNIT A
A3
D(1) E(1)
eD
eE
HD
bp b1
max.
min.
4.57
4.19
mm
inches
0.81
0.66
HE
k
16.66 16.66
16.00 16.00 17.65 17.65 1.22
1.27
16.51 16.51
14.99 14.99 17.40 17.40 1.07
0.51
0.25
3.05
0.53
0.33
0.180
0.02
0.165
0.01
0.12
0.021 0.032 0.656 0.656
0.05
0.013 0.026 0.650 0.650
0.63
0.59
0.63
0.59
Lp
v
w
y
1.44
1.02
0.18
0.18
0.1
ZD(1) ZE(1)
max. max.
2.16
β
2.16
45 o
0.695 0.695 0.048 0.057
0.007 0.007 0.004 0.085 0.085
0.685 0.685 0.042 0.040
Note
1. Plastic or metal protrusions of 0.25 mm (0.01 inch) maximum per side are not included.
REFERENCES
OUTLINE
VERSION
IEC
JEDEC
JEITA
SOT187-2
112E10
MS-018
EDR-7319
EUROPEAN
PROJECTION
ISSUE DATE
99-12-27
01-11-14
Fig 38. Package outline SOT187-2 (PLCC44)
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
71 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
TQFP44: plastic thin quad flat package; 44 leads; body 10 x 10 x 1.0 mm
SOT376-1
c
y
X
A
33
23
34
22
ZE
e
E HE
A A2
w M
(A 3)
A1
θ
bp
pin 1 index
Lp
L
detail X
12
44
11
1
ZD
e
v M A
w M
bp
D
B
HD
v M B
0
2.5
5 mm
scale
DIMENSIONS (mm are the original dimensions)
UNIT
A
max.
A1
A2
A3
bp
c
D (1)
E (1)
e
mm
1.2
0.15
0.05
1.05
0.95
0.25
0.45
0.30
0.18
0.12
10.1
9.9
10.1
9.9
0.8
HD
HE
12.15 12.15
11.85 11.85
L
Lp
v
w
y
1
0.75
0.45
0.2
0.2
0.1
Z D(1) Z E(1)
1.2
0.8
1.2
0.8
θ
7o
o
0
Note
1. Plastic or metal protrusions of 0.25 mm maximum per side are not included.
REFERENCES
OUTLINE
VERSION
IEC
SOT376-1
137E08
JEDEC
JEITA
EUROPEAN
PROJECTION
ISSUE DATE
00-01-19
02-03-14
MS-026
Fig 39. Package outline SOT376-1 (TQFP44)
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
72 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
11. Abbreviations
Table 66.
Abbreviations
Acronym
Description
DUT
Device Under Test
EMI
Electro-Magnetic Interference
IAP
In-Application Programming
ISP
In-System Programming
MCU
Microcontroller Unit
PCA
Programmable Counter Array
PWM
Pulse Width Modulator
RC
Resistance-Capacitance
SFR
Special Function Register
SPI
Serial Peripheral Interface
TTL
Transistor-Transistor Logic
UART
Universal Asynchronous Receiver/Transmitter
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
73 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
12. Revision history
Table 67.
Revision history
Document ID
Release date
Data sheet status
Change notice
Supersedes
P89LV51RB2_RC2_RD2_5
20091215
Product data sheet
-
P89LV51RB2_RC2_RD2-04
Modifications:
•
The format of this data sheet has been redesigned to comply with the new identity
guidelines of NXP Semiconductors.
•
•
Legal texts have been adapted to the new company name where appropriate.
•
•
•
Table 3: Removed sentence “However, Security lock level 4 will disable EA...” for EA
description.
Table 37: Second row, changed “fosc / 6” to “fosc / 2”.
Figure 30: Updated figure.
Figure 31: Updated figure.
P89LV51RB2_RC2_RD2-04 20041202
(9397 750 14342)
Product data
-
P89LV51RB2_RC2_RD2-03
P89LV51RB2_RC2_RD2-03 20041011
(9397 750 14101)
Product data
-
P89LV51RB2_RC2_RD2-02
P89LV51RB2_RC2_RD2-02 20031113
(9397 750 11783)
Product data
-
P89LV51RB2_RC2_RD2-01
P89LV51RB2_RC2_RD2-01 20030630
(9397 750 11669)
Product data
ECN 853-2432 30075 dated 27 June 2003
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
74 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
13. Legal information
13.1 Data sheet status
Document status[1][2]
Product status[3]
Definition
Objective [short] data sheet
Development
This document contains data from the objective specification for product development.
Preliminary [short] data sheet
Qualification
This document contains data from the preliminary specification.
Product [short] data sheet
Production
This document contains the product specification.
[1]
Please consult the most recently issued document before initiating or completing a design.
[2]
The term ‘short data sheet’ is explained in section “Definitions”.
[3]
The product status of device(s) described in this document may have changed since this document was published and may differ in case of multiple devices. The latest product status
information is available on the Internet at URL http://www.nxp.com.
13.2 Definitions
Draft — The document is a draft version only. The content is still under
internal review and subject to formal approval, which may result in
modifications or additions. NXP Semiconductors does not give any
representations or warranties as to the accuracy or completeness of
information included herein and shall have no liability for the consequences of
use of such information.
Short data sheet — A short data sheet is an extract from a full data sheet
with the same product type number(s) and title. A short data sheet is intended
for quick reference only and should not be relied upon to contain detailed and
full information. For detailed and full information see the relevant full data
sheet, which is available on request via the local NXP Semiconductors sales
office. In case of any inconsistency or conflict with the short data sheet, the
full data sheet shall prevail.
13.3 Disclaimers
General — Information in this document is believed to be accurate and
reliable. However, NXP Semiconductors does not give any representations or
warranties, expressed or implied, as to the accuracy or completeness of such
information and shall have no liability for the consequences of use of such
information.
Right to make changes — NXP Semiconductors reserves the right to make
changes to information published in this document, including without
limitation specifications and product descriptions, at any time and without
notice. This document supersedes and replaces all information supplied prior
to the publication hereof.
Suitability for use — NXP Semiconductors products are not designed,
authorized or warranted to be suitable for use in medical, military, aircraft,
space or life support equipment, nor in applications where failure or
malfunction of an NXP Semiconductors product can reasonably be expected
to result in personal injury, death or severe property or environmental
damage. NXP Semiconductors accepts no liability for inclusion and/or use of
NXP Semiconductors products in such equipment or applications and
therefore such inclusion and/or use is at the customer’s own risk.
Applications — Applications that are described herein for any of these
products are for illustrative purposes only. NXP Semiconductors makes no
representation or warranty that such applications will be suitable for the
specified use without further testing or modification.
Limiting values — Stress above one or more limiting values (as defined in
the Absolute Maximum Ratings System of IEC 60134) may cause permanent
damage to the device. Limiting values are stress ratings only and operation of
the device at these or any other conditions above those given in the
Characteristics sections of this document is not implied. Exposure to limiting
values for extended periods may affect device reliability.
Terms and conditions of sale — NXP Semiconductors products are sold
subject to the general terms and conditions of commercial sale, as published
at http://www.nxp.com/profile/terms, including those pertaining to warranty,
intellectual property rights infringement and limitation of liability, unless
explicitly otherwise agreed to in writing by NXP Semiconductors. In case of
any inconsistency or conflict between information in this document and such
terms and conditions, the latter will prevail.
No offer to sell or license — Nothing in this document may be interpreted
or construed as an offer to sell products that is open for acceptance or the
grant, conveyance or implication of any license under any copyrights, patents
or other industrial or intellectual property rights.
Export control — This document as well as the item(s) described herein
may be subject to export control regulations. Export might require a prior
authorization from national authorities.
13.4 Trademarks
Notice: All referenced brands, product names, service names and trademarks
are the property of their respective owners.
14. Contact information
For more information, please visit: http://www.nxp.com
For sales office addresses, please send an email to: [email protected]
P89LV51RB2_RC2_RD2_5
Product data sheet
© NXP B.V. 2009. All rights reserved.
Rev. 05 — 15 December 2009
75 of 76
P89LV51RB2/RC2/RD2
NXP Semiconductors
8-bit microcontrollers with 80C51 core
15. Contents
1
2
3
3.1
4
5
5.1
5.2
6
6.1
6.2
6.2.1
6.2.2
6.2.3
6.2.4
6.2.5
6.2.6
6.2.7
6.2.8
6.3
6.3.1
6.3.2
6.3.3
6.3.4
6.3.5
6.3.6
6.4
6.4.1
6.4.2
6.4.3
6.4.4
6.5
6.5.1
6.5.2
6.5.3
6.5.4
6.5.5
6.6
6.6.1
6.6.2
6.6.3
6.6.4
6.6.5
6.6.6
6.6.7
6.6.8
6.6.9
General description . . . . . . . . . . . . . . . . . . . . . . 1
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Ordering information . . . . . . . . . . . . . . . . . . . . . 2
Ordering options . . . . . . . . . . . . . . . . . . . . . . . . 2
Block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Pinning information . . . . . . . . . . . . . . . . . . . . . . 4
Pinning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Pin description . . . . . . . . . . . . . . . . . . . . . . . . . 6
Functional description . . . . . . . . . . . . . . . . . . 10
Special function registers . . . . . . . . . . . . . . . . 10
Memory organization . . . . . . . . . . . . . . . . . . . 14
Flash program memory bank selection. . . . . . 14
Power-on reset code execution. . . . . . . . . . . . 14
Software reset. . . . . . . . . . . . . . . . . . . . . . . . . 15
Brownout detect reset. . . . . . . . . . . . . . . . . . . 15
Watchdog reset. . . . . . . . . . . . . . . . . . . . . . . . 16
Data RAM memory . . . . . . . . . . . . . . . . . . . . . 16
Expanded data RAM addressing . . . . . . . . . . 16
Dual data pointers. . . . . . . . . . . . . . . . . . . . . . 19
Flash memory IAP . . . . . . . . . . . . . . . . . . . . . 20
Flash organization . . . . . . . . . . . . . . . . . . . . . 20
Boot block (block 1) . . . . . . . . . . . . . . . . . . . . 20
ISP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Using ISP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Using the serial number . . . . . . . . . . . . . . . . . 25
IAP method . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Timers/counters 0 and 1 . . . . . . . . . . . . . . . . . 27
Mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Timer 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Capture mode . . . . . . . . . . . . . . . . . . . . . . . . . 32
Auto-reload mode (up or down counter) . . . . . 33
Programmable clock-out . . . . . . . . . . . . . . . . . 35
Baud rate generator mode . . . . . . . . . . . . . . . 35
Summary of baud rate equations . . . . . . . . . . 37
UART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Mode 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Mode 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Mode 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Mode 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Framing error . . . . . . . . . . . . . . . . . . . . . . . . . 39
More about UART mode 1 . . . . . . . . . . . . . . . 39
More about UART modes 2 and 3 . . . . . . . . . 39
Multiprocessor communications . . . . . . . . . . . 40
Automatic address recognition . . . . . . . . . . . . 40
6.7
6.7.1
6.7.2
6.8
6.9
6.9.1
6.9.2
6.9.3
6.9.4
6.9.5
6.10
6.11
6.12
6.12.1
6.12.2
6.13
6.13.1
SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
SPI features . . . . . . . . . . . . . . . . . . . . . . . . . .
SPI description . . . . . . . . . . . . . . . . . . . . . . . .
Watchdog timer . . . . . . . . . . . . . . . . . . . . . . .
PCA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PCA capture mode. . . . . . . . . . . . . . . . . . . . .
16-bit software timer mode. . . . . . . . . . . . . . .
High-speed output mode . . . . . . . . . . . . . . . .
PWM mode . . . . . . . . . . . . . . . . . . . . . . . . . .
PCA watchdog timer . . . . . . . . . . . . . . . . . . .
Security bit . . . . . . . . . . . . . . . . . . . . . . . . . . .
Interrupt priority and polling sequence . . . . . .
Power-saving modes . . . . . . . . . . . . . . . . . . .
Idle mode . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Power-down mode . . . . . . . . . . . . . . . . . . . . .
System clock and clock options . . . . . . . . . . .
Clock input options and recommended
capacitor values for oscillator . . . . . . . . . . . . .
6.13.2
Clock doubling option . . . . . . . . . . . . . . . . . . .
7
Limiting values . . . . . . . . . . . . . . . . . . . . . . . .
8
Static characteristics . . . . . . . . . . . . . . . . . . .
9
Dynamic characteristics . . . . . . . . . . . . . . . . .
9.1
Explanation of symbols . . . . . . . . . . . . . . . . .
10
Package outline . . . . . . . . . . . . . . . . . . . . . . . .
11
Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . .
12
Revision history . . . . . . . . . . . . . . . . . . . . . . .
13
Legal information . . . . . . . . . . . . . . . . . . . . . .
13.1
Data sheet status . . . . . . . . . . . . . . . . . . . . . .
13.2
Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . .
13.3
Disclaimers. . . . . . . . . . . . . . . . . . . . . . . . . . .
13.4
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . .
14
Contact information . . . . . . . . . . . . . . . . . . . .
15
Contents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42
42
42
45
46
50
51
52
53
54
55
55
58
58
59
60
60
60
62
62
65
66
71
73
74
75
75
75
75
75
75
76
Please be aware that important notices concerning this document and the product(s)
described herein, have been included in section ‘Legal information’.
© NXP B.V. 2009.
All rights reserved.
For more information, please visit: http://www.nxp.com
For sales office addresses, please send an email to: [email protected]
Date of release: 15 December 2009
Document identifier: P89LV51RB2_RC2_RD2_5