Anda di halaman 1dari 8

Laboratory Manual For

MICROCONTROLLER & MICROPROCESSORS LAB







Faculty of Engineering & Technology
Department of Electronic Engineering

DISPLAY THE COUNTING FROM 0000 to FFFF on
7 SEGMENT DISPLAY

OBJECTIVE:

To understand the 89c51 Microcontroller
To understand its pin configuration
To understand the running of a program for the counting of number in
hexadecimal on KEIL
To understand purpose of 7 segment display

INTRODUCTION:

AT89C51 is a powerful microcontroller which provides a high-flexible and
cost effective solution to many embedded control applications.

FEATURES of AT89C51 MICROCONTROLLER:

128 bytes of RAM for storing data
4KB flash code memory
32 I/O lines for communicating with other devices
Two 16-bit timers/counters
0 to 24MHz crystal frequency
Full duplex serial port, on chip oscillator and clock circuitry






Pin DIAGRAM of AT89C51 IC:


In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All
these ports are 8-bit bi-directional ports, i.e., they can be used as both input and
output ports. Except P0 which needs external pull-ups, rest of the ports have
internal pull-ups. When 1s are written to these port pins, they are pulled high by
the internal pull-ups and can be used as inputs. These ports are also bit
addressable and so their bits can also be accessed individually.
Port P0 and P2 are also used to provide low byte and high byte addresses,
respectively, when connected to an external memory. Port 3 has multiplexed
pins for special functions like serial communication, hardware interrupts, timer
inputs and read/write operation from external memory. AT89C51 has an inbuilt
UART for serial communication. It can be programmed to operate at different
baud rates. Including two timers & hardware interrupts, it has a total of six
interrupts.

7 SEGMENT DISPLAY:
Features
Low Current Consumption
High Brightness
Easy to Use
PCB Mounting
A seven-segment display (SSD), or seven-segment indicator, is a form of
electronic display device for displaying decimal numerals that is an alternative
to the more complex dot matrix displays. Seven-segment displays are widely
used in digital clocks, electronic meters, and other electronic devices for
displaying numerical information.



The 7 segment display can be in different colors like red, green, blue etc. They
have common anode.
IMAGE OF 7 SEGMENT DISPLAY IN DIFFERENT COLORS:



A 7-segment display is an assembly of light emitting diode-bars (segments)
each which can be powered individually. They are arranged and labeled as
shown in the diagram, in the form of an '8' in hexadecimal form. When all the
segments are powered on, the display show the number 8. Powering up
segments a, b, c, d, and g will display the number 3. Each individual 7-segment
can display numbers from 0 to 9. The 'dot' or dp represents the decimal point,
which can be selected either on the left or right side of the display.
KEIL SOFTWARE:
PURPOSE:
This software is used to write the code of a program of our requirement and
after writing it we make the hex file of that code, that hex file will burn on the
IC and the GENIUS G540 universal programmer is used for burning hex file on
IC.




CODE FOR DISPLAYING NUMBERS from 0000 to FFFF:
#include <AT89x51.h>
void delay (int time)
{
int a,b;
for (a = 0; a<time ; a++)
{
for (b= 0 ; b<1000 ; b++)
{ }
}
}
void main()
{
inti=0;
while (1){
if (i<255)
P1=0;
P3=i;
delay(300);
i++;
if(i>=255)
P1=i;
if (i>=65535)
P1=P3=0 ;}
}
This code is used to display the numbers from 0 to 15 in hexadecimal format,
initially we assign 0 value to port 3 then we call a delay function that will
produce a delay of 300 milli sec between the display of two numbers. The for
loop 0 to 255 is used to display the counting in hex format. While loop is used
to the continual of code up to FFFF, for this purpose we have given the true
condition while (1) which means it is always true.
Now save this code then go project> object for target> output> create hex file
Then burn this hex file on ic, double click on ic and select the hex file and click
ok it will burn on it.
CIRCUIT DIAGRAM:










FINAL OUTPUT:

Anda mungkin juga menyukai