Unable to get data from end device xbeepro2

G´day everyone.

I´ve been working on this project and it´s about generating data and sending it through xbee´s. The purpose is to use one as coordinator and multiple end devices (which leads me to API mode). Basically those end devices will be collecting data from a PIC18f25k20 and sending it to the coordinator (which is attached to a USB Adapter on my PC), the data will be manipulated using labview, and the coordinator will be sending some data back to the end devices.

Here are some details:
Xbee Pro Serie 2 - Model - xbeepro2
Modem type - XBP24-B
Firmware version 21A7.

Right now, I´m working with 2 xbee´s and trying to send data between them. The data is followed:
From Coord 2 EndD - 7E 00 13 10 01 00 13 A2 00 40 8D 5A 8B FF FE 00 00 48 65 6C 6C 6F 96
From EndD 2 Coord - 7E 00 13 10 01 00 00 00 00 00 00 00 00 FF FE 00 00 48 65 6C 6C 6F FD

It works just fine when I put both on the PC USB Adapter and use XCTU. However, when I try to communicate one xbee in usb(coord) with one connected to a pic(end device) I find one trouble. I can´t get the data, which is sent from coord, from the xbee end device to my microcontroller. On the terminal XCTU, I get the followed answer:
7E 00 07 8B 01 FC C3 00 00 40 74 - which tells me that the data was succesfully delivered.
I think it’s a code problem, however it could be anything else since I’m a begginer at this stage :slight_smile:

Raw Code :


#include <18F25K20.h>
#device   adc =10
#device   ICD=TRUE
#FUSES    noWDT                    // Watch Dog Timer
#fuses 		LP						//low power crystal
#FUSES    XT                       //Crystal osc <= 4mhz
#fuses	  BROWNOUT_SW  				//Brownout enabled during operation, disabled during SLEEP 
#FUSES    NOPROTECT                //Code not protected from reading
#FUSES    BROWNOUT                 //brownout reset
#FUSES    BORV27                 //Brownout reset at 2.7V 
#FUSES    NOPUT                      //Power Up Timer
#FUSES    NOCPD                    //No EE protection
#FUSES    STVREN                   //Stack full/underflow will cause reset
#FUSES    noDEBUG                    //No Debug mode for ICD
#FUSES    noLVP                    //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES    NOWRT                    //Program memory not write protected
#FUSES    NOWRTD                   //Data EEPROM not write protected
#FUSES    noIESO                     //Internal External Switch Over mode enabled
#FUSES    FCMEN                    //Fail-safe clock monitor enabled
#FUSES    NOPBADEN                   //PORTB pins are configured as analog input channels on RESET
#FUSES    NOWRTC                   //configuration not registers write protected
#FUSES    NOWRTB                   //Boot block not write protected
#FUSES    NOEBTR                   //Memory not protected from table reads
#FUSES    NOEBTRB                  //Boot block not protected from table reads
#FUSES    NOCPB                    //No Boot Block code protection
#FUSES    LPT1OSC                  //Timer1 configured for low-power operation
#FUSES    MCLR                     //Master Clear pin enabled
#FUSES    XINST                    //Extended set extension and Indexed Addressing mode enabled*/


#use delay(clock = 4000000)                           /* Definição do CLOCK */
#use rs232(BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7)      /* Comunicação entre o PIC e o Zigbee */

int16 var;
byte var2=0x00;
long timeout;

void main() { 
	output_low(PIN_C5); // Turning on Xbee
	delay_ms(10);	
	while(1) {
			delay_ms(100);
			output_high(PIN_C0);    
			delay_ms(100);
			output_low(PIN_C0);
			timeout=0;
          		while(!kbhit()&&(++timeout<5000)) delay_us(5);
               	if(kbhit()){
					output_high(PIN_C0);
					delay_ms(10);
					output_low(PIN_C0);
					delay_ms(10);
					output_high(PIN_C0);
					delay_ms(10);
					output_low(PIN_C0);
					delay_ms(10);
					output_high(PIN_C0);
					delay_ms(10);
					
					output_low(PIN_C0);
					var2 = getc();
					delay_ms(1000);
				}
/* Data which is succesfully sent from end-device to coord
				putc(0x7E);
				putc(0x00);
				putc(0x13);
				putc(0x10);
				putc(0x01);
				putc(0x00);
				putc(0x00);
				putc(0x00);
				putc(0x00);
				putc(0x00);
				putc(0x00);
				putc(0x00);
				putc(0x00);
				putc(0xFF);
				putc(0xFE);
				putc(0x00);
				putc(0x00);
				putc(0x48);
				putc(0x65);
				putc(0x6C);
				putc(0x6C);
				putc(0x6F);
				putc(0xFD);*/				
			}

}


As I said, it’s a raw code. What I was trying to see is a blinking LED (PIN_C0) with 100 ms, and I would see a faster blinking if any charecter is received. However it doesn’t work as I planned and I have no clue why.

If somebody could help me, I’d appreciate a lot! :smiley:

Cheers,

PS.: Sry for any english mistakes :stuck_out_tongue:

Hi, I worked with project using xbee and pic18f2620.
I want to do a library in c (I use ccs PCW compiler) to send API command between xbee.
I have the same problem.
My xbee does not respond when i send an API command.
I want to send an AT command ,
Can you help me to correct my code? Thanks a lot
this is my code :

#include <18F2620.h>

#device adc=8
#use delay(clock=20000000)
#include 
#include 
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PC)
#use rs232(baud=9600,parity=N,xmit=PIN_C2,rcv=PIN_B1,bits=8,stream=Xbee)
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES LP                       //Low power osc < 200 khz
#FUSES NOPROTECT                //Code not protected from reading
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV21                   //Brownout reset at 2.1V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PBADEN                   //PORTB pins are configured as analog input channels on RESET
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES MCLR                     //Master Clear pin enabled
#include 
#include 

int8 inputBytes[13];
int8 outputBytes[13];

void main()
{
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_CLOCK_DIV_2|ADC_TAD_MUL_0);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);
   int8 ctr=0;
   int8 ctr2=0;
inputBytes[0]=0x7E;
inputBytes[1]=0x00;
inputBytes[2]=0x08;
inputBytes[3]=0x08;
inputBytes[4]=0x01;
inputBytes[5]=0x44;
inputBytes[6]=0x48;
inputBytes[7]=0x00;
inputBytes[8]=0x13;
inputBytes[9]=0xA2;
inputBytes[10]=0x00;
inputBytes[11]=0xB5;
//inputBytes[12]='\0';
for(ctr=0;ctr<12;ctr++)
{
putc(inputBytes[ctr]);//send API trame
}
for(ctr2=0;ctr2<12;ctr2++)
{
outputBytes[ctr2]=getc();// response of API command

}