我试图连接两个xbee的专业版s2并使它们在API模式下相互通信(此外,我将使用更多的终端和路由器设备)。基本上,我通过digi适配器在PC上插入了一个xbee协调器,并将其他xbee连接到PIC18f25。现在我正在从一个到另一个发送和接收数据,反之亦然。 当我在USB适配器上同时连接时,通信工作得很好(我可以向/从两个设备发送和接收数据)。但是,当我尝试使用以前的配置时,我发现从协调器发送的数据不可能从带有PIC的终端设备中获取。这里不用我想要发送的数据:无法从xbeepro2终端设备获取数据pic18f25k20
从坐标2 EndD - 7E 00 13 10 01 00 13 00 A2 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进入。然而,它不按我的计划工作,我不知道为什么。
任何帮助将不胜感激。
谢谢大家,
问候。
当然,这是面包板或连接的错误。我审查了它,现在它正在工作。 – user3169135