pcbway




UART communication in 8051 microcontroller,serial data in 8051 microcontroller, sending data with serial 8051, receive data in serial 8051, 8051 serial communicationHello friends, hope you are having fun. In today’s post, we will have a look at Serial Communication with 8051 Microcontroller in Proteus ISIS. In the previous post, we have seen a detailed post on LED Blinking Project using 8051 Microcontroller in Proteus ISIS, which was quite a simple tutorial. And I hope if you are new to 8051 Microcontroller then from that post you must have got some idea about C Programming of 8051 Microcontroller.

Now, today we are gonna go a little further and will have a look at Serial Communication with 8051 Microcontroller and we will also design the simulation of this project in Proteus ISIS software. 8051 Microcontroller also supports Serial port similar to Arduino and PIC Microcontroller. And the communication protocol is exactly the same as its a Serial Port. But obviously the syntax is bit different as we are not working in Arduino software or MPLAB. So let’s get started with it.

Serial Communication with 8051 Microcontroller in Proteus

  • Let’s first have a little recall of Serial communication. In serial communication we have two pins which are named as TX and RX.
  • TX pin is used for transmitting data while the RX pin is used for receiving data.
  • So, our microcontroller has these two pins as it supports Serial Communication and these pins are located at Pin no 10 and 11 in AT89C52 Microcontroller, which I am gonna use today.
  • First of all, we will design a Simulation of this project in which there will be 8 LEDs attached to Port 1 and by sending characters through Serial port, we will either turn these LEDs ON or OFF.
  • After designing the Simulation, we will then design the programming code for 8051 Microcontroller and will test our result.
  • So, let’s get started with Proteus Simulation of Serial Communication with 8051 Microcontroller.
Proteus Simulation
  • Open your Proteus software and get these components from your Proteus Component Library:

UART communication in 8051 microcontroller,serial data in 8051 microcontroller, sending data with serial 8051, receive data in serial 8051, 8051 serial communication

  • Now, design a circuit for Serial Communication with 8051 Microcontroller in Proteus software as shown in below figure:

UART communication in 8051 microcontroller,serial data in 8051 microcontroller, sending data with serial 8051, receive data in serial 8051, 8051 serial communication




  • Now in the above figure, I have used crystal Oscillator of 16MHz as I did in the previous post LED Blinking Project using 8051 Microcontroller and again the reset is pull Down.
  • Next I have attached Virtual Terminal with TX and RX of 8051 Microcontroller, if you don’t know about Virtual Terminal much then I suggest to read How to use Virtual Terminal in Proteus ISIS.
  • Finally, I have attached the 8 LEDs on Port 1 so that we could check whether we are getting correct data or not.
  • Now let’s design the programming code.
Programming Code
  • Now open your Keil micro vision 4 software and paste the below code into it.

  • You can see in the above code that baud rate we have used is 9600and we have used a switch case method for turning ON or OFF Leds.
  • So, now what it will do is when you send 1 on Serial Monitor, it will turn ON the first LED and when you send “a” on Serial Terminal then it will turn OFF the first LED. The same will go on for 8 LEDs.
  • Character 1,2,3,4,5,6,7,8 will turn ON the LEDs from 1 to 8 respectively.
  • While the character a,b,c,d,e,f,g,h will turn OFF the LEDs from 1 to 8 respectively.
  • For each command it will reply us back a single character which is “k”. So in this way we are doing the two way communication i.e. sending as well as receiving the serial data.
  • So, now after adding the code, get your hex file and then upload it to your Proteus Simulation and click the RUN button on your Proteus software.
  • When you start your Proteus Simulation, all the LEDs will be OFF and the virtual terminal will be open as shown in below figure:

UART communication in 8051 microcontroller,serial data in 8051 microcontroller, sending data with serial 8051, receive data in serial 8051, 8051 serial communication

  • So, now click in the Virtual Terminal and press 1 and the first LED will get ON and you will get k in response as shown in below figure:



UART communication in 8051 microcontroller,serial data in 8051 microcontroller, sending data with serial 8051, receive data in serial 8051, 8051 serial communication

  • You can see in the above figure, I have pressed 1 and the first LED goes ON as well as we get a response “k” in the virtual Terminal.
  • So, that’s how we can turn ON or OFF LEDs so in the below figure, I have turned ON all the 8 LEDs.

UART communication in 8051 microcontroller,serial data in 8051 microcontroller, sending data with serial 8051, receive data in serial 8051, 8051 serial communication

  • Now you can see in the above figure,all leds are on and the virtual terminal is showing k for 8 times as I have given 8 instructions.
  • You can download the Proteus Simulation along with hex file and the programming code by clicking the below button.

Download Proteus Simulation and Code

So, that’s how we can do Serial communication with 8051 Microcontroller. I don’t think its much difficult but still if you have problems then ask in comments and I will resolve them. That’s all for today and will meet in the next tutorial soon.

3 Comments

  1. serial rxtx.c(1): error C141: syntax error near ‘&’
    serial rxtx.c(1): error C129: missing ‘;’ before ‘.’
    serial rxtx.c(1): error C309: bad or missing filename
    serial rxtx.c(1): warning C318: can’t open file ”
    serial rxtx.c – 3 Error(s), 1 Warning(s).

    i am using keil uv5

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment