No announcement yet.

UART and RS-232

  • Time
  • Show
Clear All
new posts

  • UART and RS-232

    For the past week I had a problem with integrating a PIC 24E with a mini computer.
    It is a old classic and simple circuit anybody can do it, but it took me hours of hours
    Finally I solved it
    I would like to share my experience to anybody would like here to ease their experience


    PIC 24E <---> MAX233 UART transiver <---> PC : failed!

    PIC 24E <---> MAX233 UART transiver <---> Digitus UART to USB <---> PC : Pass
    PIC 24E <---> MAX233 UART transiver <---> MAX233 UART transiver <---> PIC 24E :PASS

    so, almost all configurations were tested and just one which I did need did not work!
    But why?!

    Remember when you program a uController for specific baud rate, say 9600 there is ALWAYS an error margin!!!
    I found a 5% error on the PIC datasheet, and sames happens within mini computer!
    So in a statistically rear event these errors cause the data corruption.

    BUT how did I solve

    I put my PIC on 9000 and the PC on 9600
    all of a sudden everything works fine
    so dont give up try all combinations

  • #2
    Interesting. Thank you for sharing this.

    PS: That is why I am always careful about choosing the proper crystal value for microcontroller (choosing the crystal value what can be nicely divided the way, that you get the right frequency for required baud rate)

    PSS: Very common problem what I have seen when connecting PC to a device via RS232 was grounding. For example, if these devices were connected into different main plugs, the communication could be corrupted. I had to connect both devices into the same main plug or ideally I would use a laptop powered from battery.


    • #3
      For whom might interest,

      My PIC was PIC24EP512GU810
      crystal was 8Mhz
      and its internal Phase Lock Loop (PLL)
      increased its speed upto 140Mhz
      compiler was MikroC
      everything works fine, even USB but UART data was corrupted

      PS: I have tested everything related to ground or power but always the data was currupted
      PSS: there were no problems at all when communicating with other micro controllers

      ​Thanks robertferanec


      • #4
        In some datasheets you can find something like this ... maybe in your case also a better crystal exists and maybe it could help (notice for example differences in Error columns between 8MHz crystal and 7.3728MHz crystal). But in some MCUs it doesn't matter anymore.
        Click image for larger version

Name:	crystals and uart.jpg
Views:	86
Size:	165.1 KB
ID:	11430