I am working on a project using Atmega16 micro-controller of AVR family. I am using UART for my project. I need to send data to my PC AT 9600 baud rate via an USB-TTL converter and view the data using 'putty'.
I am getting absurd data in putty. I am not an electronics guy but a computer science guy so need a little bit of help.
I guess I might be writing the wrong fuse bits or something else. Please specify the fuse bits if possible
The program for the micro-controller is below
#include<avr/io.h>
#include<util/delay.h>
#define UBRR_VALUE 51
//function to initialize UART
void uart_init(void)
{
UBRRH=(UBRR_VALUE>>8);//shift the register right by 8 bits
UBRRL=UBRR_VALUE;//set baud rate
UCSRB|=(1<<TXEN)|(1<<RXEN);//enable receiver and transmitter
UCSRC|=(1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1);//8 bit data format
}
//function to transmit data
void uart_transmit(unsigned char data)
{
while(!(UCSRA & (1<<UDRE)));
UDR=data;
}
void transmit_string(char *str_data)
{
while(*str_data)
{
uart_transmit(*str_data);
str_data++;
}
}
int main(void)
{
uart_init();
while(1)
{
//transmit_string("hello");
uart_transmit('h');
}
return 0;
}
The fuse bits specifications are given below
Thanks in advance for any type of help