+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Newbie level 4
    Points: 52, Level: 1

    Join Date
    May 2016
    Posts
    5
    Helped
    0 / 0
    Points
    52
    Level
    1

    2 UART on a single port

    I am curently working on a project where a MCU got only one UART port available, however I need to run two peripherals with UART interface (not simultaneously) so I was wondering if I can connect two peripherals UARTs on the same UART of the MCU while playing with enabling and disabling the peripherals one by one for communicating with the MCU?

    Your feedbacks and recommendation are appreciated about this situation

    Regards

    •   AltAdvertisment

        
       

  2. #2
    Super Moderator
    Points: 70,762, Level: 64
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    14,472
    Helped
    3292 / 3292
    Points
    70,762
    Level
    64

    Re: 2 UART on a single port

    Hi,

    As long as your slaves don't talk randomly..

    In other words: if it is apure "master requests" --> "slave answers" system, then it is possible.

    You have to take care, that the disabled slave sees a HIGH = idle, without a LOW going pulse/glitch during switching.

    You may multiplex the RS232 signals or the TTL signals (wich needs two pairs of RS232 tranmitter/receiver).

    Klaus



  3. #3
    Advanced Member level 4
    Points: 7,241, Level: 20

    Join Date
    Jan 2015
    Posts
    1,013
    Helped
    320 / 320
    Points
    7,241
    Level
    20

    Re: 2 UART on a single port

    The simple answer is no.
    The more complex answer is that it is possible but not without adding other components.
    The real problem is that UARTs expect to be able to drive the Tx line all the time. That is not a prob elm when the 1 Tx line goes to two devices but when two devices try to drive the same line (the Rx line on the MCU say) then the two line drivers will conflict.
    By adding in extra component you can select which sender you listen to but that often limits the purpose of having two UARTs that otherwise could send whenever they needed to without being 'enabled'.
    This is a bit like the RTS/CTS lines on some UARTs but they do not necessarily tri-state the line drivers. If they do then that makes for an easier implementation (but still with additional control lines).
    Susan



    •   AltAdvertisment

        
       

  4. #4
    Full Member level 1
    Points: 3,581, Level: 14

    Join Date
    Jul 2001
    Posts
    113
    Helped
    2 / 2
    Points
    3,581
    Level
    14

    Re: 2 UART on a single port

    As I have understand you would like to connect two physical serial ports (SP1 and SP2) to one UART in PIC?
    Question which PIC you use and if there is possibility to remap pins. You could remap UART when you want and it could work. But you have another solution – software UART....
    Additionally it is possible to use UART as for instance RX from SP1 and TX to SP2. And software one for rest. It is only your will ;) The only limit is that you will be deaf while reinitialise UARTs



  5. #5
    Advanced Member level 2
    Points: 3,764, Level: 14

    Join Date
    Apr 2010
    Location
    UK
    Posts
    547
    Helped
    91 / 91
    Points
    3,764
    Level
    14

    Re: 2 UART on a single port

    The correct solution is to use the correct chip for the job in the first place of course.
    (I really don't understand why people seem to put these problems in their way so often)

    As an alternative you might be able to create a software uart but since you gave no
    information on what you are using and exactly how, only you can say if that's possible.



  6. #6
    Super Moderator
    Points: 28,642, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,527
    Helped
    1081 / 1081
    Points
    28,642
    Level
    41
    Blog Entries
    6

    Re: 2 UART on a single port

    At least, electrically it is possible to directly connect multiple busses; I did that a long time ago with the TX. In regard to RX I connected them by diode, but as mentioned above, you should certify that there wouldn’t occur any reception unless solicited by the device working as master.

    Click image for larger version. 

Name:	dby.PNG 
Views:	3 
Size:	10.4 KB 
ID:	129040
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  7. #7
    Newbie level 4
    Points: 52, Level: 1

    Join Date
    May 2016
    Posts
    5
    Helped
    0 / 0
    Points
    52
    Level
    1

    Re: 2 UART on a single port

    Quote Originally Posted by KamW View Post
    As I have understand you would like to connect two physical serial ports (SP1 and SP2) to one UART in PIC?
    Question which PIC you use and if there is possibility to remap pins. You could remap UART when you want and it could work. But you have another solution – software UART....
    Additionally it is possible to use UART as for instance RX from SP1 and TX to SP2. And software one for rest. It is only your will ;) The only limit is that you will be deaf while reinitialise UARTs
    I rather use TI chip such as CC1310 or CC2650



    •   AltAdvertisment

        
       

  8. #8
    Full Member level 1
    Points: 3,581, Level: 14

    Join Date
    Jul 2001
    Posts
    113
    Helped
    2 / 2
    Points
    3,581
    Level
    14

    Re: 2 UART on a single port

    With all chip uarts is the same problem - only one TX on the bus in the time, and there could be more RX. With few TX connected to line .
    But question is why not to use proven way with RS485 or CAN way?



--[[ ]]--