XBee®/XBee‐PRO® ZB RF Modules
Enabling GPIO 1 and 2
Most of the remaining sections in this chapter describe how to configure GPIO 1 and 2 to function correctly in
custom applications that run on the XBee and XBee-PRO modules. In order for GPIO pins 1 and 2 to be
configurable, the application must set the GPIO_CFG register to enable GPIO 1 and 2. Bits 4 - 7 in the
GPIO_CFG register control the functionality of various GPIO lines. The following table lists values for these bits
that enable GPIO 1 and 2. Other functionality is affected by these settings. See the EM250 datasheet from
Ember for a complete listing of functionality.
Example 1
The following code enables GPIO 0, 1, 2, 3, 9, 10, 11, and 12 and maintains all other GPIO_CFG bits.
int16u x;
x = GPIO_CFG;
x &= (0xFF0F); // Clear bits 4 - 7
GPIO_CFG = x;
Example 2
The following code enables GPIO 0, 1, 2, 3, and 12 and maintains all other GPIO_CFG bits.
int16u x;
x = GPIO_CFG;
x &= (0xFF0F); // Clear bits 4 - 7
x |= 0x0070;
GPIO_CFG = x;
Detecting XBee vs. XBee-PRO
For some applications, it may be necessary to determine if the code is running on an XBee or an XBee-PRO
device. The GPIO1 pin on the EM250 is used to identify the module type (see table 1-03 in chapter 1). GPIO1 is
connected to ground on the XBee module. The following code could be used to determine if a module is an XBee
or XBee-PRO:
GPIO_DIRCLRL = GPIO(1);// Set GPIO1 as an input
GPIO_PUL |= GPIO(1);// Enable GPIO1 pullup resistor
ModuleIsXBeePro = (GPIO_INL & GPIO(1));//ModuleIsXBeePro > 0 if XBee-PRO, =0 if non-PRO.
Ensuring Optimal Output Power
XBee modules manufactured before February 2008 had an incorrect configuration setting that caused the
default output power mode to be set incorrectly. Digi's ZB and ZNet firmware compensate for this by setting the
output power mode in the application firmware.
Custom applications should call the emberSetTxPowerMode() function to set the output power mode as shown
below:
XBee Applications
emberSetTxPowerMode(EMBER_TX_POWER_MODE_DEFAULT); or
emberSetTxPowerMode(EMBER_TX_POWER_MODE_BOOST);
© 2012 Digi International, Inc.
GPIO_CFG[7:4]Enabled Functionality Enabled Functionality
0000
0111
1010
1101
// Set bits 4 - 7 to 0111 as shown in the table above.
GPIO 0, 1, 2, 3, 9, 10, 11, 12
0111GPIO 0, 1, 2, 3, 12
GPIO 0, 1, 2, 3
GPIO 0, 1, 2, 3, 11, 12
141