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;
}