1
\$\begingroup\$

I want to send char though Atmega2560 to the xbee coordinator(AT mode), and router(which is connected to the computer) should receive that char. I can correctly receive messages
from router -> coordinator -> atmega. Which means UART receive function works correctly. But when I'm trying to send that way atmega -> coordinator -> router, in router I keep getting messages like that 01 02 03 04 ... 0D... and so on.

UART initiazilation:

void uart_init(int baud_rate){
    UBRR0H = 0x00;
    UBRR0L = baud_rate;                                 //103

    /*Enabling Tx and Rx*/
    UCSR0B = (1<<TXEN0);
    UCSR0B = (1<<RXEN0);

    /*Setting stop 8 bits and non-parity*/
    UCSR0C = (1<<USBS0|3<<UCSZ00);
}

Here is my code for sending messages via UART:

void uart_send(byte data){
    while (!(UCSR0A & (1<<UDRE0)))
    {}
    UDR0 = data;
}

I'm sending messages from the main loop. Data to be sent is '0x73'. Im using sparkfun explorer for router, both of them is xbee series 1. Formula for baud_rate is (F_CPU /(BAUD*16) - 1). I've tried to replace router with coordinator, but nothing changes.

The thing is that even when I'm unpluging this xbee from microcontroller, it keeps sending hexademicals from 0x01 to 0xff. So I want to know, what causing these problems.

\$\endgroup\$
7
  • 6
    \$\begingroup\$ Also: This isn't really enough information, there's nothing on how you call the send function and from where. There's nothing in this code that creates data to be sent and I'm betting dollars for donuts (though I have neither) that's where your problem is. \$\endgroup\$
    – Asmyldof
    Jul 20, 2015 at 11:20
  • \$\begingroup\$ How do you calculate the Baud rate, are you sure about that it is correct? \$\endgroup\$ Jul 20, 2015 at 12:05
  • \$\begingroup\$ so, how are you receiving the messages? are you cheking for buffer overruns on receiving? \$\endgroup\$ Jul 20, 2015 at 13:16
  • \$\begingroup\$ what's the flow control going into the coordinator??? I bet that were the issue is coming from, check your flow control settings, make sure they are none or that you are using the appropriate flow control lines and protocol \$\endgroup\$
    – Kvegaoro
    Jul 20, 2015 at 13:17
  • \$\begingroup\$ Is the data you are trying to send ASCII characters, or plain integers (or something else)? \$\endgroup\$ Jul 20, 2015 at 15:57

1 Answer 1

1
\$\begingroup\$

I had the same problem using an XBee-PRO XSC module with one of the Sparkfun boards and the answer I received from Digi technical support was:

From the sounds of it, you have the radios in what we call Pitch mode. This occurs when Pin 6 is held low on startup or for long periods of time. Try disconnecting Pin 6 and then power cycle. You should see the issue go away.

If you look at the XBee Explorer Schematic you'll see pin 6 is connected to an RSSI LED because that pin is used as an RSSI indicator on some other modules. For the new revision of the board you'll see there's a jumper SJ1 that you can cut to disconnect that line which should solve the problem. I had an earlier board without that jumper so instead removed R7 for the same effect.

\$\endgroup\$
3
  • \$\begingroup\$ I checked your version. When two xbee's connected to the PC via explorers, everything works just fine. So I assume problem is in the "coordinator -> atmega" branch. Where coordinator connected to the microcontroller directly, without using explorer. I appreciate your help, thank you for suggestion \$\endgroup\$
    – DaurenD
    Jul 21, 2015 at 8:52
  • \$\begingroup\$ Did you end up trying to remove the RSSI? It was a while ago I had the problem but I seem to remember convincing myself it was the microcontroller end (connected directly the same as you) because I also had it connected over a PC OK, but I seem to remember it only happened without any clients connected. \$\endgroup\$
    – PeterJ
    Jul 21, 2015 at 9:10
  • \$\begingroup\$ Why i have to remove the RSSI, if I'm not using explorer. The module that generates that data is not connected to the explorer. \$\endgroup\$
    – DaurenD
    Jul 22, 2015 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.