Module 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

Module 1

Microprocessors and Microcontrollers


Introduction
• From past three decades, lot of improvement in technology.

• There is a lot of change in how we analyze and control the world around us.

• Parallel development in computer architecture and Integrated circuit fabrication.

• The 1st commercial Microprocessor or Computer on chip came into reality in 1971
i.e., 4 bit 4004.

• It was by small, unknown company by the name of Intel corporation.

• In late 1970’s many different types of microprocessor came into exist by more well
established semiconductor firms.
• A by-product of microprocessor development was the Microcontroller.

• The same fabrication techniques and programming concepts of general purpose


microprocessor yielded the Microcontroller

• Earlier microcontroller are nor well known to the general public or to the many technical
community.

• But , public aware that “something” is responsible for the new electronic gadgets and they
are are smart.

• Ex: Smart DVD, Video games, Microwaves, Elevators etc.,

• In competitive world, companies are also decided to develop a smart product using
Microchip.
Microprocessors and Microcontrollers

• Microprocessors and microcontrollers stem from the same basic idea, are made by
the same people. and are sold to the same types of system designers and
programmers.

• What is the difference between the two?


Microprocessors
• A microprocessor, is a general-purpose digital computer central
processing unit (CPU).
• Although popularly known as a "computer on a chip," the
microprocessor is in no sense a complete digital computer.
• Figure 1 shows a block diagram of a microprocessor CPU, which
contains an arithmetic and logic unit (ALU), a program counter (PC), a
stack pointer (SP), some working registers, a clock timing circuit, and
interrupt circuits.
Fig 1: Block diagram of Microprocessor
Add memory, usually read-only
program memory (ROM) and
random-access data memory
(RAM),
Complete

microcomputer Memory decoders, an oscillator

Number of input/output (I/O)


devices, such as parallel and
serial data ports.
Special-purpose devices, such as
interrupt handlers. or counters to
relieve the CPU from time-
consuming counting or timing
chores

Equipping with a mass storage device,


Small computer commonly a floppy disk drive

I/O peripherals, such as a


keyboard and a CRT display.

Then, small computer can be applied to a range of general-purpose software


applications
• The key term in describing the design of the microprocessor is "general-purpose."

• Based on the application demands, the hardware design of a microprocessor CPU


is arranged as a small or very large system.

• The internal CPU architecture, as well as the resultant machine level code that
operates that architecture, is comprehensive but as flexible as possible.

• The prime use of a microprocessor is to fetch data, perform extensive calculations


on that data, and store those calculations in a mass storage device or display the
results for human use.
• The programs used by the microprocessor are stored in the mass storage
device and loaded into RAM as the user directs.
• A few microprocessor programs are stored in ROM. The ROM-based
programs are primarily small fixed programs that operate peripherals
and other fixed devices that are connected to the system.
• The design of the microprocessor is driven by the desire to make it as
expandable as possible, in the expectation of commercial success in
the marketplace.
Microcontrollers
• Figure 2 shows the block diagram of a typical microcontroller, which is a true computer
on a chip.

Fig 2: Block diagram of the Microcontroller


• The design incorporates all of the features found in a microprocessor CPU: ALU, PC.
SP, and registers. It also has added the other features needed to make a complete
computer: ROM, RAM, parallel I/O, serial I/O, counters, and a clock circuit.
• Like the microprocessor, a microcontroller is a general-purpose device, but one
which is meant to fetch data, perform limited calculations on that data, and control
its environment based on those calculations.
• The prime use of a microcontroller is to control the operation of a machine using a
fixed program that is stored in ROM and that does not change over the lifetime of the
system.
Requires more Hardware Requires Less Hardware
A Microcontroller Survey
Four-Bit Microcontrollers
• The cost of any commodity microcontroller depends on the volume of the package and
the number of pins as on the amount of silicon inside.

• Pin count depends on the number of data bits handled by the microcontroller and I/O
capability

• 4 bit µC reduces package cost and pin count to a minimum.

• Applications: LED/LCD Display, Portable battery charger.

• These are less expensive .

• Ex: Renasas M34501, 20 PIN DIP

4-bit RAM 10 bit ROM COUNTER I/O PINS OTHER FEATURES


256 4K 2 14 A/D,WDT
8 bit Microcontroller
• Most popular Microcontroller in use today.

• 8 bits have proven , they are very useful to perform everyday controller tasks.

• Capable to represent 256 decimal values.

• 1-byte word is adequate for many control and monitoring applications.

• ASCII code is also Byte size :- Natural choice for data communication
applications.

• Low cost ROM and RAM memory stores 1 byte per memory location, so easy
for interfacing.
• Based on the 8051 architecture itself, some 44 manufacturers produced over 600 different
models

• Designed by Microchip, Motorola & Zilog added 100’s of additional choice to the 8-bit
MC.

• Ex: 8051 , 8 bit µC ,40 PIN DIP

• On-chip ROM Memory may be increased

• ROM less models use EPROM’s as prototype

• Flash and EEPROM memories may be incorporated into the design.

RAM ROM COUNTER I/O PINS OTHER FEATURES


128 bytes 4K 2 32 A/D,WDT,UART, Counter arrays,D/A
16 bit Microcontroller
• Greatly increased the memory size and speed.

• Better suited for programming in High level language like C.

• Applications: Disk drives, MODEMs, Printers, Scanners, Pattern recognition,


Automative and Servo motor control.

• 16 bit Microcontroller :- Motorola 68HC16Z3-144 lead LQFP Package

• Only few (24) of the 144 pins are used for general purose I/O

• Most of the pins are used for External memory addressing, Serial data and External
memory bus control. RAM ROM COUNTER I/O PINS OTHER FEATURES

4K 8K 2 24 A/D,WDT,UART,,D/A
32 bit Microcontroller
• Evolving away from general purpose applications to Targeted markets such
as PDA,GPS, Automotive control and Communication networks, Robotics,
Cell phones etc..

• LH79520-176 PIN LQFP Packages

• Also used in Note book computer: 32K RAM, 3 UART’S, Synchronous


serial, Two PWM’S, 64 I/O pins, 4 Counters, RTC,DMA
The 8051 Architecture:8051 Microcontroller Hardware

The 8051 architecture consists of these specific features:

• Eight-bit CPU with registers A (the accumulator) and B

• Sixteen-bit program counter (PC) and data pointer (DPTR)

• Eight-bit program status word (PSW)

• Eight-bit stack pointer (SP)

• Internal ROM or EPROM (8751) of 0 (8031) to 4K (8051)


• Internal RAM of 128 bytes:

➢Four register banks, each containing eight registers

➢Sixteen bytes, which may be addressed at the bit level

➢Eighty bytes of general-purpose data memory

• Thirty-two input/output pins arranged as four 8-bit ports: PO-P3

• Two 16-bit timer/counters: TO and Tl

• Full duplex serial data receiver/transmitter: SBUF


• Control registers: TCON, TMOD, SCON, PCON, IP, and IE
• Two external and three internal interrupt sources

• Oscillator and clock circuits


• The oscillator formed by the crystal, capacitors, and an on-chip inverter generates a pulse train at
the frequency of the crystal

• The clock frequency, f. establishes the smallest interval of time within the micro controller, called
the pulse, P, time.

• The machine cycle is itself made up of six states. A state is the basic time interval for discrete
operations of the microcontroller such as fetching an opcode byte, decoding an opcode, executing
an opcode, or writing a data byte. Two oscillator pulses define each state

• The time to execute that instruction is then found by multiplying C by 12 and dividing the product
by the crystal frequency:
Program Counter and Data Pointer

• The 8051 contains two 16-bit registers: the program counter (PC) and the data pointer (DPTR).
Each is used to hold the address of a byte in memory.

• Program instruction bytes are fetched from locations in memory that are addressed by the PC.

• Program ROM may be on the chip at addresses 0000h to 0FFFh

• The PC is automatically incremented after every instruction byte is fetched and may also be
altered by certain instructions. The PC is the only register that does not have an internal address.

• The DPTR register is made up of two 8-bit registers, named DPH and DPL, that are used to
furnish memory addresses for internal and external code access and external data access.

• DPTR does not have a single internal address; DPH and DPL are each assigned an address.
A and B CPU Registers

• The 8051 contains 34 general-purpose, or working, registers.

• Two of these, registers A and B, comprise the mathematical core of the 8051 central processing unit
(CPU).

• The other 32 are arranged as part of internal RAM in four banks, B0-B3, of eight registers each,
named RO to R7.

• The A (accumulator) register is the most versatile registers and is used for many operations,
including addition, subtraction, integer multiplication and division, and Boolean bit
manipulations.

• The A register is also used for all data transfers be tween the 8051 and any external memory.

• The B register is used with the A register for multiplication and division operations and has no
other function other than as a location where data may be stored.
Flags and the Program Status Word (PSW)
• Flags are 1 -bit registers provided to store the results of certain program instructions.

• Other instructions can test the condition of the flags and make decisions based upon the flag
states

• The math flags include carry (C), auxiliary carry (AC), overflow (OV), and parity (P).

• User flags are named F0, GF0, and GF1; they are general-purpose flags that may be used by
the programmer to record some event in the program.

• In order that the flags may be conveniently addressed, they are grouped inside the program
status word (PSW) and the power control (PCON) registers

• The remaining two user flags, GF0 and GFI, are stored in PCON
Internal Memory

• A functioning computer must have memory for program code bytes, commonly in
ROM, and RAM memory for variable data that can be altered as the program runs.

• The 8051 has internal RAM and ROM memory for these functions.
Internal RAM
• The 128-byte internal RAM

• Thirty-two bytes from address 00 to 1Fh that make up 32 working registers

• They are organized as four banks of eight registers each.

• The four register banks are numbered 0 to 3 and are made up of eight registers named RO
to R7

• Bits RS0 and RS1 in the PSW determine which bank of registers is currently in use at any
time when the program is running

• Each register can be addressed by name or by its RAM address.

• Thus RO of bank 3 is RO (if bank 3 is currently selected) or address 18h (whether bank 3
is selected or not).
1. A bit-addressable area of 16 bytes occupies RAM byte addresses 20h to 2Fh, forming a
total of 128 addressable bits.
2. An addressable bit may be specified by its bit address of 00h to 7Fh, or 8 bits may
form any byte address from 20h to 2Fh.
3. For example, bit address 4Fh is also bit 7 of byte address 29h.
4. A general-purpose RAM area above the bit area, from 30h to 7Fh, addressable as bytes.
The Stack and the Stack Pointer

• The stack refers to an area of internal RAM that is used in conjunction with certain op
codes to store and retrieve data quickly.

• The 8-bit stack pointer (SP) register is used by the 8051 to hold an internal RAM
address that is called the “Top of the stack.“

• The address held in the SP register is the location in internal RAM where the last byte
of data was stored by a stack operation.

• When data is to be placed on the stack, the SP increments before storing data on the
stack so that the stack grows up as data is stored.

• As data is retrieved from the stack, the byte is read from the stack, and then the SP
decrements to point to the next available byte of stored data.
• The SP is set to 07h when the 8051 is reset and can be changed to any internal

RAM address by the programmer


Special Function Registers

• The 8051 operations that do not use the internal 128-byte RAM addresses from 00h to
7Fh are done by a group of specific internal registers, each called a special-function
register (SFR), which may be addressed much like internal RAM, using addresses from
80h to FFh.

• Not all of the addresses from 80h to FFh are used for SFRs, and attempting to use an
address that is not defined, or "empty," results in unpredictable results.

• SFRs are named in certain opcodes by their functional names, such as A or THO, and
are referenced by other opcodes by their addresses, such as 0E0h or 8Ch.

• Note that any address used in the program must start with a number; thus address E0h
for the A SFR begins with 0.
NAME FUNCTION ADDRESS
(HEX)
A Accumulator 0EO
INTERNAL
B Arithmetic 0F0
RAM
DPH Addressing external memory 83 NAME FUNCTION ADDRESS
(HEX)
DPL Addressing external memory 82
IE Interrupt enable control 0A8
SP Stack pointer 81
IP Interrupt priority 0B8
Timer/counter mode
PO Input/output port latch 80 TMOD 89
control
Pl Input/output port latch 90
TCON Timer/counter control 88
P2 Input/output port latch AO
P3 Input/output port latch 0B0 TL0 Timer 0 low byte 8A

PCON Power control 87 THO Timer 0 high byte 8C


PSW Program status word ODO TL 1 Timer 1 low byte 8B
SCON Serial port control 98 THI Timer 1 high byte 8D
SBUF Serial port data buffer 99
Internal ROM

• A block of internal program code, contained in an internal ROM, occupies code address
space 0000h to 0FFFh.

• The PC is ordinarily used to address program code bytes from addresses 0000h to
FFFFh.

• Program addresses higher than 0FFFh, which exceed the internal ROM capacity, will
cause the 8051 to automatically fetch code bytes from external program memory.

• Code bytes can also be fetched exclusively from an external memory, addresses 0000h
to FFFFh, by connecting the external access pin (EA pin 31 on the DIP) to ground.
Input/Output Pins, Ports, and Circuits

You might also like