8051 Serial Communication

8051serial

I am doing a project in which I have to serially communicate data from 8051 Micro-controller to PC.

The problem is that when I transmit the data from 8051 and receive it over the Putty terminal it gives me garbage data. I get the same garbage results when I simulate it on the Proteus. I have also set the same baud rates for the micro-controller and the terminal.

Can someone tell me what possibly the problem could be ?

Best Answer

Many 8x51-family chips have rather crude baud-rate control logic; many 8x51 derivatives (and indeed even the 8052) improved upon it, but even some sophisticated 8x51 derivatives are for some reason severely limited as to the baud rates they can generate. With the original 8x51, it was common to use a crystal of 11.0592Mhz to allow many standard baud rates to be generated precisely, but such usage is less common today.

Check your part's data sheet to make certain that you have your baud rate set correctly and that the actual baud rate you will be producing is within a couple percent of the one for which you have the PC configured. If you have a scope, I would suggest measuring the baud rate. If you do not have a scope, I would suggest that you write a program to repeatedly transmit at maximum speed a sequence of many FF bytes followed by many 00 bytes. If your baud rate is supposed to be 9600 baud and you repeatedly send 240 bytes of FF and 240 bytes of 00, an LED on the port should blink between mostly on and mostly off at a rate of 2.00Hz. If the bright and dim intervals are e.g. a half second each (meaning an overall blink rate of 1Hz) that would suggest that even if you want to send 9600 baud, you're actually sending at 4800).