8051 Microcontroller LED Interfacing

by Ramatronics Laboratory in Circuits > Microcontrollers

1616 Views, 3 Favorites, 0 Comments

8051 Microcontroller LED Interfacing

AT89S52 ICSP Programming.png

In this Instructables, I am going to show you how you can program 8051(AT89S52) microcontroller using Arduino Uno(As ISP Programmer). We will create a simple program to turn on and off of an LED that is connected to pin 0 of PORT1. Let's get started!.

Supplies

AT89S52-Pin-Diagram.png
22PF.jpg
mb102-830-point-solderless-pcb-bread-board.jpg
Solderless-Breadboard-Jumper.jpg
12mhz-crystal-oscillator-500x500.png
Arduino uno.jpg
5mm_Red_LED.jpg

Hardware List:


https://www.quartzcomponents.com


8051 (AT89S52) Microcontroller

https://quartzcomponents.com/products/at89c51-microcontroller?_pos=1&_sid=3f2f7e18d&_ss=r

Arduino Uno( with Programming USB Cable)

https://quartzcomponents.com/products/arduino-uno-r3-atmega328p-arduino-compatible-no-cable?_pos=2&_sid=181560fa7&_ss=r

Bread board

https://quartzcomponents.com/products/colored-breadboard-mb-102-830-point?_pos=3&_sid=87c1bce97&_ss=r

Jumper wires

https://quartzcomponents.com/products/65pcs-breadboard-jumper-cable?_pos=3&_sid=3c316aaf8&_ss=r

Red LED (5mm)

https://quartzcomponents.com/products/red-5mm-led?_pos=1&_sid=98aba3d3f&_ss=r

12Mhz crystal

https://quartzcomponents.com/products/crystal-oscillator-12mhz?_pos=1&_sid=fa128b055&_ss=r

https://www.amazon.in/12-Mhz-Crystal-Pack-4/dp/B08NV7QF4V/ref=sr_1_1?crid=16KHRN9LHHIXD&keywords=12+mhz+crystal&qid=1663614316&sprefix=12+MH%2Caps%2C417&sr=8-1

22 PF Capacitor

https://quartzcomponents.com/products/22pf-ceramic-capacitor-pack-of-5?_pos=1&_sid=2d9ae0070&_ss=r

330 ohm Resistor

https://quartzcomponents.com/products/330-ohm-1-4-watt-resistor-with-1-tolerance-pack-of-10?_pos=2&_sid=f5ab132db&_ss=r


https://www.amazon.in


8051 (AT89S52) Microcontroller

https://www.amazon.in/Mount-AT89S52-Microcontroller-Flash-24MHz/dp/B00NYAELYE/ref=sr_1_5?crid=19JXDM3VN9H3R&keywords=at89s52+microcontroller&qid=1663613874&sprefix=AT89s%2Caps%2C529&sr=8-5

Arduino Uno( with Programming USB Cable)

https://www.amazon.in/Arduino-Uno-ATmega328P-USB-Cable/dp/B01LCN8IRK/ref=sr_1_5?crid=31ZW0R4KR9GVJ&keywords=Arduino+UNO&qid=1663614031&sprefix=arduino+un%2Caps%2C436&sr=8-5

Bread board

https://www.amazon.in/Robotbanao-Solderless-MB102-Breadboard-Points/dp/B08GG6ZC41/ref=sr_1_50?crid=3FG0A2FA62LMG&keywords=bred+board&qid=1663614092&sprefix=bred%2Caps%2C564&sr=8-50

Jumper wires

https://www.amazon.in/Scriptronics%C2%AE-Breadboard-Jumper-Dupont-Wire/dp/B09M7KFQ6S/ref=sr_1_35?crid=16YTW7JLAE6CT&keywords=jumper+wires&qid=1663614172&sprefix=jumper+wire%2Caps%2C603&sr=8-35

Red LED (5mm)

https://www.amazon.in/Red-LED-5mm-Diffused-Pieces-Pack/dp/B08P1DLM7G/ref=sr_1_6?crid=1CMZ31C6BWW9D&keywords=RED+LED+5mm&qid=1663614250&sprefix=red+led+5mm%2Caps%2C395&sr=8-6

12Mhz crystal

https://www.amazon.in/12-Mhz-Crystal-Pack-4/dp/B08NV7QF4V/ref=sr_1_1?crid=16KHRN9LHHIXD&keywords=12+mhz+crystal&qid=1663614316&sprefix=12+MH%2Caps%2C417&sr=8-1

22 PF Capacitor

https://www.amazon.in/22pF-50V-Ceramic-Capacitor-Pack-20/dp/B08X2PH6MR/ref=sr_1_1?crid=12T63WXNRQN7S&keywords=22PF&qid=1663614382&sprefix=22+pf%2Caps%2C336&sr=8-1

330 Ohm resistor

https://www.amazon.in/330-ohm-Watt-Resistor-Pieces/dp/B08WX5B8W5/ref=sr_1_3?crid=89FFDSFVTP9T&keywords=330+ohm+resistor+1%2F4w&qid=1663614486&sprefix=330+ohm+res%2Caps%2C400&sr=8-3

Download the Keil Micro Vision 5 Software

Screenshot (25).png
Screenshot (26).png
keil-uvision5.png

To write a c program to blink an LED, I am going to use the Keil micro vision 5 software. Which is used to write c program for 8051 microcontroller and generating HEX file for the 8051 microcontroller chips. you can download this software by the link given below.

link: https://keil-vision.software.informer.com/5.0/

Creating a Prototype Circuit on Breadboard

IMG_20220915_151653.jpg
IMG_20220915_151809.jpg
IMG_20220915_152018.jpg
IMG_20220915_152110.jpg
IMG_20220915_152156.jpg
IMG_20220915_152352.jpg

Circuit building is one of the toughest problem for beginners. So if you do not have good knowledge and experience of circuit making on a breadboard, you can follow my instructions that will make your work easier.

  1. Insert the AT89S52 Microcontroller chip on the breadboard.
  2. Connect the Vcc pin(40) of IC to +ve line(rail) of the breadboard with a red(you can choose any color, it has no technical sense) jumper wire.
  3. Connect the EA/Vcc pin(31) to the +ve rail of breadboard.
  4. Connect the GND pin(20) Pin of the IC to -ve line(rail) of the bread board.
  5. Connect a 12 MHz crystal on XTAL1 pin(19) and XTAL2 pin(18) of IC and also connect a 22PF or 33PF ceramic capacitor on XTAL1 and XTAL2 pins and -ve line (GND).
  6. Connect an LED on PORT1.0 pin(0) of in such a way that anode of the LED is connected to +ve line and cathode is connected to PORT1.0 pin of the IC in series with a 330 ohm Current limiting resistor.
  7. Connect the SPI(Serial Peripheral Interface) pins and reset pin of IC to the ISP programmer(Arduino UNO) according to following wiring scheme.

P1.5 (MOSI) pin(6) ----------------> Pin 11 of Arduino UNO.

P1.6 (MISO) pin(7) ------------------> Pin 12 of Arduino UNO.

P1.7 (SCK) pin(8) -------------------> Pin 13 of Arduino UNO.

Reset pin(9) ---------------------------> Pin 10 of Arduino UNO

Connect the +ve(red) line and -ve(blue) line of the bread board to the 5V and GND pins of Arduino UNO respectively.

now all the wiring is finished here.


NOTE: Please check and match all the wiring connection of your circuit with the help of given circuit diagrams.


Make the Arduino Uno As ISP Programmer

Screenshot (23).png
Screenshot (24).png

To use the Arduino UNO as ISP Programmer, open the arduino IDE on your computer and upload the Arduino ISP sketch on the UNO board. This sketch is already saved in Arduino IDE software so here you don't need to type it. After successfully uploading the Arduino ISP sketch on UNO board, your ISP Programmer is ready now.

Creating a LED Blink Program in Keil Micro Vision 5

Screenshot (26).png
Screenshot (30).png
Screenshot (34).png
Screenshot (33).png

we create a c program to blink the LED which is connected to fist pin of the PORT1 of 8051(AT89S52). For this follow the given steps:

open the Keil micro vision 5 IDE

click on project tab and choose New Uvision Project.

Give a Title (such as LED Blink in my case) and Save it.

Now you have to type the AT89S52 in search box and click on AT89S52 that appears in box just below search option and click on OK.

a new option copy 'STARTUP.A51' to project folder and add file to project will appear So just ignore it and clink on NO.

now open a new file and start writing the following C program in new file and then save it with name LED Blink.

Again go to project bar and choose option "options for Target Target 1" and write the 12 in XTAL(MHz) option, this is because here we are using a 12 MHz crystal.

After this we click on output tab and tick the option Create hex File. And click on OK.

now write the following C program in your IDE.


#include<reg51.h>

sbit LED = P1^0;

void delay_ms(unsigned int ms_count)
{
  unsigned int i, j;
  for(i=0; i<ms_count; i++)
  {
   for(j=0; j<1275; j++);
  }
}

void main()
{
 while(1)
  {
     LED = 1;
	 delay_ms(100);
	 LED = 0;
	 delay_ms(100);
  }
}

After writing the above c program, click on build option and if you did not get any error and warning after building then your LED blink program is ready.

If you get some kind of error message on the output, please recheck your program and correct the mistake and then again click on build option. Now your error will probably get corrected.


Save the 8051 Config File in Your C Drive

Download the 8051 Configuration file and save it in your C drive without changing its name. Create a new folder on your desktop and rename it as 8051 hex. Now save your LED blink hex file in this folder. you can get this hex file on the following location of your computer.

C:\Keil_v5\C51\Examples\HELLO\Objects.

8051.conf file is not supported by instructables so I will provide an another way soon please wait.

Uploading the LED Blink Hex File on 8051 Microcontroller

Screenshot (27).png
Screenshot (28).png
Screenshot (35).png

To upload the created led blink hex file on 8051 microcontroller using ISP Programmer(Arduino UNO), follow the given steps:

Open the command prompt on your computer/Laptop.

copy the text given in command.txt file (given below) in your command prompt and just press Enter and uploading process starts.