SlideShare a Scribd company logo
1 of 37
Introduction to Microcontroller
 Definition
 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.
 How Does it Works?
 Microcontrollers are used in a wide array of systems and devices. Devices often
utilize multiple microcontrollers that work together within the device to handle
their respective tasks.
 For Example
 a car might have many microcontrollers that control various individual systems
within, such as the anti-lock braking system, traction control, fuel injection or
suspension control. All the microcontrollers communicate with each other to
inform the correct actions.
Microcontrollers and Embedded
Processors
 General-purpose microprocessors
contains
 No RAM
 No ROM
 No I/O ports
 Microcontroller has
 CPU (microprocessor)
 RAM ROM
 I/O ports
 Timer
 ADC and other peripherals
Continue…
 General-purpose microprocessors
i. Must add RAM, ROM, I/O ports, and timers externally to make them functional
ii. Make the system bulkier and much more expensive
iii. Have the advantage of versatility on the amount of RAM, ROM, and I/O ports
 Microcontroller
i. The fixed amount of on-chip ROM, RAM, and number of I/O ports makes them ideal for many
applications in which cost and space are critical
ii. In many applications, the space it takes, the power it consumes, and the price per unit are
much more critical considerations than the computing power
Continue…
 There is only one application software that is typically burned into ROM
 It has RAM memory and an operating system that loads a variety of
applications into RAM and lets the CPU run them
 A PC contains or is connected to various embedded products
 Each one peripheral has a microcontroller inside it that performs only one task
Applications
 Home
Appliances, intercom, telephones, security
systems,
garage door openers, answering machines, fax
machines, home computers, TVs, cable TV
tuner,
 Office
Telephones, computers, security systems, fax
machines, microwave, copier, laser printer, color
printer, paging
 Auto
Trip computer, engine control, air bag, ABS,
instrumentation, security system, transmission
control
Continue…
 One of the most critical needs of an embedded system is to decrease power
consumption and space
 In high-performance embedded processors, the trend is to integrate more functions
on the CPU chip and let designer decide which features he/she wants to use
 In many cases using x86 PCs for the high-end embedded applications
 Saves money and shortens development time
 A vast library of software already written Windows is a widely used and well
understood platform
Inside the Computer
 Important Terminologies
 The unit of data size
 Bit : a binary digit that can have the value
0 or 1
 Byte : 8 bits
 Nibble : half of a bye, or 4 bits
 Word : two bytes, or 16 bits
 The terms used to describe amounts of
memory in IBM PCs and compatibles
 Kilobyte (K): 210 bytes
 Megabyte (M) : 220 bytes, over 1 million
 Gigabyte (G) : 230 bytes, over 1 billion
 Terabyte (T) : 240 bytes, over 1 trillion
Continue…
 Internal Organization of Computer
 CPU (Central Processing Unit)
 Execute information stored in memory
 I/O (Input/output) devices
Provide a means of communicating with
CPU
 Memory
 RAM (Random Access Memory) – temporary storage of programs that computer
is running
 The data is lost when computer is off ROM (Read Only Memory) – contains
programs and information essential to operation of the computer
 The information cannot be changed by use, and is not lost when power is off
 – It is called nonvolatile memory
Internal Organization of Computer
Continue…
Continue…
The CPU is connected to memory and
I/O through strips of wire called a bus
i. Carries information from place to place
ii. Address bus
iii. Data bus
iv. Control bus
Continue…
 Address bus
i. For a device (memory or I/O) to be recognized by the CPU, it must be assigned an address
ii. The address assigned to a given device must
be unique
iii. The CPU puts the address on the address bus,
and the decoding circuitry finds the device
 Data bus
i. The CPU either gets data from the device or sends data to it
 Control bus
i. Provides read or write signals to the device to indicate if the CPU is asking for information or
sending it information
More About the Data Bus
 The more data buses available, the
better the CPU
i. Think of data buses as highway lanes
 More data buses mean a more
expensive CPU and computer
i. The average size of data buses in CPUs varies between 8 and 64
 Data buses are bidirectional
i. To receive or send data
 The processing power of a computer is related to the size of its buses
Inside the
Computer
 CPU’S Relation to ROM & RAM
 For the CPU to process information,
the data must be stored in RAM or
ROM, which are referred to as primary
memory
 ROM provides information that is fixed
and permanent
i. Tables or initialization program
 RAM stores information that is not
permanent and can change with time
i. Various versions of OS and application
packages
ii. CPU gets information to be processed first
form RAM (or ROM)
iii. if it is not there, then seeks it from a
mass storage device, called secondary
memory, and
transfers the information to RAM
Continue…
 Registers
i. The CPU uses registers to store information temporarily
ii. Values to be processed
iii. Address of value to be fetched from memory
iv. In general, the more and bigger the registers, the better the CPU
v. Registers can be 8-, 16-, 32-, or 64-bit
vi. The disadvantage of more and bigger registers is the increased cost of such a CPU
Inside the CPU’S
 ALU (arithmetic/logic unit)
i. Performs arithmetic functions such as add, subtract, multiply, and divide, and logic
functions such as AND, OR, and NOT
 Program counter
i. Points to the address of the next instruction to be executed
ii. As each instruction is executed, the program counter is incremented to point to the
address of the next instruction to be executed
 Instruction decoder
i. Interprets the instruction fetched into the CPU
ii. A CPU capable of understanding more instructions requires more transistors to design
Choosing a
Microcontrollers
 8-bit microcontrollers
i. Motorola’s 6811
ii. Intel’s 8051
iii. Zilog’s Z8
iv. Microchip’s PIC
 There are also 16-bit and 32-bit
microcontrollers made by various
chip makers
Criteria for Choosing Microcontroller
 Meeting the computing needs of the task at hand efficiently and cost effectively
i. Speed
ii. Packaging
iii. Power consumption
iv. The amount of RAM and ROM on chip
v. The number of I/O pins and the timer on chip
 How easy to upgrade to higher performance or lower power-consumption versions
 Cost per unit
 The 8051 family has the largest number of diversified (multiple source) suppliers
i. Intel (original)
ii. Atmel
iii. Philips/Signetics
Overview of 8051 Family
 Intel introduced 8051, referred as MCS- 51, in 1981
i. The 8051 is an 8-bit processor
ii. The CPU can work on only 8 bits of data at a time
 The 8051 had
i. 128 bytes of RAM
ii. 4K bytes of on-chip ROM
iii. Two timers
iv. One serial port
v. Four I/O ports, each 8 bits wide
vi. 6 interrupt sources
Continue…
 Feature 8051 8052 8031
ROM (on-chip program 4K 8K 0K
space in bytes)
RAM (bytes) 128 256 128
Timers 2 3 2
I/O pins 32 32 32
Serial port 1 1 1
Interrupt sources 6 8 6
Inside the 8051
 Registers
 Register are used to store information
temporarily, while the information
could be
a byte of data to be processed, or
an address pointing to the data to be
fetched
 The vast majority of 8051 register are
8-bit registers
There is only one data type, 8 bits
 The 8 bits of a register are shown from
MSB D7 to the LSB D0
With an 8-bit data type, any data larger
than 8 bits must be broken into 8-bit
chunks before it is processed
Continue…
8051 Assembly Language Programming
Register are used to store
information temporarily, while
the information could be
a byte of data to be processed, or an
address pointing to the data to be
fetched
The vast majority of 8051
register are 8-bit registers
There is only one data type, 8 bits
The 8 bits of a register are
shown from MSB D7 to the LSB
D0
With an 8-bit data type, any data larger
than 8 bits must be broken into 8-bit
chunks before it is processed
MOV Instruction
The instruction tells the CPU to move
(in reality, COPY) the source operand
to the destination operand
Continue…
 If values 0 to F moved into an 8-bit register, the rest of
the bits are assumed all zeros
 “MOV A, #5”, the result will be A=05; i.e., A= 00000101
in binary
 Moving a value that is too large into a register will cause
an error
 MOV A, #7F2H ; ILLEGAL: 7F2H>8 bits (FFH)
ADD Instruction
 The ADD instruction tells the CPU
to add the source byte to register
A and put the result in register A
Assembling and Running an 8051
Program
1. First we use an editor to type a program , many excellent editors or word processors are available that can be used to create and/or edit the
program
i. Notice that the editor must be able to produce an ASCII file
ii. For many assemblers, the file names follow the usual DOS conventions, but the source file has the extension “asm“ or “src”,
depending on which assembly you are using
2. The “asm” source file containing the program code created in step 1 is fed to an 8051 assembler
i. The assembler converts the instructions into machine code
ii. The assembler will produce an object file and a list file
iii. The extension for the object file is “obj” while the extension for the list file is “lst”
Continue…
3. Assembler require a third step called linking
 The linker program takes one or more object code files and produce an absolute object file
with the extension “abs”
 This abs file is used by 8051 trainers that have a monitor program
4. Next the “abs” file is fed into a program called “OH” (object to hex converter) which creates a file
with extension “hex” that is ready to burn into ROM
 This program comes with all 8051 assemblers
 Recent Windows-based assemblers combine step 2 through 4 into one step
Steps to Create a Program
8051 Data Types and
Directives
 Data Types
 8051 microcontroller has only one data type - 8 bits
 The size of each register is also 8 bits
 It is the job of the programmer to break down data larger
than 8 bits (00 to FFH,or 0 to 255 in decimal)
 The data types can be positive or negative
Continue…
 Assembler Directives
 The DB directive is the most
widely used data directive in the
assembler
 It is used to define the 8-bit data
 When DB is used to define data,
the numbers can be in decimal,
binary, hex, ASCII formats
Assembler Directives Continue…
 ORG (origin)
i. The ORG directive is used to indicate the beginning of the address
ii. The number that comes after ORG can be either in hex and decimal
iii. If the number is not followed by H, it is decimal and the assembler will convert it to hex
 END
i. This indicates to the assembler the end of the source (asm) file
ii. The END directive is the last line of an 8051 program
iii. Mean that in the code anything after the END directive is ignored by the assembler
Continue…
 EQU (equate)
i. This is used to define a constant without occupying a memory location
ii. The EQU directive does not set aside storage for a data item but associates a
constant value with a data label
iii. When the label appears in the program, its constant value will be substituted
for the label
iv. By the use of EQU, one can change it once and the assembler will change all
of its occurrences
Flag Bits and PSW Register
 PSW (Program status Word)
i. The program status word (PSW) register, also referred to as the flag register, is an 8 bit
register
ii. Only 6 bits are used
iii. These four are CY (carry), AC (auxiliary carry), P(parity), and OV (overflow)
– They are called conditional flags, meaning that they indicate some conditions that
resulted after an instruction was executed
iv. The PSW3 and PSW4 are designed as RS0 and RS1, and are used to change the bank
v. The two unused bits are user-definable
Continue…
Continue…
Flag Bits and PSW Register
 ADD INSTRUCTION AND PSW
 The flag bits affected by the ADD
instruction are CY, P, AC, and OV
Continue…

More Related Content

Similar to lecture 2 coal assembly language lecture

Microprocessors evolution introduction to microprocessor
Microprocessors  evolution introduction to microprocessorMicroprocessors  evolution introduction to microprocessor
Microprocessors evolution introduction to microprocessorVijay Kumar
 
Bindura university of science education
Bindura university of science educationBindura university of science education
Bindura university of science educationInnocent Tauzeni
 
4CS3-MPI-Unit-1.pptx
4CS3-MPI-Unit-1.pptx4CS3-MPI-Unit-1.pptx
4CS3-MPI-Unit-1.pptxLofi19
 
Introduction to 8085 Microprocessor.pptx
Introduction to 8085 Microprocessor.pptxIntroduction to 8085 Microprocessor.pptx
Introduction to 8085 Microprocessor.pptxVishalGaur54
 
Micro controller
Micro controllerMicro controller
Micro controllerDevi Prasad
 
8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptx
8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptx8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptx
8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptxsruti009988
 
Microprocessor note
Microprocessor noteMicroprocessor note
Microprocessor notealokbhatta
 
Ch # 04 computer hardware
Ch # 04 computer hardware Ch # 04 computer hardware
Ch # 04 computer hardware MuhammadRobeel3
 
Computer capsule ibps_po_2014
Computer capsule ibps_po_2014Computer capsule ibps_po_2014
Computer capsule ibps_po_2014Lucky Saini
 
Embeded system by Mitesh Kumar
Embeded system by Mitesh KumarEmbeded system by Mitesh Kumar
Embeded system by Mitesh KumarMitesh Kumar
 
Origin of Microprocessor and Classification of Microprocessor
Origin of Microprocessor and  Classification of Microprocessor Origin of Microprocessor and  Classification of Microprocessor
Origin of Microprocessor and Classification of Microprocessor Vijay Kumar
 

Similar to lecture 2 coal assembly language lecture (20)

Final ict
Final ictFinal ict
Final ict
 
Microprocessors evolution introduction to microprocessor
Microprocessors  evolution introduction to microprocessorMicroprocessors  evolution introduction to microprocessor
Microprocessors evolution introduction to microprocessor
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Bindura university of science education
Bindura university of science educationBindura university of science education
Bindura university of science education
 
4CS3-MPI-Unit-1.pptx
4CS3-MPI-Unit-1.pptx4CS3-MPI-Unit-1.pptx
4CS3-MPI-Unit-1.pptx
 
Introduction to 8085 Microprocessor.pptx
Introduction to 8085 Microprocessor.pptxIntroduction to 8085 Microprocessor.pptx
Introduction to 8085 Microprocessor.pptx
 
Micro controller
Micro controllerMicro controller
Micro controller
 
Micro processor
Micro processorMicro processor
Micro processor
 
8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptx
8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptx8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptx
8085 Microprocessor - Ramesh Gaonkar.pdf-27 (1).pptx
 
Microprocessor note
Microprocessor noteMicroprocessor note
Microprocessor note
 
Ppt embedded
Ppt embeddedPpt embedded
Ppt embedded
 
EEE226a.ppt
EEE226a.pptEEE226a.ppt
EEE226a.ppt
 
Ch # 04 computer hardware
Ch # 04 computer hardware Ch # 04 computer hardware
Ch # 04 computer hardware
 
Computer capsule ibps_po_2014
Computer capsule ibps_po_2014Computer capsule ibps_po_2014
Computer capsule ibps_po_2014
 
Embeded system by Mitesh Kumar
Embeded system by Mitesh KumarEmbeded system by Mitesh Kumar
Embeded system by Mitesh Kumar
 
Origin of Microprocessor and Classification of Microprocessor
Origin of Microprocessor and  Classification of Microprocessor Origin of Microprocessor and  Classification of Microprocessor
Origin of Microprocessor and Classification of Microprocessor
 
Lecture
LectureLecture
Lecture
 
Lecture-It104
Lecture-It104Lecture-It104
Lecture-It104
 
Lecture
LectureLecture
Lecture
 
IT Lecture
IT LectureIT Lecture
IT Lecture
 

Recently uploaded

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdfSuman Jyoti
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesPrabhanshu Chaturvedi
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 

Recently uploaded (20)

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 

lecture 2 coal assembly language lecture

  • 1. Introduction to Microcontroller  Definition  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.  How Does it Works?  Microcontrollers are used in a wide array of systems and devices. Devices often utilize multiple microcontrollers that work together within the device to handle their respective tasks.  For Example  a car might have many microcontrollers that control various individual systems within, such as the anti-lock braking system, traction control, fuel injection or suspension control. All the microcontrollers communicate with each other to inform the correct actions.
  • 2. Microcontrollers and Embedded Processors  General-purpose microprocessors contains  No RAM  No ROM  No I/O ports  Microcontroller has  CPU (microprocessor)  RAM ROM  I/O ports  Timer  ADC and other peripherals
  • 3. Continue…  General-purpose microprocessors i. Must add RAM, ROM, I/O ports, and timers externally to make them functional ii. Make the system bulkier and much more expensive iii. Have the advantage of versatility on the amount of RAM, ROM, and I/O ports  Microcontroller i. The fixed amount of on-chip ROM, RAM, and number of I/O ports makes them ideal for many applications in which cost and space are critical ii. In many applications, the space it takes, the power it consumes, and the price per unit are much more critical considerations than the computing power
  • 4. Continue…  There is only one application software that is typically burned into ROM  It has RAM memory and an operating system that loads a variety of applications into RAM and lets the CPU run them  A PC contains or is connected to various embedded products  Each one peripheral has a microcontroller inside it that performs only one task
  • 5. Applications  Home Appliances, intercom, telephones, security systems, garage door openers, answering machines, fax machines, home computers, TVs, cable TV tuner,  Office Telephones, computers, security systems, fax machines, microwave, copier, laser printer, color printer, paging  Auto Trip computer, engine control, air bag, ABS, instrumentation, security system, transmission control
  • 6. Continue…  One of the most critical needs of an embedded system is to decrease power consumption and space  In high-performance embedded processors, the trend is to integrate more functions on the CPU chip and let designer decide which features he/she wants to use  In many cases using x86 PCs for the high-end embedded applications  Saves money and shortens development time  A vast library of software already written Windows is a widely used and well understood platform
  • 7. Inside the Computer  Important Terminologies  The unit of data size  Bit : a binary digit that can have the value 0 or 1  Byte : 8 bits  Nibble : half of a bye, or 4 bits  Word : two bytes, or 16 bits  The terms used to describe amounts of memory in IBM PCs and compatibles  Kilobyte (K): 210 bytes  Megabyte (M) : 220 bytes, over 1 million  Gigabyte (G) : 230 bytes, over 1 billion  Terabyte (T) : 240 bytes, over 1 trillion
  • 8. Continue…  Internal Organization of Computer  CPU (Central Processing Unit)  Execute information stored in memory  I/O (Input/output) devices Provide a means of communicating with CPU  Memory  RAM (Random Access Memory) – temporary storage of programs that computer is running  The data is lost when computer is off ROM (Read Only Memory) – contains programs and information essential to operation of the computer  The information cannot be changed by use, and is not lost when power is off  – It is called nonvolatile memory
  • 9. Internal Organization of Computer Continue…
  • 10. Continue… The CPU is connected to memory and I/O through strips of wire called a bus i. Carries information from place to place ii. Address bus iii. Data bus iv. Control bus
  • 11. Continue…  Address bus i. For a device (memory or I/O) to be recognized by the CPU, it must be assigned an address ii. The address assigned to a given device must be unique iii. The CPU puts the address on the address bus, and the decoding circuitry finds the device  Data bus i. The CPU either gets data from the device or sends data to it  Control bus i. Provides read or write signals to the device to indicate if the CPU is asking for information or sending it information
  • 12. More About the Data Bus  The more data buses available, the better the CPU i. Think of data buses as highway lanes  More data buses mean a more expensive CPU and computer i. The average size of data buses in CPUs varies between 8 and 64  Data buses are bidirectional i. To receive or send data  The processing power of a computer is related to the size of its buses
  • 13. Inside the Computer  CPU’S Relation to ROM & RAM  For the CPU to process information, the data must be stored in RAM or ROM, which are referred to as primary memory  ROM provides information that is fixed and permanent i. Tables or initialization program  RAM stores information that is not permanent and can change with time i. Various versions of OS and application packages ii. CPU gets information to be processed first form RAM (or ROM) iii. if it is not there, then seeks it from a mass storage device, called secondary memory, and transfers the information to RAM
  • 14. Continue…  Registers i. The CPU uses registers to store information temporarily ii. Values to be processed iii. Address of value to be fetched from memory iv. In general, the more and bigger the registers, the better the CPU v. Registers can be 8-, 16-, 32-, or 64-bit vi. The disadvantage of more and bigger registers is the increased cost of such a CPU
  • 15. Inside the CPU’S  ALU (arithmetic/logic unit) i. Performs arithmetic functions such as add, subtract, multiply, and divide, and logic functions such as AND, OR, and NOT  Program counter i. Points to the address of the next instruction to be executed ii. As each instruction is executed, the program counter is incremented to point to the address of the next instruction to be executed  Instruction decoder i. Interprets the instruction fetched into the CPU ii. A CPU capable of understanding more instructions requires more transistors to design
  • 16. Choosing a Microcontrollers  8-bit microcontrollers i. Motorola’s 6811 ii. Intel’s 8051 iii. Zilog’s Z8 iv. Microchip’s PIC  There are also 16-bit and 32-bit microcontrollers made by various chip makers
  • 17. Criteria for Choosing Microcontroller  Meeting the computing needs of the task at hand efficiently and cost effectively i. Speed ii. Packaging iii. Power consumption iv. The amount of RAM and ROM on chip v. The number of I/O pins and the timer on chip  How easy to upgrade to higher performance or lower power-consumption versions  Cost per unit  The 8051 family has the largest number of diversified (multiple source) suppliers i. Intel (original) ii. Atmel iii. Philips/Signetics
  • 18. Overview of 8051 Family  Intel introduced 8051, referred as MCS- 51, in 1981 i. The 8051 is an 8-bit processor ii. The CPU can work on only 8 bits of data at a time  The 8051 had i. 128 bytes of RAM ii. 4K bytes of on-chip ROM iii. Two timers iv. One serial port v. Four I/O ports, each 8 bits wide vi. 6 interrupt sources
  • 19. Continue…  Feature 8051 8052 8031 ROM (on-chip program 4K 8K 0K space in bytes) RAM (bytes) 128 256 128 Timers 2 3 2 I/O pins 32 32 32 Serial port 1 1 1 Interrupt sources 6 8 6
  • 20. Inside the 8051  Registers  Register are used to store information temporarily, while the information could be a byte of data to be processed, or an address pointing to the data to be fetched  The vast majority of 8051 register are 8-bit registers There is only one data type, 8 bits  The 8 bits of a register are shown from MSB D7 to the LSB D0 With an 8-bit data type, any data larger than 8 bits must be broken into 8-bit chunks before it is processed
  • 22. 8051 Assembly Language Programming Register are used to store information temporarily, while the information could be a byte of data to be processed, or an address pointing to the data to be fetched The vast majority of 8051 register are 8-bit registers There is only one data type, 8 bits The 8 bits of a register are shown from MSB D7 to the LSB D0 With an 8-bit data type, any data larger than 8 bits must be broken into 8-bit chunks before it is processed
  • 23. MOV Instruction The instruction tells the CPU to move (in reality, COPY) the source operand to the destination operand
  • 24. Continue…  If values 0 to F moved into an 8-bit register, the rest of the bits are assumed all zeros  “MOV A, #5”, the result will be A=05; i.e., A= 00000101 in binary  Moving a value that is too large into a register will cause an error  MOV A, #7F2H ; ILLEGAL: 7F2H>8 bits (FFH)
  • 25. ADD Instruction  The ADD instruction tells the CPU to add the source byte to register A and put the result in register A
  • 26. Assembling and Running an 8051 Program 1. First we use an editor to type a program , many excellent editors or word processors are available that can be used to create and/or edit the program i. Notice that the editor must be able to produce an ASCII file ii. For many assemblers, the file names follow the usual DOS conventions, but the source file has the extension “asm“ or “src”, depending on which assembly you are using 2. The “asm” source file containing the program code created in step 1 is fed to an 8051 assembler i. The assembler converts the instructions into machine code ii. The assembler will produce an object file and a list file iii. The extension for the object file is “obj” while the extension for the list file is “lst”
  • 27. Continue… 3. Assembler require a third step called linking  The linker program takes one or more object code files and produce an absolute object file with the extension “abs”  This abs file is used by 8051 trainers that have a monitor program 4. Next the “abs” file is fed into a program called “OH” (object to hex converter) which creates a file with extension “hex” that is ready to burn into ROM  This program comes with all 8051 assemblers  Recent Windows-based assemblers combine step 2 through 4 into one step
  • 28. Steps to Create a Program
  • 29. 8051 Data Types and Directives  Data Types  8051 microcontroller has only one data type - 8 bits  The size of each register is also 8 bits  It is the job of the programmer to break down data larger than 8 bits (00 to FFH,or 0 to 255 in decimal)  The data types can be positive or negative
  • 30. Continue…  Assembler Directives  The DB directive is the most widely used data directive in the assembler  It is used to define the 8-bit data  When DB is used to define data, the numbers can be in decimal, binary, hex, ASCII formats
  • 31. Assembler Directives Continue…  ORG (origin) i. The ORG directive is used to indicate the beginning of the address ii. The number that comes after ORG can be either in hex and decimal iii. If the number is not followed by H, it is decimal and the assembler will convert it to hex  END i. This indicates to the assembler the end of the source (asm) file ii. The END directive is the last line of an 8051 program iii. Mean that in the code anything after the END directive is ignored by the assembler
  • 32. Continue…  EQU (equate) i. This is used to define a constant without occupying a memory location ii. The EQU directive does not set aside storage for a data item but associates a constant value with a data label iii. When the label appears in the program, its constant value will be substituted for the label iv. By the use of EQU, one can change it once and the assembler will change all of its occurrences
  • 33. Flag Bits and PSW Register  PSW (Program status Word) i. The program status word (PSW) register, also referred to as the flag register, is an 8 bit register ii. Only 6 bits are used iii. These four are CY (carry), AC (auxiliary carry), P(parity), and OV (overflow) – They are called conditional flags, meaning that they indicate some conditions that resulted after an instruction was executed iv. The PSW3 and PSW4 are designed as RS0 and RS1, and are used to change the bank v. The two unused bits are user-definable
  • 36. Flag Bits and PSW Register  ADD INSTRUCTION AND PSW  The flag bits affected by the ADD instruction are CY, P, AC, and OV

Editor's Notes

  1. Definition: A microcontroller is a small electronic chip that's like the brain of a specialized system. It's designed to handle specific tasks within that system. Components: Inside a microcontroller, there's a tiny processor (like the brain), memory (for storing information), and input/output peripherals (for connecting to other parts of the system). How it works: When a microcontroller is in action, it follows a set of instructions to perform its task. These instructions tell it what to do with the information it receives and how to send out responses. Example - Car: Let's take the example of a car. A car can have many microcontrollers inside, each responsible for managing different functions like brakes, fuel injection, or suspension. These microcontrollers talk to each other to coordinate their actions, making sure everything in the car works smoothly and safely. For instance, if the anti-lock braking system senses a wheel locking up, it communicates with other microcontrollers to adjust the braking pressure and keep the car under control. In simpler terms, microcontrollers are like small computer brains that handle specific tasks in devices like cars, making sure everything runs smoothly by talking to each other and coordinating their actions.
  2. Fixed resources: A microcontroller has a set amount of built-in memory (ROM and RAM) and a specific number of input/output ports (for connecting to other devices). These resources cannot be changed or upgraded. Cost and space considerations: Microcontrollers are great for situations where keeping costs low and saving space are really important. Because they have everything integrated into one chip, they're often more affordable and take up less room compared to using separate components. Power consumption: Microcontrollers are designed to use minimal power. This is important because in many devices, especially portable ones like smartphones or battery-operated gadgets, conserving battery life is crucial. Microcontrollers help keep power usage low. Price, space, and power over computing power: When choosing a microcontroller, factors like how much it costs, how much space it takes up, and how much power it uses are often more important than how powerful it is in terms of processing speed or capabilities. This means that even if a microcontroller isn't the fastest or most advanced, it can still be the best choice for certain applications because it meets these critical requirements effectively.
  3. Single application software: Microcontrollers typically have one set of software permanently stored in ROM. This software controls how the microcontroller operates. RAM and operating system: Microcontrollers have RAM for temporary data storage, and they can run different applications loaded into RAM by a small operating system. Embedded products in PCs: Many devices connected to or inside a computer, like peripherals, contain microcontrollers. Each microcontroller inside these devices is responsible for performing a single specific task. In simple terms, general-purpose microprocessors need extra parts to work, making them bigger and pricier. Microcontrollers, on the other hand, have everything they need built into one chip, making them ideal for space-saving and cost-effective solutions. They're often used in devices where space, power usage, and cost are more important than raw computing power. In simple terms, microcontrollers usually have one specific set of instructions stored in their memory that tells them how to do their job. This set of instructions is like a rulebook that the microcontroller follows all the time. It's stored in a part of the microcontroller called ROM, and it's always there, kind of like a computer program that's permanently built into the microcontroller. These instructions determine exactly what the microcontroller does and how it does it, governing its behavior and making it perform its intended function. For example, let's say we have a thermostat in a smart home system. The microcontroller inside the thermostat has its instructions (software) stored in ROM, telling it how to read the temperature, compare it to the desired temperature, and control the heating or cooling system accordingly. These instructions remain unchanged, just like the thermostat's behavior stays consistent. So, whenever you adjust the temperature on the thermostat, the microcontroller follows its predefined instructions stored in ROM to make sure your home stays at the right temperature.
  4. Embedded System: Definition: An embedded system is a combination of hardware and software specifically designed to perform a dedicated function within a larger system. Example: A washing machine. It has a microcontroller or microprocessor embedded inside it to control the various functions like water intake, washing cycle, and spinning. The software programmed into the embedded system ensures that it performs these tasks efficiently without needing human intervention. Microcontroller: Definition: A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Example: A remote-controlled toy car. The microcontroller inside the toy car interprets signals from the remote control and controls the motors to make the car move forward, backward, turn left, or turn right. It has all the necessary components like memory and input/output ports built into a single chip. Microprocessor: Definition: A microprocessor is the central processing unit (CPU) of a computer, which performs arithmetic and logic operations. It requires external components like memory, input/output devices, and support chips to function as a complete system. Example: A personal computer (PC). The microprocessor, like an Intel Core or AMD Ryzen chip, is the brain of the computer. It processes instructions from software and performs tasks like running programs, browsing the internet, and playing games. However, to make a complete PC system, you need additional components like RAM, storage drives, a motherboard, and peripherals such as a monitor, keyboard, and mouse.
  5. RAM (Random Access Memory): Definition: RAM is a type of computer memory that is used to temporarily store data that the CPU (central processing unit) needs to access quickly while performing tasks. It is volatile memory, meaning that its contents are lost when the power is turned off. Example: Imagine RAM like a workspace on a desk. When you're working on a project, you might spread out papers and tools on your desk for easy access. RAM works similarly for a computer. For instance, when you open a program like a web browser, the computer loads data from the browser into RAM so that it can quickly access and manipulate this data while you're using the program. However, when you turn off the computer, all the data stored in RAM is erased, just like clearing off your desk at the end of the day. ROM (Read-Only Memory): Definition: ROM is a type of computer memory that stores data permanently and cannot be modified or erased under normal conditions. It holds instructions or data that are essential for the operation of the computer or electronic device. Example: Think of ROM like a factory manual that comes with a piece of equipment. Once printed, the information in the manual cannot be changed. Similarly, ROM contains permanent instructions or data that the computer needs to start up and perform basic functions, such as BIOS (Basic Input/Output System) or firmware. For example, when you turn on your computer, the BIOS stored in ROM initializes the hardware components and starts the operating system loading process. Unlike RAM, ROM retains its data even when the power is turned off because it's non-volatile.
  6. A computer has a system bus, possibly a backside bus, and an expansion bus. A system bus connects the processor with main memory Backside bus connects the processor with cache An expansion bus allows the processor to communicate with peripheral devices System bus also known as front side bus