eng-ahm
Newbie level 2
- Joined
- Mar 14, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,293
I have a problem with the usart of the atmega32a chip .
I write a program to send text to a serial port but I received the data in a different format like ĆĆĆĆĆĆĆĆ
please help me
this is my program
I write a program to send text to a serial port but I received the data in a different format like ĆĆĆĆĆĆĆĆ
please help me
this is my program
Code:
#include <avr/io.h>
#include <util/delay.h>
#define USART_BAUDRATE 9600
#define F_CPU 4000000
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) - 1)
void usart_init (void)
{
UCSRB |= (1 << RXEN) | (1 << TXEN);
UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1);
UBRRL = BAUD_PRESCALE;
UBRRH = (BAUD_PRESCALE >> 8);
}
void usart_send (unsigned char cht)
{
while(! (UCSRA & (1<<UDRE)));
UDR=cht;
}
int main(void)
{
unsigned char str[30]="a b c d e f g h";
unsigned char x;
unsigned char strlength=30;
unsigned char i=0;
usart_init();
_delay_ms(500);
while(1)
{
usart_send(str[i++]);
if (i >= strlength)
i = 0;
}
return 0;
}
Last edited by a moderator: