Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with communicating between PC and PIC16F877 via xbee

Status
Not open for further replies.

orxanb

Newbie level 3
Joined
Apr 27, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
Hi everyone

As it is apparent from the title, I have a communication problem between PC and the PIC. Xbees are definitely configured correctly because I tested them by connecting between two computers and sending data from one to another.

What I am basically trying to do is send a character from a computer terminal to PIC and eventually turn on a led in the circuit.

I am using polling to test whether data has arrived or not:

while(!kbhit())
{}
c = getc();

Actually the code inside the while loop is not empty, but it is just blinking a LED such that when the blinking goes off, I know that the PIC has received the data. But the thing is, it never stops even though I keep sending characters on and on.

If there is anything you can suggest, it is greatly appreciated.

Thanks.

P.S.: I attached the part of the code I am talking about from the whole
 

Attachments

  • xbee_pic16f877.txt
    987 bytes · Views: 8
Last edited:

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
Are the Xbees configure in AT (Transparency) Mode?

The Xbees have a buffer, however it's small. Do you have the hardware control lines implemented in your design for flow control?
Without these you basicly have no buffer.

Did you use X-CTU to verify the configuration?

---------- Post added at 23:35 ---------- Previous post was at 23:27 ----------

Also without seeing your entire code, the snippet rarely tells the whole story. But using std library functions like:

printf("HiThere");

Is rarely a good idea. Zip up both sides of the project, PIC and PC, and upload to the forum. What PIC compiler are you using?
 

orxanb

Newbie level 3
Joined
Apr 27, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
Actually I used X-CTU to configure the xbees(in AT mode) and afterwards I tested them from two computer terminals.

I am not using hardware control lines for flow control implementation because there is no such a need in this project. I am going to send 4 bytes of information every 3 or 4 seconds.

Before trying printf, I already used

putc('a');
putc(13);

to send data from xbee, but with no luck.

Right now there is no PC side, I am using a simple terminal to send and receive characters. The code that I uploaded is the only one that is essentially working. The rest of the code is to compare the received data and output pwm values for motors, that is it.

I am using CCS compiler.
 
Last edited:

orxanb

Newbie level 3
Joined
Apr 27, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,308
With regard to xbees, they work with 3.3V and thus have a output high voltage of 3.3V. And I am directly connecting that 3.3V output to the PIC's serial input.

Do you think there can be a problem, with PIC not being able to interpret 3.3V as high?
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
Absolutely, you need a level shifter. Otherwise, excessively current flows could overheat and damage the XBee.

Also, here's a check list to setup a peer to peer XBee Network without the need of a Coordinator.

Otherwise the network must have at least one Coordinator and the other XBee is designated an Endpoint.

A peer-to-peer network can be established by configuring each module to operate as an End Device (CE = 0), disabling End Device Association on all modules (A1 = 0) and setting ID and CH parameters to be identical across the network.


XBee®/XBee-PRO® RF Modules
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top