aurora WROTE:Can you confirm if your uC is sending the right data? Like connecting your uC direct your your MAX232, and able to receive the character?
If i remember correctly, XBee take a few seconds (like 1-2s) to pair before sending/receiving is possible. By right, you shouldn't be seeing any character (in this case, the dot) so soon, could be a glitch or power spike when you switch on. You can try click on "show hex" in Terminal window. It will show you the hex for the dot. It's probably random.
Yes. I did connect the max232 directly to the PIC. The full stop is indeed a random hex value as shown in the image.
This is the code that i used. I know there may be redundant codes, but I'm leaving it there for now.
- CODE: SELECT_ALL_CODE
#include <16F628A.h>
#fuses INTRC_IO, NOLVP, NOWDT, PUT, BROWNOUT
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1, INVERT, ERRORS)
#include <htc.h>
#include <stdio.h>
#include "usart.h"
#include <stdlib.h>
#include <string.h>
#byte PORTB = 6 /*map ports */
#byte PORTA = 5
//#include <i2c.h>
#define _XTAL_FREQ 4000000
__CONFIG (0x2134); //0x - hex ;; 0b - binary
_LVP_OFF;
BAUD9600;
int main ()
{
CMCON = 7;
char a,b,x,y;
unsigned char j;
int i;
long code_d0, code_d1;
long c_d0[6];
long c_d1[6];
//char *file = "C:\\file.txt";
while (1) { // infinity loop..for;;
//codes
TRISA = 0xff; //configure all a ports as inputs
TRISB = 0x00; //configure all b ports as outputs
//SETUP_UART(FALSE);
x = RA0;
y = RA1;
b = ((0b00001111 || RA0)||(0b1111));
PORTB = x;
// code_d0=RA0;
// code_d1=RA1;
putch(0x48);
putch(0x45);
putch(0x4C);
putch(0x4C);
putch(0x4F);
putch(getch);
//__delay_ms(1000);
a = getch;
if(a == '1'){
RB4 = 0b00000001;
RB5 = 0b00000000;
RB6 = 0b00000000;
RB7 = 0b00000000;
}
else if (a == '2'){
RB4 = 0b00000000;
RB5 = 0b00000001;
RB6 = 0b00000000;
RB7 = 0b00000000;
}
}
}
Sorry for the length. Practically, when i send 1 the led should light up. But instead, I get the output as shown.
Blue is the code I type, and red is the received data.