Continue to Site

Welcome to

Welcome to our site! is an international Electronics 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

Not open for further replies.


Newbie level 3
Apr 27, 2011
Reaction score
Trophy points
Activity points
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:

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.


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


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

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:


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?

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


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:

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?

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

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to