Api 无法使用pic18f25k20从xbeepro2终端设备获取数据

Api 无法使用pic18f25k20从xbeepro2终端设备获取数据,api,embedded,pic,xbee,Api,Embedded,Pic,Xbee,我正在尝试连接两个xbee的pro s2,并使它们在API模式下相互通信(此外,我将使用更多的终端和路由器设备)。基本上,我有一个xbee协调器通过digi适配器插在我的电脑上,我有另一个xbee连接到PIC18f25。现在我正在处理从一个到另一个的发送和接收数据,反之亦然。 当我在usb适配器上连接这两个设备时,通信工作正常(我可以从这两个设备发送和接收数据)。然而,当我尝试使用之前的配置时,我发现不可能从带有PIC的终端设备获取从协调器发送的数据。下面是我试图发送的数据: 从Coord 2

我正在尝试连接两个xbee的pro s2,并使它们在API模式下相互通信(此外,我将使用更多的终端和路由器设备)。基本上,我有一个xbee协调器通过digi适配器插在我的电脑上,我有另一个xbee连接到PIC18f25。现在我正在处理从一个到另一个的发送和接收数据,反之亦然。 当我在usb适配器上连接这两个设备时,通信工作正常(我可以从这两个设备发送和接收数据)。然而,当我尝试使用之前的配置时,我发现不可能从带有PIC的终端设备获取从协调器发送的数据。下面是我试图发送的数据:

从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

来自EndD 2 Coord-7E 00 13 10 01 00 00 FF FE 00 00 48 65 6C 6C 6F FD

我认为可以这样说,当我试图通过终端设备将数据从PIC发送到协调器时,它是有效的。 我想知道问题是否与我的代码有关,可以在下面找到:

#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)                           /* Clock definition */
#use rs232(BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7)      /* ZigBee and PIC Communication */

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);       // TESTE
        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 to coordinator
            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);*/               
        }

}
#包括
#设备adc=10
#设备ICD=真
#保险丝noWDT//看门狗定时器
#低功率晶体熔断器

#FUSES XT//Crystal osc您知道,在这一点上,很多部件都在工作。如果PIC向协调器接收的XBee模块发送帧,则:

  • 您有正确的波特率
  • 您至少已将PIC Tx正确连接到XBee Rx
  • XBee模块已通电且正在运行
  • XBee模块连接到协调器的网络
  • XBee模块的
    RESET
    行被正确断言
您是否可能在XBee模块上启用了硬件握手功能(
ATD6=1
),因此无法发送到PIC,因为它没有断言RTS

您能否将标准串行电缆连接到PIC(而不是XBee),并确认从终端程序发送的数据会触发您的闪烁,并且终端程序会看到发送的帧


您能否使用一个XBee接口,在Tx和Rx上闪烁LED,这样您就可以直观地看到是否有数据通过?

这肯定是试验板或某些连接中的错误。我检查过了,现在可以用了。