[SOLVED] usart problem in atmega 8

Status
Not open for further replies.

vvarlord

Member level 4
Joined
Mar 15, 2012
Messages
74
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,288
Visit site
Activity points
1,756
i had worked with usart of atmega 8 for send and recieve data.
but after some days i have this problem which when i run a simple echo test for usart (recieve data by mcu and send it through com port again,and i use termite program for send and recieve),when i send a one digit number it works correct,,but with two digit number it gives garbage data

tnx in advance.
 

Code:
#include <mega16.h>
#include <stdio.h>
int a=0;
void main(void)
{
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x19;
while (1)
      {
      scanf("%d",&a);
      printf("%d",a);
      
      }
}

- - - Updated - - -

i don't think the problem is in codes
any suggestions?
 

i think the problem is inBaud Rate,You can double-check the baud rate of the PC and the microcontroller
 

the baud rate on both sides are set on 2400
could it be from a hardware problem?
 

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…