Digi International Inc XBEEPRO2 Manual Do Utilizador

Página de 155
XBee®/XBee‐PRO® ZB RF Modules 
© 2011 Digi International, Inc.
     142
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;
// Set bits 4 - 7 to 0111 as shown in the table above. 
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);
XBee-PRO Applications:
emberSetTxPowerMode(EMBER_TX_POWER_MODE_ALTERNATE); or
emberSetTxPowerMode(EMBER_TX_POWER_MODE_BOOST_AND_ALTERNATE);
XBee-PRO modules must also set a couple of IO lines to enable output power compensation. This is shown 
below. Once the IO lines are initialized (after powerup), the XBee will enable the power amplifier and LNA 
as needed.
GPIO_CFG[7:4]Enabled Functionality Enabled Functionality
0000
GPIO 0, 1, 2, 3, 9, 10, 11, 12
0111
0111GPIO 0, 1, 2, 3, 12
1010
GPIO 0, 1, 2, 3
1101
GPIO 0, 1, 2, 3, 11, 12