implementing uart by digital I/o

Discussion in 'Embedded Systems and Microcontrollers' started by embedded.world, Apr 10, 2014.

  1. embedded.world

    Thread Starter Member

    Feb 27, 2014
    36
    0
    I am using AT89C51.
    I need two uart in my application. One uart is available in MCU.

    Second I am thinking to implement by digital I/o's


    Is there any reference code available for this.
    I am using Rx,Tx & Gnd only.

    Data can rx/tx simultaneously on both uart, so rx procedure has to be in ISR.

    Tx should be ideally high so can I put a 10K pull up on tx line
     
    Last edited: Apr 10, 2014
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
  3. embedded.world

    Thread Starter Member

    Feb 27, 2014
    36
    0
    I have searched some reference from internet & trimmed the code for my requirement.

    I have made a small algo for this. Can anyone look at it if this is correct.

    Meanwhile I am writing the code for it.


     
  4. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    With this software UART of yours, what will you do if there's a character being sent out, and half way through it a character starts coming in? It doesn't seem to me as if this can work.
     
  5. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Agreed.

    A better method is to use a timer interrupt at about 5* higher freq than one bit period. That int can constantly poll for incoming RX data and sync to it. It can also simultaneously (asynchronously) send TX data, sending one bit every 5 ints.

    A timer interrupt setup this way can process multiple RX and TX signals, to multiple in/out pins.

    So once it has been set up it is trivial to add more TX or RX channels.
     
  6. embpic

    Member

    May 29, 2013
    187
    3
    yes for that purpose you will need higher clock frequency.
     
  7. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,393
    497
    I have a silly question.
    Would it not be easier to use uart ic chip instead?

    I just looked at one at mouser, the datasheet even had an example code in C.
     
  8. embpic

    Member

    May 29, 2013
    187
    3
    what is frequency of machine cycle u r using???
     
Loading...