P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 43 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
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.
Fig 16. SPI master-slave interconnection
002aaa528
8-BIT SHIFT REGISTER
MSB master LSB
SPI
CLOCK GENERATOR
MISO MISO
MOSI MOSI
SPICLK SPICLK
SS SS
8-BIT SHIFT REGISTER
MSB slave LSB
V
SS
V
DD
Table 28. SPCTL - SPI control register (address D5H) bit allocation
Bit addressable; reset source(s): any reset; reset value: 0000 0000B.
Bit 7 6 5 4 3 2 1 0
Symbol SPIE SPEN DORD MSTR CPOL CPHA PSC1 PSC0
Table 29. 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 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 44 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
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 = f
osc
divided by
004
0116
1064
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 7 6 5 4 3 2 1 0
Symbol SPIF WCOL - - - - - -
Table 32. 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.
Table 29. SPCTL - SPI control register (address D5H) bit descriptions
…continued
Bit Symbol Description
Fig 17. SPI transfer format with CPHA = 0
002aaa529
SPICLK cycle #
(for reference)
SPICLK (CPOL = 0)
SPICLK (CPOL = 1)
MOSI
(from master)
MISO
(from slave)
SS (to slave)
12345678
MSB654321LSB
MSB
654321LSB
P89LV51RB2_RC2_RD2_5 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 05 — 15 December 2009 45 of 76
NXP Semiconductors
P89LV51RB2/RC2/RD2
8-bit microcontrollers with 80C51 core
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 / f
CLK (XTAL1)
where WDTD is the value loaded into the WDTD register and f
osc
is the oscillator
frequency.
Fig 18. SPI transfer format with CPHA = 1
002aaa530
MSB
S
PICLK cycle #
(for reference)
S
PICLK (CPOL = 0)
S
PICLK (CPOL = 1)
MOSI
(from master)
MISO
(from slave)
SS (to slave)
6
12345678
5
MSB654321 LSB
4 3 2 1 LSB
Fig 19. Block diagram of programmable WDT
002aaa531
WDT
UPPER BYTE
WDT reset
internal reset
344064
clks
CLK (XTAL1)
external reset
WDTC
COUNTER
WDTD

P89LV51RD2BA,512

Mfr. #:
Manufacturer:
NXP Semiconductors
Description:
IC MCU 8BIT 64KB FLASH 44PLCC
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union