I was trying to send the command from my MCU to the Xbee module through serial port.
The test which has been done is that I send the “ABCD” from the MCU to Xbee and use another Xbee which connect to another PC to open the X-CTU terminal. The terminal can get the data and display “ABCD” which means that the broadcast is successful.
What I am doing now is to send the command(+++) to my xbee which means to enter the AT command mode. I hope I can get the “OK” string then send the another AT command to do other works. I think the Xbee get the “+++” and reply “OK” already. The reason I say this is the green led is blink first then after around 1 second, the yellow led blink as well.
The problem confuses me is I can not get the “OK” back to my program. Do I need to set up the parity, polarity or something? I was trying to figure out this problem and spending lot of time but unfortunately, there was nothing discovered.
I hope someone who is experienced can help me deal with this problem.
If the transmission part of your test is working ok, then the serial parameters should be correct. Are you sure the transmit line of the XBee is connected to the receive line of the MCU?
Are you receiving any bytes back to the MCU from the XBee? I don’t believe the XBee sends a newline (
) at the end of a line, just a carriage return (\r); if you’re trying to read an entire “line”, you may have to adjust your concept of what a “line” is
I spent lot of time to figure out what’s the problem.
I think I got some points of that.
The first step I did for the experiment is…
I ever wrote the program which can communicate from my hyperterminal to my MCU through serial port. That is, I can type some words, for example…“ABCD”, when the MCU get this data, it can reply “case1”, “EFGH”, reply “case2”, otherwise, “case3”. All these data can be shown on hyperterminal correctly.
Regardless of xbee now, I try to use this adapter(Null modem, as you can see in attachment) to connect my PC to my MCU to try this program again. The big discovery is that when I type “ABCD”, there is no response from my board. This means the data can be sent out but can not be received. I assume this is the problem with my MUC communicate to my Xbee.
The seconde step is…
I use the oscilloscope to test if any hardware problem happens. It shows the sending function from MCU works fine. And the receiving function and sending function for Xbee work fine as well. The problem is that the receiving function for MCU, the oscilloscope indicates that no any data reach the MCU.
Above is my experiment I did these days and that why I assume maybe I misuse the adapter. If you have any experience about this, let me know…What kind of adapter is working for me.