Digi, Digi International, the Digi logo, XBee(R) and XBee-PRO(R) are trademarks or registered trademarks of Digi International Inc. in the United Sates and other couuntries worldwide. ZigBee(R) is a registered trademark of the ZigBee alliance. All
other trademarks mentioned in this document are the property of their respective owners.
Information in this document is subject to change without notice and does not represent a commitment on the part of Digi
International.
Digi provides this document “as is,” without warranty of any kind, expressed or implied, including, but not limited to, the
implied warranties of fitness or merchantability for a particular purpose. Digi may make improvements and/or changes in this
manual or in the product(s) and/or the program(s) described in this manual at any time.
This product could include technical inaccuracies or typographical errors. Changes are periodically made to the information
herein; these changes may be incorporated in new editions of the publication.
For basic information to help get you started on the XBee/XBee-PRO ZB RF Module, navigate to the Getting Started Guide at
digi.com/support. Enter the keyword 'XBee-PRO ZB' and select the Documentation tab. Under the Documentation tab, you
will find the XBee-PRO ZB RF Module Development Kit Getting Started Guide.
This manual describes the operation of the XBee/XBee-PRO ZB RF module, which consists of ZigBee firmware loaded
onto XBee S2C and PRO S2C hardware.
®
XBee
and XBee-PRO® ZB embedded RF modules provide wireless connectivity to end-point devices in ZigBee mesh
networks. Utilizing the ZigBee PRO Feature Set, these modules are interoperable with other ZigBee devices, including
devices from other vendors. With the XBee, users can have their ZigBee network up-and-running in a matter of minutes
without configuration or addtional development.
The XBee/XBee-PRO ZB modules are compatible with other devices that use XBee “ZB” technology. These include ConnectPortX gateways, XBee and XBee-PRO Adapters, Wall Routers, XBee Sensors, and other products with the “ZB” name.
Worldwide Acceptance
• FCC Approval (USA) Refer to Appendix A for FCC Requirements. Systems that
contain XBee/XBee-PRO ZB RF Modules inherit Digi Certifications.
• ISM (Industrial, Scientific & Medical) 2.4 GHz frequency band
• Manufactured under ISO 9001:2000 registered standards
• XBee/XBee-PRO ZB RF Modules are optimized for use in US, Canada, Australia, Europe (XBee
only) and Japan (XBee only). Contact Digi for a complete list of agency approvals.
What’s New in 40xx Firmware
• An alternative serial port is available using SPI slave mode operation.
• Six software images (Coordinator AT, Coordinator API, Router AT, Router API, End Device AT,
and End Device API) are combined into a single software.
• Fragmentation is now available in both API mode and transparent mode.
• P3 (DOUT), P4 (DIN), D8 (SleepRq), and D9 (On-Sleep
• Both pull-up and pull-down resistors can now be applied to pins configured for inputs.
• 401D - ATVL command added for long version information
• 401E - ATDO command added for configuring device options
• 4020 - ATAS command added for Active Scan
• 4021 - Self addressed Tx Status messages return a status code of 0x23
• ATDO has HIGH_RAM_CONCENTRATOR and NO_ACK_IO_SAMPLING options added.
• 4040 - Binding and Multicasting transmissions are supported.
• AT&X command added to clear binding and group tables.
-26 to +8 dBm 0 to +18 dBm-26 to +8 dBm+1 to +19 dBm
XBee-PRO (Surface
Mount)
XBee (Through-hole)XBee-PRO (Through-hole)
Serial Communications Specifications of the XBee ZigBee RF Module
XBee RF modules support both UART (Universal Asynchronous Receiver / Transmitter) and SPI (Serial
Peripheral Interface) serial connections.
UART
The SC1 (Serial Communication Port 1) of the Ember 357 is connected to the UART port.
UARTPinAssignments
SpecificationsModule Pin Number
UART PinsXBee (Surface Mount)XBee (Through-hole)
DOUT32
DIN / CONFIG
/ DIO72512
CTS
/ DIO62916
RTS
More information on UART operation is found in the UART section in Chapter 2.
43
SPI
The SC2 (Serial Communication Port 2) of the Ember 357 is connected to the SPI port.
SPIPinAssignments
SpecificationsModule Pin Number
SPI PinsXBee (Surface Mount)XBee (Through-hole)
SPI_SCLK1418
SPI_SSEL
SPI_MOSI1611
SPI_MISO174
For more information on SPI operation, see the SPI section in Chapter 2.
1517
GPIO Specifications
XBee RF modules have 15 GPIO (General Purpose Input / Output) ports available. The exact list will depend on
the module configuration, as some GPIO pads are used for purposes such as serial communication.
See GPIO section for more information on configuring and using GPIO ports.
Output source/sink current for pad numbers 3, 4, 5, 10, 12, 14, 15, 16, 17,
25, 26, 28, 29, 30, and 32 on the SMT modules
Output source/sink current for pin numbers 2, 3, 4, 9, 12, 13, 15, 16, 17,
and 19 on the TH modules
Output source/sink current for pad numbers 7, 8, 24, 31, and 33 on the
SMT modules
Output source/sink current for pin numbers 6, 7, 11, 18, and 20 on the TH
modules
Total output current (for GPIO pads)40 mA
Hardware Specifications for Programmable Variant
If the module has the programmable secondary processor, add the following table values to the specifications
listed on page 8. For example, if the secondary processor is running at 20 MHz and the primary processor is in
recieve mode then the new current value will be I
The following table shows how the EM357 pins are used on the XBee.
EM357 Pin #EM357 Pin Name XBee (SMT) Pad # XBee (TH) Pin #Other Usage
12RST65Programming
18PA787
19PB32916Used for UART
20PB42512Used for UART
21PA0 / SC2MOSI1611Used for SPI
22 PA1 / SC2MISO174Used for SPI
24 PA2 / SC2SCLK1418Used for SPI
25PA3 / SC2SSEL
26PA4 / PTI_EN3219OTA packet tracing
27
29PA676
30PB1 / SC1TXD32Used for UART
31PB2 / SC1RXD43Used for UART
33PC2 / JTDO / SWO2613JTAG (see Writing Custom Firmware section)
34PC3 / JTDI2815JTAG (see Writing Custom Firmware section)
35PC4 / JTMS / SWDIO54JTAG (see Writing Custom Firmware section)
36PB0109
38 PC1 / ADC33017
41 PB7 / ADC23118
42 PB6 / ADC13320
43PB5 / ADC0Temperature sensor on PRO version
PA5 / PTI_DATA /
BOOTMODE
1517Used for SPI
12NA
OTA pacet tracing, force embedded serial bootloader, and SPI
attention line
NOTE: Some lines may not go to the external XBee pins in the programmable secondary processor version.
Design Notes for the XBee ZigBee RF Module
The XBee modules do not specifically require any external circuitry or specific connections for proper
operation. However, there are some general design guidelines that are recommended for help in
troubleshooting and building a robust design.
Power Supply Design
Poor power supply can lead to poor radio performance, especially if the supply voltage is not kept within
tolerance or is excessively noisy. To help reduce noise, we recommend placing both a 1F and 8.2pF capacitor
as near to (pad 2/SMT, pin 1/TH) on the PCB as possible. If using a switching regulator for your power supply,
switching frequencies above 500kHz are preferred. Power supply ripple should be limited to a maximum 50mV
peak to peak.
Note – For designs using the programmable modules, an additional 10F decoupling cap is recommended near
(pad 2/SMT, pin 1/TH) of the module. The nearest proximity to (pad 2/SMT, pin 1/TH) of the three caps should
be in the following order: 8.2pf, 1F followed by 10F.
Recommended Pin Connections
The only required pin connections are VCC, GND, DOUT and DIN. To support serial firmware updates, VCC,
GND, DOUT, DIN, RTS, and DTR should be connected.
All unused pins should be left disconnected. All inputs on the radio can be pulled high or low with 30k internal
pull-up or pull-down resistors using the PR and PD software commands. No specific treatment is needed for
unused outputs.
For applications that need to ensure the lowest sleep current, unconnected inputs should never be left
floating. Use internal or external pull-up or pull-down resistors, or set the unused I/O lines to outputs.
Other pins may be connected to external circuitry for convenience of operation, including the Associate LED
pad (pad 28/SMT, pin 15/TH) and the Commissioning pad (pad 33/SMT, pin 20/TH). The Associate LED pad
will flash differently depending on the state of the module to the network, and a pushbutton attached to pad
33 can enable various join functions without having to send serial port commands. Please see the
commissioning pushbutton and associate LED section in chapter 7 for more details. The source and sink
capabilities are limited to 4mA for pad numbers 3, 4, 5, 10, 12, 14, 15, 16, 17, 25, 26, 28, 29, 30 and 32, and
8mA for pad numbers 7, 8, 24, 31 and 33 on the SMT module. The source and sink capabilities are limited to
4mA for pin numbers 2, 3, 4, 9, 12, 13, 15, 16, 17, and 19, and 8mA for pin numbers 6, 7, 11, 18, and 20 on
the TH module.
The VRef pad (pad 27) is only used on the programmable versions of the SMT modules. For the TH modules, a
VRef pin (Pin #14) is used. For compatibility with other XBee modules, we recommend connecting this pin to
a voltage reference if analog sampling is desired. Otherwise, connect to GND.
Board Layout
XBee modules are designed to be self sufficient and have minimal sensitivity to nearby processors, crystals or
other PCB components. As with all PCB designs, Power and Ground traces should be thicker than signal traces
and able to comfortably support the maximum current specifications. A recommended PCB footprint for the
module can be found in Appendix C. No other special PCB design considerations are required for integrating
XBee radios except in the antenna section.
The choice of antenna and antenna location is very important for correct performance. With the exception of
the RF Pad variant, XBees do not require additional ground planes on the host PCB. In general, antenna
elements radiate perpendicular to the direction they point. Thus a vertical antenna emits across the horizon.
Metal objects near the antenna cause reflections and may reduce the ability for an antenna to radiate
efficiently. Metal objects between the transmitter and receiver can also block the radiation path or reduce the
transmission distance, so external antennas should be positioned away from them as much as possible. Some
objects that are often overlooked are metal poles, metal studs or beams in structures, concrete (it is usually
reinforced with metal rods), metal enclosures, vehicles, elevators, ventilation ducts, refrigerators, microwave
ovens, batteries, and tall electrolytic capacitors.
Design Notes for PCB Antenna Modules
PCB Antenna modules should not have any ground planes or metal objects above or below the antenna.
For best results, the module should not be placed in a metal enclosure, which may greatly reduce the
range. The module should be placed at the edge of the PCB on which it is mounted. The ground, power
and signal planes should be vacant immediately below the antenna section. The drawings on the
following pages illustrate important recommendations when designing with PCB antenna modules. It
should be noted that for optimal performance, this module should not be mounted on the RF Pad
footprint described in the next section because the footprint requires a ground plane within the PCB
Antenna keep out area.
The RF Pad is a soldered antenna connection. The RF signal travels from pin 36 on the module to the
antenna through an RF trace transmission line on the PCB. Please note that any additional components
between the module and antenna will violate modular certification. The RF trace should have a
controlled impedance of 50 ohms. We recommend using a microstrip trace, although coplanar
waveguide may also be used if more isolation is needed. Microstrip generally requires less area on the
PCB than coplanar waveguide. Stripline is not recommended because sending the signal to different PCB
layers can introduce matching and performance problems.
It is essential to follow good design practices when implementing the RF trace on a PCB. The following
figures show a layout example of a host PCB that connects an RF Pad module to a right angle, through
hole RPSMA jack. The top two layers of the PCB have a controlled thickness dielectric material in
between. The second layer has a ground plane which runs underneath the entire RF Pad area. This
ground plane is a distance d, the thickness of the dielectric, below the top layer. The top layer has an RF
trace running from pin 36 of the module to the RF pin of the RPSMA connector. The RF trace's width
determines the impedance of the transmission line with relation to the ground plane. Many online tools
can estimate this value, although the PCB manufacturer should be consulted for the exact width.
Assuming d=0.025", and that the dielectric has a relative permittivity of 4.4, the width in this example
will be approximately 0.045" for a 50 ohm trace. This trace width is a good fit with the module
footprint's 0.060" pad width. Using a trace wider than the pad width is not recommended, and using a
very narrow trace (under 0.010") can cause unwanted RF loss. The length of the trace is minimized by
placing the RPSMA jack close to the module. All of the grounds on the jack and the module are
connected to the ground planes directly or through closely placed vias. Any ground fill on the top layer
should be spaced at least twice the distance d (in this case, at least 0.050") from the microstrip to
minimize their interaction.
Implementing these design suggestions will help ensure that the RF Pad module performs to its
specifications.
The modules with the programmable option have a secondary processor with 32k of flash and 2k of RAM. This
allows module integrators to put custom code on the XBee module to fit their own unique needs. The DIN,
DOUT, RTS, CTS, and RESET lines are intercepted by the secondary processor to allow it to be in control of the
data transmitted and received. All other lines are in parallel and can be controlled by either the EM357 or the
MC9SO8QE micro (see Block Diagram for details). The EM357 by default has control of certain lines. These
lines can be released by the EM357 by sending the proper command(s) to disable the desired DIO line(s) (see
XBee Command Reference Tables).
In order for the secondary processor to sample with ADCs, the XBee VREF pin (27/SMT, 14/TH) must be
connected to a reference voltage.
Digi provides a bootloader that can take care of programming the processor over the air or through the serial
interface. This means that over the air updates can be supported through an XMODEM protocol. The processor
can also be programmed and debugged through a one wire interface BKGD (Pin 9/SMT, Pin 8/TH).
The XBee Programmable module is equipped with a Freescale MC9S08QE32 application processor. This
application processor comes with a supplied bootloader. This section describes how to interface the customer's
application code running on this processor to the XBee Programmable module's supplied bootloader.
The first section discusses how to initiate firmware updates using the supplied bootloader for wired and overthe-air updates.
Bootloader Software Specifics
Memory Layout
Figure 1 shows the memory map for the MC9S08QE32 application processor.
The supplied bootloader occupies the bottom pages of the flash from 0xF200 to 0xFFFF. Application
code cannot write to this space.
The application code can exist in Flash from address 0x8400 to 0xF1BC. 1k of Flash from 0x8000 to
0x83FF is reserved for Non Volatile Application Data that will not be erased by the bootloader during a
flash update.
A portion of RAM is accessible by both the application and the bootloader. Specifically, there is a shared
data region used by both the application and the bootloader that is located at RAM address 0x200 to
0x215. Application code should not write anything to BLResetCause or AppResetCause unless
informing the bootloader of the impending reset reason. The Application code should not clear
BLResetCause unless it is handling the unexpected reset reason.
To prevent a malfunctioning application from running forever, the Bootloader increments BLResetCause
after each watchdog or illegal instruction reset. If this register reaches above 0x10 the bootloader will
stop running the application for a few minutes to allow an OTA or Local update to occur. If no update is
initiated within the time period, BLResetCause is cleared and the application is started again. To
prevent unexpected halting of the application, the application shall clear or decrement BLResetCause
just before a pending reset. To disable this feature, the application shall clear BLResetCause at the
start of the application.
Upon reset of any kind, the execution control begins with the bootloader.
If the reset cause is Power-On reset (POR), Pin reset (PIN), or Low Voltage Detect (LVD) reset (LVD)
the bootloader will not jump to the application code if the override bits are set to RTS(D7)=1,
DTR(D5)=0, and DIN(B0)=0. Otherwise, the bootloader writes the reset cause "NOTHING" to the
shared data region, and jumps to the Application.
Reset causes are defined in the file common. h in an enumeration with the following definitions:
// 0x0000 to 0x00FF are considered valid for APP use.
APP_CAUSE_USE255 = 0x00FF,
APP_CAUSE_FIRMWARE_UPDATE = 0x5981,
APP_CAUSE_BYPASS_MODE = 0x4682,
APP_CAUSE_BOOTLOADER_MENU = 0x6A18,
} APP_RESET_CAUSES;
Otherwise, if the reset cause is a "watchdog" or other reset, the bootloader checks the shared memory
region for the APP_RESET_CAUSE. If the reset cause is:
1."APP_CAUSE_NOTHING" or 0x0000 to 0x00FF, the bootloader increments the
BL_RESET_CAUSES, verifies that it is still less than BL_CAUSE_BAD_APP, and jumps back to
the application. If the Application does not clear the BL_RESET_CAUSE, it can prevent an
infinite loop of running a bad application that continues to perform illegal instructions or
watchdog resets.
2."APP_CAUSE_FIRMWARE_UPDATE", the bootloader has been instructed to update the
application "over-the-air" from a specific 64-bit address. In this case, the bootloader will
attempt to initiate an Xmodem transfer from the 64-bit address located in shared RAM.
3."APP_CAUSE_BYPASS_MODE", the bootloader executes bypass mode. This mode passes the
local UART data directly to the EM357 allowing for direct communication with the EM357.
The only way to exit bypass mode is to reset or power cycle the module.
If none of the above is true, the bootloader will enter "Command mode". In this mode, users can
initiate firmware downloads both wired and over-the-air, check application/bootloader version strings,
and enter Bypass mode.
Application version string
Figure 1 shows an "Application version string pointer" area in application flash which holds the pointer
to where the application version string resides. The application's linker command file ultimately
determines where this string is placed in application flash.
It is preferable that the application version string be located at address 0x8400 for MC9S08QE32 parts.
The application string can be any characters terminated by the NULL character (0x00). There is not a
strict limit on the number of characters in the string, but for practical purposes should be kept under
100 bytes including the terminating NULL character. During an update the bootloader erases the entire
application from 0x8400 on. The last page has the vector table specifically the redirected reset vector.
The version string pointer and reset vector are used to determine if the application is valid.
Application Interrupt Vector table and Linker Command File
Since the bootloader flash region is read-only, the interrupt vector table is redirected to the region
0xF1C0 to 0xF1FD so that application developers can use hardware interrupts. Note that in order for
Application interrupts to function properly, the Application's linker command file (*.prm extension)
must be modified appropriately to allow the linker to place the developers code in the correct place in
memory. For example, the developer desires to use the serial communications port SCI1 receive
interrupt. The developer would add the following line to the Codewarrior linker command file for the
project:
VECTOR ADDRESS 0x0000F1E0 vSci1Rx
This will inform the linker that the interrupt function "vSci1Rx()" should be placed at address
0x0000F1E0. Next, the developer should add a file to their project "vector_table.c" that creates an
array of function pointers to the ISR routines used by the application.
extern void _Startup(void);/* _Startup located in Start08.c */
The interrupt routines themselves can be defined in separate files. The "vDummyIsr" function is used
in conjunction with "iWritetoSci1" for debugging purposes.
Bootloader Menu Commands
The bootloader accepts commands from both the local UART and OTA. All OTA commands sent must be
Unicast with only 1 byte in the payload for each command. A response will be returned to the sender. All
Broadcast and multiple byte OTA packets are dropped to help prevent general OTA traffic from being
interpreted as a command to the bootloader while in the menu.
The bootloader provides a "bypass" mode of operation that essentially connects the SCI1 serial
communications peripheral of the freescale mcu to the EM357's serial Uart channel. This allows direct
communication to the EM357 radio for the purpose of firmware and radio configuration changes. Once
in bypass mode, the XCTU utility can change modem configuration and/or update EM357 firmware.
Bypass mode automatically handles any baud rate up to 115.2kbps. Note that this command is
unavailable when module is accessed remotely.
Update Firmware - "F"
The "F" command initiates a firmware download for both wired and over-the-air configurations.
Depending on the source of the command (received via Over the Air or local UART), the download will
proceed via wired or over-the-air respectively.
Adjust Timeout for Update Firmware - "T"
The "T" command changes the timeout before sending a NAK by Base-Time*2^(T). The Base-Time for
the local UART is different than the Base-Time for Over the Air. During a firmware update, the
bootloader will automatically increase the Timeout if repeat packets are received or multiple NAKs for
the same packet without success occur.
Application Version String - "A"
The "A" command provides the version of the currently loaded application. If no application is present,
"Unkown" will be returned.
Bootloader Version String - "V"
The "V" command provides the version of the currently loaded bootloader. The version will return a
string in the format BLFFF-HHH-XYZ_DDD where FFF represents the Flash size in kilo bytes, HHH is the
hardware, XYZ is the version, and DDD is the preferred XMODEM packet size for updates. Double the
preferred packet size is also possible, but not guaranteed. For example "BL032-2B0-023_064" will take
64 byte CRC XMODEM payloads and may take 128 byte CRC XMODEM payloads also. In this case, both
64 and 128 payloads are handled, but the 64 byte payload is preferred for better Over the Air
reliability.
Bootloader Version BL032-2x0-025_064 only operates at 9600 baud on the local UART as well as
communications to the EM357 Radio. A newer version of the Bootloader BL032-2x0-033_064 or newer
BL032-2B0-XXX_064 has changed the baud rate to 115200 between the Programmable and the EM357
Radio. The EM357 is also set to 115200 as the default baud rate. The default rate of the programmable
local UART is also set to 115200, however, the local UART has an auto baud feature added to detect if
the UART is at the wrong baud rate. If a single character is sent, it will automatically switch to 115200
or 9600 baud.
Firmware Updates
Wired Updates
A user can update their application using the bootloader in a wired configuration with the following
steps:
a. Plug XBee programmable module into a suitable serial port on a PC.
b. Open a hyperterminal (or similar dumb terminal application) session with 115200 baud, no parity, and 8 data bits with one stop bit.
c. Hit Enter to display the bootloader menu.
d. Hit the "F" key to initiate a wired firmware update.
e. A series of "C" characters Will be displayed within the hyperterminal window. At this point,
select the "transfer->send file" menu item. Select the desired flat binary output file.
f. Select "Xmodem" as the protocol.
g. Click "Send" on the "Send File" dialog. The file will be downloaded to the XBee Programmable
module. Upon a successful update, the bootloader will jump to the newly loaded application.
Over-The-Air updates
A user can update their application using the bootloader in an "over-the-air" configuration with the
following steps…(This procedure assumes that the bootloader is running and not the application. The
EM357 baud rate of the programmable module must be set to 115200 baud. The
bootloader only operates at 115200 baud between the Radio and programmable bootloader. The
application must be programmed with some way to support returning to the bootloader in order to
support Over the Air (OTA) updates without local intervention.)
a. The XBee module sending the file OTA (Host module) should be set up with a series 2 Xbee
module with transparent mode firmware.
b. The XBee Programmable module receiving the update (remote module) is configured with API
firmware.
c. Open a hyperterminal session to the host module with no parity, no hardwareflow control, 8
data bits and 1 stop bit. (The host module does not have to operate at the same baud rate as the
remote module.) For faster updates and less latency due to the UART, set the host module to a
faster baud rate. (i.e. 115200)
d.Enter 3 pluses "+++" to place the EM357 in command mode. (or XCTU’s “Modem Configuration”
tab can be used to set the correct parameters)
e. Set the Host Module destination address to the target module’s 64 bit address that the host
module will update (ATDH aabbccdd, ATDL eeffgghh, ATCN, where aabbccddeeffgghh is the hexadecimal 64 bit address of the target module).
f. Hit Enter and the bootloader command menu will be displayed from the remote module. (Note
that the option "B" doesn't exist for OTA)
g. Hit the "F" key to cause the remote module to request the new firmware file over-the-air.
h. The host module will begin receiving "C" characters indicating that the remote module is
requesting an Xmodem CRC transfer. Using XCTU or another terminal program, Select "XMODEM"
file transfer. Select the Binary file to upload/transfer. Click Send to start the transfer. At the conclusion of a successful transfer, the bootloader will jump to the newly loaded application.
P&E Micro provides a background debug tool that allows flashing applications on the MC9S08QE parts
through their background debug mode port. By default, the Codewarrior tool produces an "ABS" output
file for use in programming parts through the background debug interface. The programmable XBee
from the factory has the BKGD debugging capability disabled. In order to debug, a bootloader with the
debug interface enabled needs to be loaded on the secondary processor or a stand-alone app needs to
be loaded.
Bootloader updates
The supplied bootloader requires files in a "flat binary" format which differs from the default ABS file
produced. The Codewarrior tool also produces a S19 output file. In order to successfully flash new
applications, the S19 file must be converted into the flat binary format. Utilities are available on the
web that will convert S19 output to "BIN" outputs. Often times, the "BIN" file conversion will pad the
addresses from 0x0000 to the code space with the same number. (Often 0x00 or 0xFF) These extra
bytes before the APP code starts will need to be deleted from the bin file before the file can be
transferred to the bootloader.
XBee RF Modules interface to a host device through a serial port. Through its serial port, the module can
communicate with any logic and voltage compatible UART, through a level translator to any serial device (for
example, through a RS-232 or USB interface board), or through a Serial Peripheral Interface, which is a synchronous
interface to be described later.
Two Wire serial Interface (TWI) is also available, but not supported by Digi. For information on the TWI, see the
EM357 specification.
UART Data Flow
Devices that have a UART interface can connect directly to the pins of the RF module as shown in the figure
below.
Data enters the module UART through the DIN (pin 4) as an asynchronous serial signal. The signal should
idle high when no data is being transmitted.
Each data byte consists of a start bit (low), 8 data bits (least significant bit first) and a stop bit (high). The
following figure illustrates the serial bit pattern of data passing through the module.
Serial communications depend on the two UARTs (the microcontroller's and the RF module's) to be
configured with compatible settings (baud rate, parity, start bits, stop bits, data bits).
The UART baud rate, parity, and stop bits settings on the XBee module can be configured with the BD, NB,
and SB commands respectively. See the command table in chapter 10 for details.
XBee ZigBee SPI Communications
The XBee modules support SPI communications in slave mode. Slave mode receives the clock signal and data
from the master and returns data to the master. The SPI port uses the following signals on the XBee:
• SPI_MOSI (Master Out, Slave In) - inputs serial data from the master
• SPI_MISO (Master In, Slave Out) - outputs serial data to the master
• SPI_SCLK (Serial Clock) - clocks data transfers on MOSI and MISO
•SPI_SSEL (Slave Select) - enables serial communication with the slave
The above four pins are standard for SPI. This module also supports an additional pin, which may be configured
to alert the SPI master when it has data to send. This pin is called SPI_ATTN
(through polling or interrupts), it can know when it needs to receive data from the module. SPI_ATTN
whenever it has data to send and it remains asserted until all available data has been shifted out to the SPI
master.
In this mode, the following apply:
• Data/Clock rates of up to 5 Mbps are possible
• Data is MSB first
• Frame Format mode 0 is used (see below)
. If the master monitors this pin
asserts
FrameFormatforSPICommunications
SPI Operation
When the slave select (SPI_SSEL) signal is asserted by the master, SPI transmit data is driven to the output
pin (SPI_MISO), and SPI data is received from the input pin SPI_MOSI. The SPI_SSEL
asserted to enable the transmit serializer to drive data to the output signal SPI_MISO. A rising edge on
SPI_SSEL resets the SPI slave shift registers.
If the SPI_SCLK is present, the SPI_MISO line is always driven whether with or without the SPI_SSEL
driven. This is a known issue with the Ember EM357 chip, and makes additional hardware necessary if
multiple slaves are using the same bus as the XBee.
If the input buffer is empty, the SPI serializer transmits a busy token (0xFF). Otherwise, all transactions on
the SPI port use API operation. See Chapter 9 - API Operation for more information.
The SPI slave controller must guarantee that there is time to move new transmit data from the transmit
buffer into the hardware serializer. To provide sufficient time, the SPI slave controller inserts a byte of
padding at the start of every new string of transmit data. Whenever the transmit buffer is empty and data
is placed into the transmit buffer, the SPI hardware inserts a byte of padding onto the front of the
transmission as if this byte were placed there by software.
Serial Port Selection
In the default configuration the UART and SPI ports will both be configured for serial port operation.
If DOUT is held low during boot, then only SPI will be used. If both interfaces are configured, serial data will
go out the UART until the SPI_SSEL
the SPI interface.
If only the UART is enabled, then only the UART will be used, and SPI_SSEL
is enabled, then only the SPI will be used.
If neither serial port is enabled, the module will not support serial operations and all communications must
occur over the air. All data that would normally go to the serial port is discarded.
signal is asserted. Thereafter, all serial communications will operate on
will be ignored. If only the SPI
pin has to be
line
XBee ZigBee Serial Buffers
The XBee modules maintain small buffers to collect received serial and RF data, which is illustrated in the figure
below. The serial receive buffer collects incoming serial characters and holds them until they can be processed.