Attention !!! We are operating and shipping all Orders. But due to COVID-19 related restrictions, limited staff and reduced working time dispatches may be delayed.
Thanks for your understanding & Support. Be kind and stay safe!!

Product categories

Have You Seen

STM32F103C8T6 ARM Development Board

STM32F103C8T6 ARM Development Board

STM32F103C8T6 ARM Development Board (Blue Pill)STM32F103C8T6 Dev Board for ARM Microcontroller, STM3..

Rs.932.20 (inc GST)
Rs.790.00 + GST

SKU: 0626 | DAB048
Stock: 302


GY-906 MLX90614ESF MODULE GY-906-MLX90614ESF-New-MLX90614-Contactless-Temperature-Sensor-Module-Com..

Rs.1,314.52 (inc GST)
Rs.1,114.00 + GST

SKU: 2391 | DAC227
Stock: 0


Serial Communication is one of the most widely used methods of communications is microcontrollers. It provides a low cost solution for interfacing with the PC. Most of the micro controllers have one UART port, some have two UART ports but some lower end microcontrollers do not have a single UART port. Serial communication is also used for interfacing modules like GSM modems, GPS modules, RFID reader etc so what if you are using 8051 based controller and has just one UART port and want to serially interface more than one device to the same controller?

You can use a method called as “BIT BANGING”. Bit Banging basically uses Software for communication instead of a dedicated hardware. In this method Transmitting is done by alternating the Transmit Pin after specific interval, this time interval depends on the Baud rate for serial communication. In same way Receive function is performed by sampling the pin at regular interval. This is quite a tedious process and puts too much load the Micro controller processing.

Over here I will be explaining how to send and receive a byte using this method. This polling interval is decided by the communication Baud rate e.g. if the baud rate is 9600 bps then the polling interval will be 1/9600 seconds i.e.104µS.

Serial Communication
Figure 1
Figure 1 shows the basic Frame for serial communication. You can see the basic frame consists of Start Bit which is followed by the Data and end of transmission is indicated by a Stop Bit.

ALGORITHM for Sending Byte:-

  1. Start.
  2. Make Tx pin Low (Stop Bit).
  3. Wait for duration corresponding to baud rate.
  4. Send data bit.
  5. Wait for duration corresponding to baud rate.
  6. Go to 4 till all eight data bits haven’t been sent.
  7. Send Stop Bit
  8. Wait for duration corresponding to baud rate.
  9. Make Tx pin High
  10. Stop
Receiving a byte is more difficult than sending it. Since it is not possible to continuously poll the Rx pin we will be using external interrupt function for detecting the START bit of serial communication. Once this START bit has been detected we poll the Rx pin at regular interval.
We will be using P3.2 (INT0) as the Rx pin so that we can use the External Interrupt 0 to detect the Start Bit. Normally the Rx pin is high so when the pin becomes low i.e. Start Bit is received an interrupt is generated. The controller then deactivates the External Interrupts and starts polling the Rx pin at regular interval after getting next eight bits we confirm the receiving of the Stop bit and the External Interrupt 0 is activated again for receiving the next byte.

ALGORITHM for Receiving Byte:-

  1. Start.
  2. Turn ON External Interrupt 0.
  3. Wait for External Interrupt 0.
  4. Confirm Rx Pin is Low (Start Bit).
  5. Wait for duration corresponding to baud rate.
  6. Get Rx pins status.
  7. Go to 5 till eight bits haven’t been read.
  8. Wait for duration corresponding to baud rate.
  9. Check for stop bit.
  10. Stop
Written by Amol Shah

Amol Shah

Founder of DNA Technology an Electronic Engineer by choice. Started working on this website as an Hobby and now its a full time venture. Very passionate about Electronics and like to learn new stuff. Want to make DNA Technology one of the best Online Store for Electronics Components in India.
Follow Me Twitter | Facebook | Google Plus | Instagram