# uart problem

**URL:** <https://community.sparkfun.com/t/uart-problem/34340>\
**Category:** MicroMod\
**Tags:** avr-atmel\
**Created:** [April 30, 2017, 10:07pm UTC](https://community.sparkfun.com/t/uart-problem/34340 "2017-04-30T22:07:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![alesyo](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@alesyo](https://community.sparkfun.com/u/alesyo)\
**Post date:** [April 30, 2017, 10:07pm UTC](https://community.sparkfun.com/t/uart-problem/34340/1 "2017-04-30T22:07:47Z")

</div>

Hello guys ,i need some help ,i have a module with xbee, the module is fine,i have some problem with code because i recive wrong parameters ,i send a string like “Hello world!” and i recive wrong like “!@~~Hello word!x” …look in the img…i use a at90can32 microcontroller…please help…here is the code

#define F\_CPU 8000000

#include \<avr/io.h\>

#include\<avr/interrupt.h\>

#include\<util/delay.h\>

#include\<string.h\>

#define BAUD\_RATE 9600

#define BAUD\_PRESCALER (((F\_CPU / (BAUD\_RATE \* 16UL))) - 1)

static void BAUD\_SETTINGS(){

UBRR1H=(BAUD\_PRESCALER\>\>8);

UBRR1L=BAUD\_PRESCALER;

}

static void TRANSMIT\_SETTINGS(){

UCSR1B=(1\<\<TXEN1) | (1\<\<RXEN) | (1\<\<RXCIE);

UCSR1C=(1\<\<UCSZ0) | (1\<\<UCSZ1) | (1\<\<UMSEL1);

}

void UART\_TX(unsigned char znak);

void UART\_String\_TX(char \*command);

int main(void)

{

BAUD\_SETTINGS();

TRANSMIT\_SETTINGS();

DDRD=0xff;

PORTC=0xff;

PORTD=0x03;

sei();

\_delay\_ms(900);

for(;;){

PORTD=0xff;

UART\_String\_TX(“Hello World!”);

\_delay\_ms(1000);

}

}

void UART\_TX(unsigned char znak){

while(!(UCSR1A & (1\<\<UDRE1)));

UDR1 = znak;

}

void UART\_String\_TX(char \*command){

while(\*command != 0x00){

UART\_TX(\*command);

command++;}

}

ISR(USART\_RXC\_vect){

char RXC\_byte;

RXC\_byte=UDR1;

UDR1=RXC\_byte;

PORTD=0x00;

}
