Serial data receiving format error

Status
Not open for further replies.

Deepesh Khaneja

Newbie level 5
Joined
Nov 10, 2013
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
110
hey all
i am trying to send following data serially to pc from atmega16 but at the receiving terminal i am not getting hex data(there is unexpected data) which i am transmitting Please help
Below is my code
Code:
#include<avr/io.h>
#include<util/delay.h>

unsigned char str[8]={0x00,0x00,0x01,0x03,0xff,0xee,0xff};

void usart_init(void)
{
UCSRB|=(1<<TXEN)|(1<<RXEN);
UCSRC|=(1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
UBRRL=(8000000/(16*9600))-1;
}
void SEND_BYTE(unsigned char ch)
{ 
while(!(UCSRA&(1<<UDRE)));
UDR=ch;
}

void main(void)
{
unsigned char length=8;
unsigned char i=0;
usart_init();
while(length>0)
{
SEND_BYTE(str[i]);
i++;
length--;
_delay_ms(500);
}
}

suppose i send a single hex value like 0x42 i receive D3 OR D2 something on pc
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…