This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

8051 communication with RS232

I have used USB to RS232 converter to transfer my USB port on PC to RS232 port which performs communication with 8051. The problem is why my PC only can receive unexpected garbage code.
My 8051 and PC can realize serial communication with 8051 and PC respectively. But when combine them together the problem will happen.
Would you help me to give me some suggestions?

Parents
  • "I have shortened Pin 2 and Pin 3 of this converter for PC can receive the data it just sent out. The result is that the PC can receive the data correctly."

    This shows that the PC and converter hardware are working, and that the PC transmit settings match the PC receive settings.

    "I also did the same thing to 8051 with the same correct result."

    Similarly, this shows that the 8051 & associated hardware are working, and that the 8051 transmit settings match the 8051 receive settings.

    "But when combine PC and 8051 ... only can receive garbage data."

    What you haven't demonstrated yet is that the PC transmit settings match the 8051 receive settings, and vice-versa.

    The fact that you receive something (albeit garbage) suggests that the cable connections are correct.

    This just leaves a mismatch between PC and 8051 settings.
    Have you checked with the Keil calculator that you have your baudrate exactly correct?
    http://www.keil.com/c51/baudrate.asp

    Are you sure the parity & data bits settings is correct?
    (the 8051 supports 8 bits only, and doesn't do parity)

    Have you tried the "Hello, World" example?
    This should give you a known set of serial port options.

Reply
  • "I have shortened Pin 2 and Pin 3 of this converter for PC can receive the data it just sent out. The result is that the PC can receive the data correctly."

    This shows that the PC and converter hardware are working, and that the PC transmit settings match the PC receive settings.

    "I also did the same thing to 8051 with the same correct result."

    Similarly, this shows that the 8051 & associated hardware are working, and that the 8051 transmit settings match the 8051 receive settings.

    "But when combine PC and 8051 ... only can receive garbage data."

    What you haven't demonstrated yet is that the PC transmit settings match the 8051 receive settings, and vice-versa.

    The fact that you receive something (albeit garbage) suggests that the cable connections are correct.

    This just leaves a mismatch between PC and 8051 settings.
    Have you checked with the Keil calculator that you have your baudrate exactly correct?
    http://www.keil.com/c51/baudrate.asp

    Are you sure the parity & data bits settings is correct?
    (the 8051 supports 8 bits only, and doesn't do parity)

    Have you tried the "Hello, World" example?
    This should give you a known set of serial port options.

Children