0
\$\begingroup\$

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 ?

\$\endgroup\$
  • 1
    \$\begingroup\$ You didn't forget to use a level shifter like a MAX232, did you? \$\endgroup\$ – Federico Russo Feb 5 '13 at 10:41
  • \$\begingroup\$ As it doesn't work in Proteus sounds like a firmware configuration problem. If you have a scope you can check the bitrate from the 8051, otherwise stepping through some different baud rates on your PC is a good way to start in case some divisor is not set how you expect. Edit - I'm not familiar with Proteus but perhaps that has some virtual scope you can attach? \$\endgroup\$ – PeterJ Feb 5 '13 at 10:44
  • \$\begingroup\$ The baud rates depend on the 8051 clock frequency. You didn't copy the baud rate setting code from an example clocked at a different frequency, by any chance? If so, the fix should be easy... \$\endgroup\$ – Brian Drummond Feb 5 '13 at 11:03
  • 4
    \$\begingroup\$ Post some source code along with your device operating frequency and we may be in a position to help. Without this it's merely speculation and a definitive solution is impossible. \$\endgroup\$ – Adam Lawrence Feb 5 '13 at 13:49
  • 2
    \$\begingroup\$ We can't figure out what it is without seeing some code. It's more than likely a software baudrate or configuration issue. \$\endgroup\$ – Gustavo Litovsky Feb 5 '13 at 15:59
1
\$\begingroup\$

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).

\$\endgroup\$
0
\$\begingroup\$

Add a delay in your code...if that doesn't work make sure Putty is set to the same baud rate as used in your code....the best baud rate is 9600 and 4800

\$\endgroup\$
  • 8
    \$\begingroup\$ Why do you say those are the best rates? I just think that 9600 is one of the more common ones. \$\endgroup\$ – Brian Carlton Feb 12 '13 at 0:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.