Dec 18, 2013 #1 D Deepesh Khaneja Newbie level 5 Joined Nov 10, 2013 Messages 9 Helped 0 Reputation 0 Reaction score 0 Trophy points 1 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: Dec 19, 2013
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
Dec 19, 2013 #2 jayanth.devarayanadurga Banned Joined Dec 4, 2012 Messages 4,280 Helped 822 Reputation 1,654 Reaction score 791 Trophy points 1,393 Location Bangalore, India Activity points 0 https://www.kanda.com/AVR-C-Code-UART.php