Analog and digital IO lines RSSI PWM
XBee/XBee-PRO ZigBee RF Modules User Guide 107
IO examples
Example 1: configure the following IO settings on the XBee
Configure AD1/DIO1 as a digital input with pullup resistor enabled
Configure AD2/DIO2 as an analog input
Configure DIO4 as a digital output, driving high.
To configure AD1/DIO1 as an input, issue the ATD1 command with a parameter of 3 ("ATD13"). To
enable pull-up resistors on the same pin, the PR command should be issued with bit 3 set (for
example ATPR8, ATPR1FFF, and so forth.).
The ATD2 command should be issued with a parameter of 2 to enable the analog input (“ATD22”).
Finally, DIO4 can be set as an output, driving high by issuing the ATD4 command with a parameter
value of 5 (“ATD45”).
After issuing these commands, changes must be applied before the module IO pins will be updated
to the new states. The AC or CN commands can be issued to apply changes (for example ATAC).
Example 2: calculate the PWM counts for a packet received with an RSSI of -84
dBm
RSSI = -84 = 0xAC = 172 decimal (unsigned)
PWM counts = (41 * 172) - 5928
PWM counts = 1124
With a total of 2400 counts, this yields an ON time of (1124 / 2400) = 46.8%
Example 3: configure the RSSI/PWM pin to operate for two seconds after each
received RF packet
First, ensure the RSSI/PWM functionality is enabled by reading the P0 (P-zero) command. It should
be set to 1 (default).
To configure the duration of the RSSI/PWM output, set the RP command. To achieve a two second
PWM output, set RP to 0x14 (20 decimal, or 2 seconds) and apply changes (AC command).
After applying changes, all received RF data packets should set the RSSI timer for two seconds.