You are on page 1of 8

EXPERIMENT 01

Introduction to Microcontroller 8051, Keil µVision, and Proteus

Objective:

• Familiarize students with ATMEL 8051 IC and RIMS trainer kit.


• Familiarization with Keil µVision and Proteus software.

Background Knowledge:

A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded


system. A typical microcontroller includes a processor, memory, and input/output (I/O) peripherals on a
single chip. 8051 microcontroller was designed by Intel in 1981. It is an 8-bit microcontroller with 40 pins
DIP (dual inline package), 4kb of ROM storage and 128 bytes of RAM storage, and 2 16-bit timers. It
consists of four parallel 8-bit ports, which are programmable as well as addressable. An on-chip crystal
oscillator is integrated in the microcontroller having crystal frequency of 12 MHz. The pin diagram of 8051
microcontroller is given below.

• Pins 1 to 8 − These pins are collectively known as Port 1. This port is internally pulled up, bi-
directional I/O port and doesn’t serve any other function.
• Pin 9 − It is a RESET pin, which is used to reset the microcontroller to its initial values. The 8051
is reset by holding the rst high for at least two machine cycles and then returning it low. However,
content of on-chip ram is not affected by reset.
• Pins 10 to 17 − These pins are known as Port 3. This port serves some functions like interrupts,
timer input, control signals, serial communication signals RxD and TxD, etc.
• Pins 18 & 19 − These pins are used for interfacing an external crystal to provide system clock.
• Pin 20 − This pin is ground.
• Pins 21 to 28 − These pins are known as Port 2. It serves as I/O port. Higher order address bus
signals are also multiplexed using this port.
• Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used to read a signal from
the external program memory.
• Pin 30 − This is EA pin which stands for External Access input. It is used to enable/disable the
external memory interfacing.
• Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used to demultiplex the
address-data signal of port.
• Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port. Lower order address and data
bus signals are multiplexed using this port.
• Pin 40 − This pin is used to provide power supply to the circuit. The operating voltage of 8051
microcontroller is 5V.

Basic 8051 Circuit:

Oscillator circuit:

The 8051 microcontroller uses the crystal to synchronize its operation. Effectively, the 8051 operates using
machine cycles, where a single machine cycle is the minimum amount of time in which a single 8051
instruction can be executed. 8051 has an on-chip oscillator. It needs an external crystal that decides the
operating frequency of the 8051. The crystal is connected to pins 18 and 19 with stabilizing capacitors. 12
MHz (11.0592 MHz) crystal is often used and the capacitance ranges from 20 pF to 40 pF.
Using Ports for I/O Operation:

8051 is TTL logic device and has two levels: logic "high" (1) and logic "low" (0). The voltage and current
involved for the two levels are as follows:

Level Voltage Current


High Above 2.4v Virtually no current flow

1.6 mA sinking current from TTL input to ground


Low Below 0.9v
(depends on logic family)

Port functions:

Ports Function
Dual-Purpose Port
Port 0 (Pin 32-39) • General purpose I/O port.
• Multiplexed address & data bus open drain outputs.
Dedicated I/O Port
Port 1 (Pin 1-8)
This port is used solely for interfacing to external devices (internal pull-ups).
Dual-purpose port
Port 2 (Pin 21-28)
• General purpose I/Oport.
• A multiplexed address & data bus (internal pull-ups).
Dual-purpose port
Port 3 (Pin 10-17)
• General purpose I/O port.
• Pins have alternate purpose related to special features of the 8051 (internal
pull-ups).

Configuring for Input:

When power is on all ports are output ports by default. To configure any port for input, write all 1’s (0xff)
to the port. Any port can be used for output but for input, the FET must be off. Otherwise, the IC will be
reading the latch values rather than the external signal. Therefore, a "1" should be written to the pin if you
want to use it as input, especially when you have used it for output before. If you don't do this input high
voltage will get grounded through FET so you will read pin as low and not as high. It is best to use a resistor
while driving a port high otherwise the FET would burn.

Keil µVision Software:

Keil development tools for the 8051 microcontroller architecture support every level of software developer
from the professional applications engineer to the student just learning about embedded software
development, the industry-standard Keil c compilers, macro assemblers, debuggers, real-time kernels,
single-board computers, and emulators support all 8051 derivatives and help you get your projects
completed on schedule.

• When starting a new project, simply select the microcontroller you use from the device database
and the µvision IDE sets all compiler, assembler, linker, and memory options for you.
• Numerous example programs are included to help you get started with the most popular embedded
8051 devices.
• The Keil µvision debugger accurately simulates on-chip peripherals (i²c, CN, UART, SPI,
interrupts, I/O ports, A/D converter, D/A converter, and PWM modules) of your 8051 device.
Simulation helps you understand hardware configurations and avoids time wasted on setup
problems. Additionally, with simulation, you can write and test applications before target hardware
is available.

Procedure:

1. Open the Keil µVision software.


2. Click the project on the main tool bar.
3. Select new project and name it.
4. Then select ATMEL 89c51 microcontroller.
5. Create a new file from the file menu.
6. Save the file with extension with .asm or .c.
7. Click the target in the main window, and then right click the source to select the saved file.
8. Now open a new file and type the program, save it with a new name.
9. Right click the target and go to its properties.
10. Change the microcontroller frequency to 11.0592 MHz.
11. On the output menu, check the “create hex file” box.

Procedure to Use Microcontroller HEX Files in Proteus:


• In start menu open the software ISIS from Proteus professional.
• Open the option “pick device” as shown in figure.
• Now select microprocessors ICs from left window and from microprocessors library select
AT89c51.

• Now place this IC on circuit.


• Now to load program file right click on IC, it will turn into red, now if you again right click on the
component, this will delete that component and if you left click it will show you component
properties; so double right click is used to delete and single right click followed by single left click
opens the properties of that component.

• Now in program file option browse for desired hex file and load it on the controller.
• For output visualization you have an option “visual instruments” in left window, you can choose
oscilloscope from there.

• For voltage sources you can select any generator from the left toolbar option “generators”.

• For connecting different components use left click at the pin of one component it will start making
a wire, hold left click till you connect it to the other terminal of connection.

Lab Task:
Write a code to continuously turn an LED on and off in Keil µVision. Burn this code on 8051
microcontroller chip and obtain the results. Verify the results in Proteus.
Conclusion:

You might also like