Microcontrollers – Part 6 : The UART Interface

   Microcontrollers – Part 6: The UART Interface

   It’s time to meet again with our little friend: CPU Monkey – the “manager” of all processes into our Virtual machine – The Microcontroller.

   Today, the CPU Monkey will communicate… using the UART interface. It will be a Heavy work … , or just a fun ! 

    But, to communicate, the CPU monkey needs an interlocutor. It will be his brother.  To easily recognition them, we will apply the indexes  #1 and #2, i.e. CPU Monkey #1 and CPU Monkey #2.

   NOW, let’s try to answer the questions below?

   What does the UART mean?

   Is It necessary, and how to use it?

   Firstly, we need to generate the explanation of this question:

  What does the Interface?

  The “Interface” is a complex of activities and ways of communication between the devices. As an analogy with the Humans: the speaking and the languages are the activities and ways to communicate each other.

  We can separate the physical and logical level of communication:

  • Physical level;
  • Logical level.

  Now, we are talking about The physical level of communication:


  We could recognize two different types of communication, related as data are simultaneously transferred : parallel ,and serial – Bit-by-Bit :

  Parallel communication:

  • Tetrade-by-Tetrade, used in 4-bit logic:  -> obsolete, it is rarely used,
  • Byte-by-Byte: -> most useful, 
  • 16 bit, 32 bit or / custom, Word-by-Word: -> it is rarely used.

   As we can see, there is minimum 4, 8, 16, 32 or more connection wires, than normally a few, up to 3 connecting wires in the serial communication (The full UART uses many signals and it is an exception).

   Serial communication:

  • Independently by surrounding additional signals, transferring the data serially – Bit-by-Bit at one moment.


   The UART interface has to construct the physical’s interface level of communication – In its simple configuration uses two wires: One for the receiving and second one for the transmission of data.

  How does it make?

  The UART, As an abbreviate, means:  Universal Asynchronous Receiver / Transmitter.

  Let’s prepare the Monkey’s working places.


   CPU Monkey #1 Has a Left Table #L with all necessary thing on the table.

   CPU Monkey #2 Has a Right Table #R with all necessary thing on the table.

   Two Monkeys will use the Metronome for the UART clock setting and they both need a new thing – the light torch.

   The Serial Asynchronous communication we will try to explain in the same funny way as  previously our explanations of the things.

   Two metronomes are “synchronized ” –  clocking the time – knock – knock periodically, with the same frequencies. Let it be 1 knock per second. Just for the analogy, the real UART interface has hundred thousand times faster clock … amazingly, is it?

  Example: CPU Monkey #1 needs to send a message to CPU Monkey #2.


   The simple message#1 is Data : AA [a Hex style representation]  equal to a bit representation in two tetrades as following:   1010 1010 [an Boolean Style representation].

   Now, the answer is going to be sent from CPU Monkey #2 to CPU Monkey #1:

   The simple message #2 is Data : 55 [a Hex style representation]  equal to a bit representation in two tetrades as following:   0101 0101 [an Boolean Style representation].

  The For easy understanding and for Monkeys acknowledge – Message #2 is just an inverted Message #1;

  Let We suppose:

  • We will send the most significant [7-th bit] First will be the most significant Bit-7 :  Send [7th Bit]=1 ,  Send [6th Bit]=0     …  Send [1st Bit]=1 and next will be the least significant bit 0 Send [0th Bit]=0;
  • the logical level ‘1’ to be associated with a light torch = ON, and
  • the logical level ‘0’ to be associated with a light torch = OFF.
  • Two companies: The Intel and Motorola have the inverted representation of the meaning, which is the first sent bit [7th or 0th].

  Data transferred need to be  1 [torch = ON] , then, 0 [torch = ON] ……  1 [torch = ON] , then, 0 [torch = ON].  End of transition. The system is going in the IDLE State.

Let We do a Small jump into real way of communication.  


The Real Interface on the Physical Level is using RS-232C to TTL – converter is using to prevent the damages of input GPIO of CPU: 


  Pictures above are giving a simple sight to a real interface additional components. 

  Now, We are retuning into our Virtual Example.  

   Let we generate our virtual example:

  The Tables #L and #R are starting knocking – the metronomes are set and clocking, second by second.

  The Connection Dialog is Beginning.  

  It Starts with first light ray pulsed by CPU monkey #1. forward the CPU monkey#2  or its working position near the Table #R.

  CPU Monkey #1 stays the torch in ON state, till It hears the knock ‘tick’ from the metronome. After that he immediately changes the torch state, corresponding with data ‘logical state’ of next sent Bit.

  CPU Monkey #2 see the lights and start to write on the sheet of paper, Received ‘states’ or logical levels of received light signals.

  The CPU Monkey #2 are sampling a valid data, with the small delay of 0.5 sec till the moment of each metronome ‘knock’ – on the edge of the metronome clocks.

  It is equal to sampling the data into the middle of the bit duration pulse.

   The analogy of this funny example with a real UART is different only with the condition, the BIT is divided into 16 different pieces, and it gets the statistic: 2-by-3 taking the result from 8th, 9th, 10th logical level sample.

   If two samples or three samples are  ‘high’, the UART engine get the bit is equal to 1[High Logical Level], in opposite case , if one or more sampling results are zero, the UART engine gets the bit is equal to 0 [Low logical level].  




   As you probably see, the usage of  Virtual Monkey’s metronomes Synchronisation and Real UART hardware middle-bit sampling synchronization is a necessary activity.

   Imagine the described data sending without any kind of synchronization – what a mess! It won’t be a usable dialog. It will be a kind – the symphony of noises.

   When the CPU Monkey #2 finishes listening to a data transfer,  and on paper in front of him is written 1,0,1,0,1,0,1,0, He can start answering the CPU monkey #1 with 55 [Hex] Data.

   All procedure described above is repeating until the data 0,1,0,1,0,1,0,1 is received on paper in front of CPU Monkey #1.

   Real UART Interface and full hardware UART variant with additional pins, creating synchronous transfer, using the handshaking technique.

   The UART in both configurations is a valuable part of an industrial physic level of communication, also between the MCU and any supporting such interface electronic device.

   Let Switch the light torch in off state – Saving their batteries.

   CPU Monkey # 1 and #2 are going to rest – their Virtual UARTs are going to the idle state.


Don’t Stop To Reinvent Yourself, Dear Explorers!



Amazon Gift Ideas  Affiliate Link

Amazon Hot New Releases  Affiliate Link

Amazon Best Sellers  Affiliate Link


Leave a Reply