You are on page 1of 34

Microprocessors and

Microcontrollers
(EE-231)

Main Objectives

Introduction to Computing
Inside Computer
The 8051 Microcontrollers
Specifications and variants of 8051
microcontrollers

Converting Decimal to Binary


Divide the decimal number by 2 repeatedly while keeping
track of the remainders
Continue this process until the quotient becomes zero
Write the remainders in reverse order to obtain the binary
number

Alternate way
Know the weight of each bit in a binary Number and then
add them together to get its decimal equivalent

We can use this method to convert back

Binary to Hexadecimal Conv


Start from the right and group 4 bits at a time, replacing
each 4-bit binary number with its hex equivalent

To convert back simply do the reverse

Decimal to Hexadecimal Conv


Two way
1. Convert to binary first and then convert to hex
2. Convert directly to hex by repeated division, keeping track
of the remainders

Addition of Hex Numbers


Add digits from the least significant digit and if the result is
less than 16 then write the sum as it is
If it is greater than 16, subtract 16 from it and then write the
result and take carry 1 to the next digit.

Subtraction of Hex Numbers


If the second digit is greater than the first, borrow 16 from
the preceding digit and add it to current digit, then perform
the subtraction.
And then move to the next digit.

ASCII Code

1.
2.
3.

The American Standard Code for Information Interchange


The ASCII (pronounced ask-E) code
assigns binary patterns for
Numbers 0 to 9
All the letters of English alphabet, uppercase and lowercase
Many control codes and punctuation marks
The ASCII system uses 7 bits to represent each code

Terminology

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

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

Internal Organization of Computer

Internal Organization of Computer


The CPU is connected to memory and I/O through strips of
wire called a bus
Bus can be of 3ree types
Data
Address
Control

The Bus
Address bus
For a device (memory or I/O) to be recognized by the CPU, it
must be assigned an address
The address assigned to a given device must be unique
The CPU puts the address on the address bus, and the
decoding circuitry finds the device
Data bus
The CPU either gets data from the device or sends data to it
Control bus
Provides read or write signals to the device to indicate if the
CPU is asking for information or sending it information

The Bus
The more address buses available, the larger the number of
devices that can be addressed
The number of locations with which a CPU can communicate
is always equal to 2x, where x is the address lines, regardless
of the size of the data bus
For Ex. a CPU with 24 address lines and 16 data lines can
provide a total of 224 or 16M bytes of addressable memory
Each location can have a maximum of 1 byte of data, since all
general-purpose CPUs are byte addressable
The address bus is unidirectional

Inside CPU

Internal Working
ALU (arithmetic/logic unit)
Performs arithmetic functions such as add, subtract,
multiply, and divide, and logic functions such as AND, OR,
and NOT
Program counter
Points to the address of the next instruction to be executed
As each instruction is executed, the program counter is
incremented to point to the address of the next instruction
to be executed
Instruction decoder
Interprets the instruction fetched into the CPU

Internal Working
Example
A CPU has registers A, B, C, and D and it has an 8-bit data bus
and a 16-bit address bus. The CPU can access memory from
addresses 0000 to FFFFH. (Total number of addresses = ?)
Assume that the code for the CPU to move a value to register
A is B0H and the code for adding a value to register A is 04H
The action to be performed by the CPU is to put 21H into
register A, and then add to register A values 42H and 12H

Internal Working
Example

8051 Microcontrollers
Microcontroller VS General-purpose Microprocessors
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

All on a Single Chip

Microcontroller vs. General-Purpose


Microprocessor

Microcontroller vs. General-Purpose


Microprocessor
General-purpose microprocessors
Must add RAM, ROM, I/O ports, and timers externally to
make them functional
Make the system bulkier and much more expensive
Have the advantage of versatility on the amount of RAM,
ROM, and I/O ports
Microcontroller
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
In many applications, the space, the power it consumes, and
the price per unit are much more critical considerations than
the computing power

Embedded System
An embedded system uses a microprocessor (or
microcontroller) to do one task and one task only
&
There is only one application software that is typically
burned into ROM
A PC, in contrast with the embedded system, can be used for
any number of applications
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 (e.g., mouse, keyboard, printer all
have their own microcontroller inside them)

Embedded System Examples

Home
Appliances, intercom, telephones, security systems etc.
Office
Telephones, computers, security systems, fax machine etc.
Auto
Trip computer, engine control, air bag, security system etc.

Embedded Processors
Many manufactures of general-purpose microprocessors
have targeted their microprocessor for the high end of the
embedded market
When a company targets a general-purpose microprocessor
for the embedded market, it optimizes the processor used
for embedded systems
Very often the terms embedded processor and
microcontroller are used interchangeably

Embedded Processors
One of the most critical needs of an embedded system is to
decrease power consumption and space
But, 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 (Intel 8086, 80486, etc) 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

8-bit Microcontroller

8-bit microcontrollers
Motorolas 6811
Intels 8051
Zilogs Z8
Microchips PIC
There are also 16-bit and 32-bit microcontrollers made by
various chip makers

Choosing a Microcontroller
A microcontroller is chosen on following criteria
1. Meeting the computing needs of the task at hand efficiently
and cost effectively
2. Availability of software development tools, such as
compilers, assemblers, and debuggers
3. Wide availability and reliable sources of the microcontroller

Choosing a Microcontroller
Meeting the computing needs of the task at hand efficiently
and cost effectively
Speed
Packaging
Power consumption
The amount of RAM and ROM on chip
The number of I/O pins and the timer on
chip
How easy to upgrade
Cost per unit

Choosing a Microcontroller
Availability of software development tools, such as compilers,
assemblers, and debuggers
Are there tools available of for the debugging of the code.
Are efficient compilers and assemblers available.

Choosing a Microcontroller
Wide availability and reliable sources of the microcontroller
The 8051 family has the largest number of diversified
(multiple source) suppliers
Intel (original)
Atmel
Philips/Signetics
AMD
Infineon (formerly Siemens)
Matra
Dallas Semiconductor/Maxim

History of 8051
Intel introduced 8051, referred as MCS-51, in 1981
The 8051 is an 8-bit processor meaning the CPU can work on only
8 bits of data at a time
The 8051 had

128 bytes of RAM


4K bytes of on-chip ROM
Two timers
One serial port
Four I/O ports, each 8 bits wide
6 interrupt sources

The 8051 became widely popular after allowing other


manufactures to make and market any flavor of the 8051, but
remaining code-compatible

Inside 8051

8051 Family
The 8051 is a subset of the 8052
The 8031 is a ROM-less 8051
ROM is externally added at the expense of loosing two I/O ports

Various 8051 Microcontrollers

8751 microcontroller
UV-EPROM
PROM burner
UV-EPROM eraser takes 20 min to erase

AT89C51 from Atmel Corporation (We will use in LAB)

Flash (erase before write)


ROM burner that supports flash
A separate eraser is not needed

DS89C4x0 from Dallas Semiconductor, now part of Maxim Corp.


Flash
Comes with on-chip loader, loading program to on-chip flash via PC COM port

DS5000 from Dallas Semiconductor


NV-RAM (changed one byte at a time),
Also comes with on-chip loader

OTP (one-time-programmable) version of 8051


8051 family from Philips
ADC, DAC, extended I/O, and both OTP and flash

You might also like