You are on page 1of 3

ICLES’

MOTILAL JHUNJHUNWALA COLLEGE


DEPARTMENT OF C.S. / I.T
LABORATORY WORK

Name Signature:
Roll No. Date:

LED interfacing is the first thing, one would try to do while getting started with any microcontroller. So
here in this tutorial we are going to interface a LED with 8051 microcontroller, and will write a C
Program to blink the LED. We have used a very popular microcontroller AT89S52, of 8051 family,
by ATMEL.

Before going into detail, we should get some brief idea about microcontroller AT89S52. It is 40 pin
microcontroller, and has 4 ports (P0,P1,P2,P3), each port have 8 pins. We can consider each port
as 8 bit register, from the software point of view. Each pin having one Input/output line, means every
pin can be used for input as well as for output, i.e. to read data form some device like sensor or to
provide its output to some output device. Some pins have the Dual functionality, which has been
mentioned in bracket in Pin Diagram below. Dual functionally like for interrupt, counters, timers etc.
AT89S52 has two types of memory, first is RAM which has 256 Bytes of memory and second is
EEPROM (Electronically Erasable and Programmable Read Only Memory) which has 8k bytes of
memory. RAM is used to store the data during execution of a program and EEPROM used to store
the Program itself. EEPROM is the flash memory which we used to burn the program into.

Circuit Diagram and Explanation


We are using pin one of port 1 to connect the LED. In embedded C programming we can access
the PIN 1 of port 1 by using P1_0. We have connected a crystal oscillator of 11.0592MHz frequency
to the PIN 19 and 18 i.e. XTAL1 and XTAL2. Crystal oscillator is used to generate clock pulses, and
clock pulse is used to provide the mean for timing calculation, which is mandatory to synchronise all
the events. These type of crystals used in almost every modern digital equipment like in computers,
watches etc. Most commonly used Crystal is quartz. It's a resonant oscillator circuit and capacitors
are used to oscillate the crystal, so we have connected here 22pf capacitors. You can read about
“resonant circuits” to know more.

The circuit diagram for LED interfacing with 89S52 is shown in above figure. Pin 31 (EA) is
connected to Vcc, which is an active low pin. This should be connected to Vcc when we are not
using the any external memory. Pin 30(ALE) and pin 29 (PSEN) are used to connect microcontroller
to the external memory and Pin 31 tells microcontroller to use external memory, when connected to
Ground. We are not using any external memory so we connected Pin31 to Vcc.

Pin 9 (RST) is the reset PIN, used to reset the microcontroller and program again starts from the
beginning. It resets the microcontroller when connected to HIGH. We have used standard reset
circuitry, 10k ohm resistor and 1uF Capacitor to connect the RST pin.

Now the interesting part here is that we connect the LED in reverse, means negative leg with
microcontroller PIN, because microcontroller don’t provide enough power to glow an LED, so here
the LED run on the negative logic like when, pin P1_0 is 1 then LED will be tuned OFF and when pin
output is 0 then LED will be turned ON. When PIN output is 0, it behaves like ground and LED
glows.

You might also like