Operation
SPI operation
XBee/XBee-PRO S2C 802.15.4 RF Module User Guide
53
SPI_ATTN
: The device asserts this pin low when it has data to send to the SPI master. When you
configure this pin for SPI operations, it is an output (not tri-stated). This signal alerts the master that
the slave has data queued to send. The device asserts this pin as soon as data is available to send to
the SPI master and it remains asserted until the SPI master has clocked out all available data.
SPI parameters
Most host processors with SPI hardware allow you to set the bit order, clock phase and polarity. For
communication with all XBee/XBee-PRO S2C 802.15.4 RF Modules, the host processor must set these
options as follows:
n
Bit order: send MSB first
n
Clock phase (CPHA): sample data on first (leading) edge
n
Clock polarity (CPOL): first (leading) edge rises
All XBee/XBee-PRO S2C 802.15.4 RF Modules use SPI mode 0 and MSB first. Mode 0 means that data is
sampled on the leading edge and that the leading edge rises. MSB first means that bit 7 is the first bit
of a byte sent over the interface.
SPI and API mode
The SPI only operates in API mode 1. The SPI does not support Transparent mode or API mode 2 (with
escaped characters). This means that the
AP
configuration only applies to the UART interface and is
ignored while using the SPI.
Full duplex operation
When using SPI on the XBee/XBee-PRO S2C 802.15.4 RF Module the device uses API operation without
escaped characters to packetize data. The device ignores the configuration of
AP
because SPI does
not operate in any other mode. SPI is a full duplex protocol, even when data is only available in one
direction. This means that whenever a device receives data, it also transmits, and that data is
normally invalid. Likewise, whenever a device transmits data, invalid data is probably received. To
determine whether or not received data is invalid, the firmware places the data in API packets.
SPI allows for valid data from the slave to begin before, at the same time, or after valid data begins
from the master. When the master sends data to the slave and the slave has valid data to send in the
middle of receiving data from the master, a full duplex operation occurs, where data is valid in both
directions for a period of time. Not only must the master and the slave both be able to keep up with
the full duplex operation, but both sides must honor the protocol.
The following figure illustrates the SPI interface while valid data is being sent in both directions.