0% found this document useful (0 votes)
19 views23 pages

'KB Lab Microprocessor and Microcontroller-1' With You

Task of keil version 5

Uploaded by

momainali0786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views23 pages

'KB Lab Microprocessor and Microcontroller-1' With You

Task of keil version 5

Uploaded by

momainali0786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Lab Manuals

Microcontroller & Microprocessor

Submitted To:
Sir Farooq
Submitted by:
Khuda Bux
FL210097
BS ELECTRONICS
SEMESTER-5

NATIONALUNIVERSITYOFMODERNLANGUAGES
ISLAMABAD
Lab#01:
Introduction to 8051 microcontroller architecture, pin diagram,
memory organization, and basic instructions.

Introduction:
The 8051 microcontroller is a popular microcontroller that has been widely
used inembedded systems and applications since its introduction in the
1980s. It was developedbyIntelandhasbecomeastandardinthe
industry.The8051microcontroller architectureis based on the Harvard
architecture and has a rich set of features suitable for a variety
ofapplications.

8051MicrocontrollerArchitecture:
The8051 microcontrollerarchitecture consists ofthefollowingkeycomponents:
1. Central Processing Unit (CPU): The CPU of the 8051 is an 8-bit

processor thatcan execute a set of 111 instructions. It has a four-stage


pipeline architecture andoperates at a clockfrequencyof typically12
MHz.
2. Registers:The8051has atotalof128 bytesofRAM,divided
intofourregisterbanks (R0-R7) of 8 registers each. Some of these
registers are used for general-purposedata storage, while others
havespecificfunctions.
3. ProgramMemory (ROM):The8051hasaprogram

memory(ROM)thatcanbeeither 4 KB or 8 KB, depending on the


specific variant. The program memoryholdsthe user's programand is
typicallynon-volatile.
4. Data Memory (RAM): In addition to the registers, the 8051 has

128 bytes ofRAM,which is used fordatastorageduringprogram


execution.
5. Input/Output Ports: The 8051 has four parallel I/O ports (P0-P3)
that can beconfiguredasinputor output.Theseports
areusedforinterfacingwith externaldevices.
6. SerialCommunication

Control:The8051includesaUART(UniversalAsynchronousRe
ceiver/Transmitter)forserialcommunication.
7. Timers/Counters: The 8051 has two 16-bit timers/counters that can

be used forvarioustimingand countingapplications.


8. Interrupt System: The 8051 supports both external and internal

interrupts,allowing the microcontroller to respond to external events


or specific conditionsduringprogram execution.
8051 Pin Diagram:
The8051microcontroller has40pins, andthe pindiagramis
typicallyrepresentedasfollows:

MemoryOrganization:
The memory organization of the 8051 includes Program Memory (ROM)
and DataMemory(RAM).TheROM storestheuser'sprogram
code,andRAMis usedfordatastorageduringprogram execution.
Program Memory(ROM):4 KBor 8KB
DataMemory(RAM):128bytes

BasicInstructions:
The8051microcontroller supportsaset of111instructions,
includingarithmetic, logic,controltransfer,and data transfer
instructions.Somebasic instructionsinclude:
MOV:Movedatafrom oneregister/memorylocation to another.
ADD:Addtwo numbers.
SUB:Subtractonenumberfromanother.
JMP:Jump toaspecifiedaddress.
CALL/RET:Call asubroutine orreturnfrom asubroutine.
INC/DEC: Incrementordecrementaregister/memorylocation.
These are just a few examples, and the complete set of instructions
provides a versatilerange of operations for programming the 8051
microcontroller. Assembler language iscommonlyused for programmingthe
8051,and thereareseveral development toolsandcompilersavailableforthis
purpose.

Conclusion:
The8051 microcontroller is awidelyused and versatile8-bit microcontroller
with awell-defined architecture that has been a cornerstone in the field of
embedded systems fordecades.
Itspopularitycanbeattributedtoitsrobustfeatures,simplicity,andreliability.
Lab # 2:
Keilu Visionper form arithmetic operation
For 8051 microcontroller programming and interfacing.

Objectives:
TheobjectiveofthislabexperimentistoutilizeKeiluVision,anintegrated
developmentenvironment (IDE), to program the 8051 microcontroller. The
focus is on writing codethat will run on the 8051, and KeiluVision serves as
the platform for code development.Additionally, the experiment involves
simulating the behavior of the programmed 8051microcontroller when
interfaced with various components. To achieve this simulation,Proteus
software is employed, providing a virtual environment to test and observe
howthe8051 interacts with connected peripherals or devices.

UseofSoftware’s:
KeiluVision

Procedure:
1) KeiluVisionSetup:
ProjectCreation:Initiatethe processbycreatinganewproject
withinKeiluVision,specificallytailoredforthe8051 microcontroller.
Programming:DevelopaprogramusingKeiluVisionthatestablishesinteractio
nswithvarious components, such as LEDs for creating blinking patterns or
reading input frompush buttons.
Compile and Generate Hex File: After writing the code, proceed to
compile it,generatinga
HEXfilethatencapsulatesthecompiledprogram.ThisHEX
filewillbeutilizedin thesubsequentProteus simulation

Arithmetic Operation
An arithmetic operation is a combination of operands and an arithmetic
operator. Arithmetic is a fundamental branch of mathematics that includes the
operations of numbers. The four basic arithmetic operations in mathematics
are:
Addition: Finding the sum
Subtraction: Finding the difference
Multiplication: Finding the product
Division: Finding the quotient

Addition

Output

Subtraction

Multiplication
Output

Divison

Increment Operator

Output
Decrement Operator

Conclusion:
Utilizing KeiluVision for programming the 8051 microcontroller and
simulating itsbehavior in Proteus offers a holistic grasp of embedded
systems. This method allows forthorough validation of code functionality
and real-time interaction with externalcomponents in a virtual environment
before transitioning to actual hardwareimplementation.
Lab # 3:
Perform Logical Operation

Logical Operation
An operator used to compare logical expressions that returns a result of true
or false. Examples of logical operators include less than (<), greater than (>),
equal to (=), and not equal to (<>).
Logical operators are generally used for combining two or more relational
statements. They return Boolean values. The logical operators are used
primarily in the expression evaluation to make a decision. These operators
allow the evaluation and manipulation of specific bits within the integer.

The types of Logical operators with their description are tabulated as follows

Logical Operator

Or operator
Truth table

1. Input/Output

2. Input/Output

AND Operator

Truth table
1. Input/Output

2. Input/Output

Not Operater

Truth table
1. Input/Output

2. Input/Output

XOR GATE Operater

Truth table
1. Input/Output

2. Input/Output
Lab # 4:
I/O port programming in assembly language, including input and output
operations, and interfacing with switches andleds.

Objective:
In this our objective that to make a code for an assembly language to
interfacing the ledwiththehelp of switchesand show it in proteus.

Useofsoftware:
KeiluVision
Proteus

Code:

Task 1:
Lab # 5:
I/O port programming in assembly language, including input and output
operations, and interfacing with switches andleds.

Objective:
In this our objective that to make a code for an assembly language to
interfacing the led with the help of switches and show it in proteus.

Useofsoftware:
KeiluVision

Code:
ORG 0000h

mov A,#0x001
Main:
mov P2,A
LCALL delay

RR A
LCALL delay
sjmp Main
delay:
mov r0,#0x060
here: mov R1, #0x0ff
here1: mov R2,#0x0ff
here2: DJNZ R2, here2
DJNZ R1, here1
DJNZ r0,here

RET
END
Figure 1:

Figure 2:
Conclusion:
Inthis labwelearnabouthow to docodeon assemblylanguageand
interfacingwithswitchesandLED’s.

You might also like