Xbee Serie 1 problem

hello everyone,

I have strange with my board composed with PIC 18f452 (HSPLL 8Mhz x 4)and XBEE S1 (v10A5). I work in API mode. I don’t use RTS and CTS function.

I want the PIC send a TX REQUEST (64bits) to XBEE , get the TX STATUS ,package it in new TX REQUEST packet , and send it . The problem is TX_STATUS is never received if pic don’t wait 10s .In fact , i just receive the first two byte 7E 00 .

If the PIC wait 10s , it received TX STATUS succesfull !!!

I have simulated this board with Proteus VSM + COMPIN model (and connect PC Xbee board on COM port) . No problem appear.

I think it’a a timing problem but i don’t see where ?!?

This is my mikro C source code

#define WIBEE_AT_COMMAND 0x08
#define WIBEE_TX_REQUEST 0x00
#define WIBEE_FRAME_ID 0xFF
#define WIBEE_START_DELIMITER 0x7E
#define WIBEE_TX_STATUS 0x89

unsigned char WIBEE_Packet_checksum;
unsigned char WIBEE_AT_COMMAND_BUFFER[2];
unsigned char WIBEE_AT_COMMAND_VALUE[20];
unsigned char WIBEE_AT_COMMAND_VALUE_LENGHT;
unsigned char WIBEE_TX_REQUEST_DESTINATION_ADDRESS[8];
unsigned char WIBEE_TX_REQUEST_OPTIONS;
unsigned char WIBEE_TX_REQUEST_RF_DATA[64];

unsigned char i;

// Sending packet to WIBEE network or AT COMMAND to XBEE
// In input : Packet Type => WIBEE_AT_COMMAND
// WIBEE_TX_REQUEST
// In output : operation result WIBEE_PACKET_SEND_SUCCES
// WIBEE_PACKET_SEND_FAILED

unsigned char WIBEE_Send_Packet(unsigned char PacketType)
{
// 1) Init checksum 

WIBEE_Packet_checksum = 0xFF - PacketType;
WIBEE_Packet_checksum -= WIBEE_FRAME_ID;

// 2) What type of packet to send ?
// 3) Checksum calculate
// 4) Send packet to Xbee

switch (PacketType)
{
// Commande AT
case WIBEE_AT_COMMAND:
WIBEE_Packet_checksum -= WIBEE_AT_COMMAND_BUFFER[0];
WIBEE_Packet_checksum -= WIBEE_AT_COMMAND_BUFFER[1];

for (i = 0 ; i < WIBEE_AT_COMMAND_VALUE_LENGHT ; i++)
WIBEE_Packet_checksum -= WIBEE_AT_COMMAND_VALUE;

Usart_Write(WIBEE_START_DELIMITER);
Usart_Write(0);
Usart_Write((0x04 + WIBEE_AT_COMMAND_VALUE_LENGHT));
Usart_Write(WIBEE_AT_COMMAND);
Usart_Write(WIBEE_FRAME_ID);
Usart_Write(WIBEE_AT_COMMAND_BUFFER[0]);
Usart_Write(WIBEE_AT_COMMAND_BUFFER[1]);
for (i = 0 ; i < WIBEE_AT_COMMAND_VALUE_LENGHT ; i++)
Usart_Write(WIBEE_AT_COMMAND_VALUE);
break;

// Data packet to transmit
case WIBEE_TX_REQUEST:
for (i = 0 ; i < 8 ; i++)
WIBEE_Packet_checksum -= WIBEE_TX_REQUEST_DESTINATION_ADDRESS;

WIBEE_Packet_checksum -= WIBEE_TX_REQUEST_OPTIONS;

for (i = 0 ; i < 64 ; i++)
WIBEE_Packet_checksum-=WIBEE_TX_REQUEST_RF_DATA;

Usart_Write(WIBEE_START_DELIMITER);
Usart_Write(0);
Usart_Write(75);
Usart_Write(WIBEE_TX_REQUEST);
Usart_Write(WIBEE_FRAME_ID);
for (i = 0 ; i < 8 ; i++)
Usart_Write(WIBEE_TX_REQUEST_DESTINATION_ADDRESS);
Usart_Write(WIBEE_TX_REQUEST_OPTIONS);
for (i = 0 ; i < 64 ; i++)
Usart_Write(WIBEE_TX_REQUEST_RF_DATA);
break;

default:
break;
}
Usart_Write(WIBEE_Packet_checksum);

return 1;
}

void main()
{
// Port C initialization
TRISC = 0x80;
PORTC = 0x00;
LATC = 0x00;

// USART initialization
Usart_Init(9600);

// Clear TX_REQUEST_RF_DATA buffer
for (i = 0 ; i < 64 ; i++)
WIBEE_TX_REQUEST_RF_DATA = 0x00;

// Destination address 000000000000FFFF for broadcast
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[0] = 0x00;
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[1] = 0x00;
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[2] = 0x00;
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[3] = 0x00;
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[4] = 0x00;
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[5] = 0x00;
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[6] = 0xFF;
WIBEE_TX_REQUEST_DESTINATION_ADDRESS[7] = 0xFF;

// No options
WIBEE_TX_REQUEST_OPTIONS = 0x00;

// Send packet to network
WIBEE_Send_Packet(WIBEE_TX_REQUEST);

PORTC.RC0 = 1; // Power on STATUS LED

// Get TX STATUS
while (!Usart_Data_Ready);
WIBEE_TX_REQUEST_RF_DATA[0] = RCREG;
while (!Usart_Data_Ready);
WIBEE_TX_REQUEST_RF_DATA[1] = RCREG;
while (!Usart_Data_Ready);
WIBEE_TX_REQUEST_RF_DATA[2] = RCREG;
while (!Usart_Data_Ready);
WIBEE_TX_REQUEST_RF_DATA[3] = RCREG;
while (!Usart_Data_Ready);
WIBEE_TX_REQUEST_RF_DATA[4] = RCREG;
while (!Usart_Data_Ready);
WIBEE_TX_REQUEST_RF_DATA[5] = RCREG;
while (!Usart_Data_Ready);
WIBEE_TX_REQUEST_RF_DATA[6] = RCREG;

// Send new packet
WIBEE_Send_Packet(WIBEE_TX_REQUEST);

PORTC.RC0 = 0; // POWER OFF STATUS LED

// infinite loop
while (1)
{
}

}

schematic of my board can be found here : http://yoopix.org/thumb/show?WEAUExE-c1

thanks a lot for your help

I just glanced at your code. But I’ll throw out this…

  1. mikroC - compiler-generated code and their run-time libraries: I don’t know about the PIC, but the AVR version has so many bugs and errors that it’s unusable.

  2. Have you downloaded to the XBees the wireless serial port extension firmware - where you can issue modem commands like +++< delay >ATxxx and so on to configure? Then use a pair of XBees as a transparent wireless serial link? This can help you verify that all your tools are correct. Then you can revert to the rather complicated Binary Packet Protocol as you’ve shown, if need be, rather than the modem emulator firmware.

Thanks a lot for your replies Stevech,

  1. mikroC - compiler-generated code and their run-time libraries: I don’t know about the PIC, but the AVR version has so many bugs and errors that it’s unusable.

May be you’re right , i must test on other C compiler or in ASM . I would do it this week end.

  1. Have you downloaded to the XBees the wireless serial port extension firmware - where you can issue modem commands like +++< delay >ATxxx and so on to configure? Then use a pair of XBees as a transparent wireless serial link? This can help you verify that all your tools are correct. Then you can revert to the rather complicated Binary Packet Protocol as you’ve shown, if need be, rather than the modem emulator firmware.

I already use the transparent mode ,and i always have same RX problem with PIC (always mickroC code).

I have connected two PC with XBee (in API mode and Transparent mode)and there is no problem.

I can’t use transparent mode for my application , maybe in my data i can have “+++” and i don’t want the Xbee understand to entering in Configuration mode.

Have a nice day.

you can have +++ in TX data to the XBee if you adhere to the guard-time rule. Just like a Hayes modem. Must have idle marking before and after +++ for it to be an escape.

so if you send hello+++CRLF it is not considered an escape.

Hello,

I test a piece of code with C18 and ASM this week end, same pb.

Other things very strange if i start my board without XBee after 1 or 2s , i plug XBee , sometimes the board respond ?!? I think a don’t understand something but i don’t know what !

:frowning:

Hello everyone,

i have found the mistake .It is a voltage problem between Xbee and PIC . The RX pin of PIC is a trigger schmitt input (4V) and the Xbee can only send 3,3V so I have put 2 x bc547 + few resistors for convert voltage to 5V.

I have also add a management of Xbee reset pin with PORT.RC5 ,now the Xbee is reset by PIC and wait for Modem status.

Hi ,

my xbee doesn’t communicate, do you know how to deal with it?

Xing