RS232 Communication – The Basics
RS232 is a asynchronous serial communication protocol widely used in computers and digital systems. It is called asynchronous because there is no separate synchronizing clock signal as there are in other serial protocols like SPI and I2C. The protocol is such that it automatically synchronize itself. We can use RS232 to easily create a data link between our MCU based projects and standard PC. Excellent example is a commercial Serial PC mouse (not popular these days, I had got one with my old PC which I bought in year 2000 in those days these were famous). You can make a data loggers that reads analog value(such as temperatures or light using proper sensors) using the ADC and send them to PC where a special program written by you shows the data using nice graphs and charts etc.. actually your imagination is the limit!
Basics of Serial Communication.
In serial communication the whole data unit, say a byte is transmitted one bit at a time. While in parallel transmission the whole data unit, say a byte (8bits) are transmitted at once. Obviously serial transmission requires a single wire while parallel transfer requires as many wires as there are in our data unit. So parallel transfer is used to transfer data within short range (e.g. inside the computer between graphic card and CPU) while serial transfer is preferable in long range.
As in serial transmission only one wire is used for data transfer. Its logic level changes according to bit being transmitted (0 or 1). But a serial communication need some way of synchronization. If you don't understand what I mean by "synchronization" then don't worry just read on it will become clear.
The animation below shows you how a serial transmission would look like (if you can see electricity).
![]() |
Fig- A Serial Line.(HIGH=RED & LOW=WHITE) |
Can you make out what data is coming? No because you are not synchronized. You need a way to know when a new byte start and when a bit ends and new bit start. Suppose the line is low for some time that means a '0' but how many zeros? If we send data like 00001111 then line is first low for some time and high after that. Then how we know it is four '0's and four '1's?
Now if we add another line called the clock line to synchronize you then it will become very easy. You need to note down the value of data line only when you see the "clock line" high. Lets understand this with help of an animation.
![]() |
Fig- A Serial Line.(HIGH=RED & LOW=WHITE) |
Now you can see how the "clock" line helps you in "synchronizing" the incoming data. In this way many serial busses like SPI and I2C works. But USART is different in USART there is no clock line. So it is called UART - Universal Asynchronous Receiver Transmitter. In USART a start bit and stop bits are used to synchronize the incoming data the.
RS232
In RS232 there are two data lines RX and TX. TX is the wire in which data is sent out to other device. RX is the line in which other device put the data it need to sent to the device.
Fig- RS232 transmission. The arrows indicates the direction of data transfer. In addition to RX/TX lines there is a third line i.e. Ground (GND) or Common. |
One more thing about RS232. We know that a HIGH =+5v and LOW=0v in TTL / MCU circuits but in RS232 a HIGH=-12V and LOW=+12V. Ya this is bit weird but it increases the range and reliability of data transfer. Now you must be wondering how to interface this to MCUs who understand only 0 and 5v? But you will be very happy to know that there is a very popular IC which can do this for you! It is MAX232 from Maxim Semiconductors. I will show you how to make a level converter using MAX232 in next tutorial.
As there is no "clock" line so for synchronization accurate timing is required so transmissions are carried out with certain standard speeds. The speeds are measured in bits per second. Number of bits transmitted is also known as baud rate. Some standard baud rates are
- 1200
- 2400
- 4800
- 9600
- 19200
- 38400
- 57600
- 115200
- ... etc
For our example for discussion of protocol we chose the speed as 9600bps(bits per second). As we are sending 9600 bits per second one bits takes 1/9600 seconds or 0.000104 sec or 104 uS (microsecond= 10^-6 sec).
To transmit a single byte we need to extra bits they are START BIT AND STOP BIT(more about them latter). Thus to send a byte a total of ten bits are required so we are sending 960 bytes per second.
Note: The number of stop bits can be one or two (for simplicity we will be using single stop bit)
There is one more bit the parity bit but again for simplicity we would not be using it)
RS232 Data Transmission.
The data transfer is done in following ways
Transmission
- When there is no transmission the TX line sits HIGH (-12V See above para) ( STOP CONDITION )
- When the device needs to send data it pulls the TX line low for 104uS (This is the start bit which is always 0)
- then it send each bits with duration = 104uS
- Finally it sets TX lines to HIGH for at least 104uS (This is stop bits and is always 1). I said "at least" because after you send the stop bit you can either start new transmission by sending a start bit or you let the TX line remain HIGH till next transmission begin in this case the last bit is more than 104uS.
Fig- Data Transmission on RS232 line. |
Reception
- The receiving device is waiting for the start bit i.e. the RX line to go LOW (+12V see above para).
- When it gets start bit it waits for half bit time i.e. 104/2 = 51uS now it is in middle of start bit it reads it again to make sure it is a valid start bit not a spike.
- Then it waits for 104uS and now it is in middle of first bit it now reads the value of RX line.
- In same way it reads all 8 bits
- Now the receiver has the data.
Fig- How the Receiver receives the data on RS232 RX line |
To be continued ...
Ok friends that's it for now meet you in next tutorial. Till then good bye!
If you are facing any difficulties in understanding the topic, feel free to post a comment and I will surly help you as soon as possible.



[...] to the third part of my RS232 serial communication tutorial. Till now we saw the basics of RS232 communication and made our level converter. Now its time to understand the USART of AVR microcontroller and write [...]
December 12th, 2008 at 6:30 pmits very very interesting…
December 25th, 2008 at 1:39 am[...] RS232 Basics [...]
December 29th, 2008 at 12:13 pmIts very difficult to find the next tutorial, Is it possible for you to give the link of next tutorial when some tutorial finished . In the its only written this tutorial is finished meet in next tutorial but how to go for next tutorial is not given . CAN YOU PLZZZZ GIVE LINK FOR NEXT TUTORIAL not only for this but for all tutorial
March 5th, 2009 at 4:32 pmHello,
Go to “AVR Tutorials” section from the right sidebar navigation. There are all tutorials are listed.
March 6th, 2009 at 8:57 amthank you very much.
April 8th, 2009 at 8:09 amgud. thanx
May 28th, 2009 at 7:03 pm[...] http://extremeelectronics.co.in/avr-tutorials/rs232-communication-the-basics/ [...]
July 20th, 2009 at 7:02 amgood tutorial.
any code for debounce problem.
can you suggest how to use TI cc2500 . i have Atmega 16L kit. it would be nice of you if you send me any link of Atmega16 schematic with cc2500.
nice work !!!
September 3rd, 2009 at 5:42 amAvinash Gupta you are a Guru! I take my hat for you.
I am 48 years old, and only today i could really (really underlined) RS232.
Thanks man!
November 10th, 2009 at 5:07 pmIts guys like you who make the Internet a great place to spend time and learn.
…much appreciation, from Sávio Gonçalves – PORTUGAL
@Savio
Thanks Mr Savio for your kind words !!!
November 11th, 2009 at 8:17 amThank you so much…really interesting
November 20th, 2009 at 1:41 amAvinashji , hats off for u.
December 1st, 2009 at 3:29 pmi hav done b.tech. but this type of explain i havenot seen anywhere. may this site live long life
Hi! frnds,
I have 3+ exp. in embedded domain and I have done lots of communication protocol base projects. I think this documents really gives you better gudeline. I am greatful to gives a thanx to technical person who Involved such great kind of activity.
Thanx & Regards
January 11th, 2010 at 2:02 pmSumit Gupta
there is a minor error i found in the article is that in the reception example
Quote
“When it gets start bit it waits for half bit time i.e. 104/2 = 51uS now it is in middle of start bit it reads it again to make sure it is a valid start bit not a spike.”
well i m pretty sure that 104/2 is 52 and not 51.
the explanation of the articles are just aweinspiring(awesome+inspiring)and gr8 for beginners in the field of robotics and electronics.
Lastly,Thank you for your contribution.
Regards,
January 26th, 2010 at 6:19 pmGaurav Parida
Thanks for that excellent info. i never understood this comms protocol until now.
February 11th, 2010 at 10:59 amDude! Thanks for this website! I love avr’s and your website and tutorials has helped me tonnes!!!!!!!!!!
Keep it up!!!
February 11th, 2010 at 12:00 pmsir, thanx 4 all the info u provided……very useful…..
March 4th, 2010 at 1:00 ammy ques is that wat does this mean….
baudrate=25; when baudrate is 2400….
wat hav to b writtten for 9600…. and by which criteria…
regards
@Kamran Where it is written ???
“baudrate=25; when baudrate is 2400″
March 4th, 2010 at 9:13 am