* Split from the 4 year old thread https://www.avrfreaks.net/comment...
I am using attiny841 controller for my application. I am facing some strange problem in Uart communication in two controllers. i have same set of hardware and i am using same piece of firmware for both the controllers. Here is my uart initialization function.
void Uart initialization(unsigned int baudrate)
UBRR0H = (unsigned char) (baudrate>>8);
UBRR0L = (unsigned char) (baudrate);
UCSR0B |= (1<<RXCIE0);
UCSR0B |= ((1<<RXEN0) | (1<<TXEN0)); //enable receiver and transmitter pin
UCSR0C |= ((1<<UCSZ01) | (1<<UCSZ00)); // setting to 8bit mode
UCSR0B &=~ (1<<UCSZ02);
UCSR0C &=~((1<<UPM00) | (1<<UPM01));
UCSR0C |= (1<<USBS0);
UCSR0A |= (1<< U2X0);
For one controller, I am able to communicate correctly with Uart initialization(7); where as for other, it is working with Uart initialization(8); which means i need to set different baud rate register for 2 different controllers. If i set both to Uart initialization(7); or Uart initialization(8); then i get junk characters in the other.
Please suggest some solution to the issue.