【问题标题】:Unable to get data from xbeepro2 end device with pic18f25k20无法使用 pic18f25k20 从 xbeepro2 终端设备获取数据
【发布时间】:2014-01-07 12:53:36
【问题描述】:

我正在尝试连接两个 xbee 的 pro s2 并使它们在 API 模式下相互通信(此外,我将使用更多的终端和路由器设备)。基本上,我通过 digi 适配器在我的 PC 上插入了一个 xbee 协调器,并且我将其他 xbee 连接到 PIC18f25。现在我正在处理从一个到另一个发送和接收数据,反之亦然。 当我在 USB 适配器上连接两者时,通信工作得很好(我可以从两个设备发送和接收数据)。但是,当我尝试使用以前的配置时,我发现无法从带有 PIC 的终端设备获取从协调器发送的数据。这是我要发送的数据:

从坐标 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 坐标 - 7E 00 13 10 01 00 00 00 00 00 00 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);*/               
        }

}

程序应该让 LED (PIN_C0) 闪烁 100 毫秒,如果有任何数据进入 PIC,它会更快地闪烁。但是它没有按我的计划工作,我不知道为什么。

任何帮助将不胜感激。

提前谢谢大家,

问候。

【问题讨论】:

    标签: api embedded pic xbee


    【解决方案1】:

    您知道此时很多部分都在起作用。如果 PIC 正在向协调器接收的 XBee 模块发送帧,则:

    • 您的波特率正确。
    • 您至少将 PIC Tx 正确连接到 XBee Rx。
    • XBee 模块已通电并正在运行。
    • XBee 模块已加入协调器的网络。
    • XBee 模块的RESET 行已正确断言。

    您是否有可能在 XBee 模块上启用了硬件握手 (ATD6=1),因此由于未声明 RTS 而无法发送到 PIC?

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

    您能否使用 XBee 界面让 Tx 和 Rx 上的 LED 闪烁,以便直观地查看数据是否通过?

    【讨论】:

    • 肯定是面包板或某些连接中的错误。我审查了它,它现在可以工作了。
    猜你喜欢
    • 1970-01-01
    • 2018-06-17
    • 2015-09-16
    • 1970-01-01
    • 2016-04-12
    • 1970-01-01
    • 2015-03-18
    • 1970-01-01
    • 2012-03-19
    相关资源
    最近更新 更多