P89CV51RB2_RC2_RD2_3 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 03 — 25 August 2009 40 of 76
NXP Semiconductors
P89CV51RB2/RC2/RD2
80C51 with 1 kB RAM, SPI
The following examples help to show the versatility of this scheme.
Example 1, slave 0:
Example 2, slave 1:
In the above example 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 bit0=0(forslave0)andbit1=0(forslave1).Thus, both could be addressed
with 1100 0000.
In a more complex system the following could be used to select slaves 1 and 2 while
excluding slave 0.
Example 1, slave 0:
Example 2, slave 1:
Example 3, slave 2:
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 bit1=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 FFH. Upon reset SADDR and SADEN
are loaded with 0s. This produces a given address of all don’t cares as well as a broadcast
SADDR = 1100 0000
SADEN = 1111 1101
Given = 1100 00X0
----------------------------------------------------
SADDR = 1100 0000
SADEN = 1111 1110
Given = 1100 000X
----------------------------------------------------
SADDR = 1100 0000
SADEN = 1111 1001
Given = 1100 0XX0
----------------------------------------------------
SADDR = 1110 0000
SADEN = 1111 1010
Given = 1110 0X0X
----------------------------------------------------
SADDR = 1100 0000
SADEN = 1111 1100
Given = 1100 00XX
----------------------------------------------------
P89CV51RB2_RC2_RD2_3 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 03 — 25 August 2009 41 of 76
NXP Semiconductors
P89CV51RB2/RC2/RD2
80C51 with 1 kB RAM, SPI
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 Serial Peripheral Interface (SPI)
6.7.1 SPI features
Master or slave operation
10 MHz bit frequency (max)
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 serial peripheral interface allows high-speed synchronous data transfer between the
P89CV51RB2/RC2/RD2 and peripheral devices or between several
P89CV51RB2/RC2/RD2 devices. Figure 16 shows the correspondence between master
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 of
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 SPI interrupt
Flag (SPIF) is set. An SPI interrupt request will be generated if the SPI Interrupt Enable bit
(SPIE) and the SPI interrupt enable bit, ES, are both set.
An external master drives the Slave Select input pin (SS) LOW to select the SPI module
as a slave. If SS has not been driven LOW, then the slave SPI unit is not active and the
MOSI pin can also be used as an input port pin.
CPHA and CPOL control the phase and polarity of the SPI clock (SCK). Figure 17 and
Figure 18 show the four possible combinations of these two bits.
P89CV51RB2_RC2_RD2_3 © NXP B.V. 2009. All rights reserved.
Product data sheet Rev. 03 — 25 August 2009 42 of 76
NXP Semiconductors
P89CV51RB2/RC2/RD2
80C51 with 1 kB RAM, SPI
Fig 16. SPI master-slave interconnection
002aaa528
8-BIT SHIFT REGISTER
MSB master LSB
SPI
CLOCK GENERATOR
MISO MISO
MOSI MOSI
SCK SCK
SS SS
8-BIT SHIFT REGISTER
MSB slave LSB
V
SS
V
DD
Table 27. SPCR - SPI control register (address D5H) bit allocation
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 SPR1 SPR0
Table 28. SPCR - SPI control register (address D5H) bit description
Bit Symbol Description
7 SPIE SPI interrupt enable. If both SPIE = 1 and ES = 1, 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).
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 SPR1 SPI clock Rate select bit 1. Along with SPR0 controls the SPICLK rate of the
device when a master. SPR1 and SPR0 have no effect on the slave; see
Table 29.
0 SPR0 SPI clock Rate select bit 0. Along with SPR1 controls the SPICLK rate of the
device when a master. SPR1 and SPR0 have no effect on the slave; see
Table 29.
Table 29. SPCR - SPI control register (address D5H) clock rate selection
SPR1 SPR0 SPICLK = f
osc
divided by
6-clock mode 12-clock mode
002 4
018 16
1 0 32 64
1 1 64 128

P89CV51RD2FA,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