# AVR sending message via UART

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.

• 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. – Asmyldof Jul 20 '15 at 11:20
• How do you calculate the Baud rate, are you sure about that it is correct? – Bence Kaulics Jul 20 '15 at 12:05
• so, how are you receiving the messages? are you cheking for buffer overruns on receiving? – Jasen Jul 20 '15 at 13:16
• 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 – Kvegaoro Jul 20 '15 at 13:17
• Is the data you are trying to send ASCII characters, or plain integers (or something else)? – Peter Bennett Jul 20 '15 at 15:57