0% found this document useful (0 votes)
4 views

MPMC module 3.1

This document provides an overview of microprocessors and microcontrollers, highlighting the differences between general-purpose microprocessors and microcontrollers, particularly focusing on the 8051 family. It details the architecture, components, and functionalities of the 8051 microcontroller, including its registers, ports, and timers. The document emphasizes the advantages of microcontrollers in specific applications where cost and space are critical, as well as the compatibility of various 8051 versions.

Uploaded by

rishiv1947
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

MPMC module 3.1

This document provides an overview of microprocessors and microcontrollers, highlighting the differences between general-purpose microprocessors and microcontrollers, particularly focusing on the 8051 family. It details the architecture, components, and functionalities of the 8051 microcontroller, including its registers, ports, and timers. The document emphasizes the advantages of microcontrollers in specific applications where cost and space are critical, as well as the compatibility of various 8051 versions.

Uploaded by

rishiv1947
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

MICROPROCESSORS AND

MICROCONTROLLERS – UNIT 3

B Y S ON A L G U P TA
INSTRUCTIONS

• Understand the two figures provided properly with a view of


comparison with 8086.
• Details about bus connections etc is not needed. Just a very brief
overview like what are the components in the architecture and what is
the general difference between 8086 and 8051 architectures.
• Some explanation is provided in the text I have given.
• For more explanation, please search internet.
• Try not to ask me any doubts, however, you may email me if absolutely
necessary.
• Their will be one question of at least 5 marks from this material
provided.
MICROCONTROLLER VERSUS GENERAL-
PURPOSE MICROPROCESSOR

• What is the difference between a microprocessor and


microcontroller?
• By microprocessor is meant the general-purpose microprocessors
such as Intel’s x86 family (8086, 80286, 80386, 80486, and the Pentium)
or Motorola’s 680x0 family (68000, 68010, 68020, 68030, 68040, etc.).
• These microprocessors contain no RAM, no ROM, and no I/O ports
on the chip itself.
• For this reason, they are commonly referred to as general-purpose
microprocessors. See Figure 1.
MICROCONTROLLER VERSUS GENERAL-
PURPOSE MICROPROCESSOR

• A system designer using a general-purpose microprocessor such as the


Pentium or the 68040 must add RAM, ROM, I/O ports, and timers
externally to make them functional.
• Although the addition of external RAM, ROM, and I/O ports makes
these systems bulkier and much more expensive, they have the
advantage of versatility such that the designer can decide on the
amount of RAM, ROM, and I/O ports needed to fit the task at hand.
• This is not the case with microcontrollers.
• A microcontroller has a CPU (a microprocessor) in addition to a fixed
amount of RAM, ROM, I/O ports, and a timer all on a single chip.
MICROCONTROLLER VERSUS GENERAL-
PURPOSE MICROPROCESSOR

• In other words, the processor, RAM, ROM, I/O ports, and timer are all
embedded together on one chip; therefore, the designer cannot add
any external memory, I/O, or timer to it.
• The fixed amount of on-chip ROM, RAM, and number of I/O ports in
microcontrollers makes them ideal for many applications in which cost
and space are critical.
• In many applications, for example a TV remote control, there is no
need for the computing power of a 486 or even an 8086
microprocessor because the space it takes, the power it consumes, and
the price per unit are much more critical considerations than the
computing power.
MICROCONTROLLER VERSUS GENERAL-
PURPOSE MICROPROCESSOR

• These applications most often require some I/O operations to read


signals and turn on and off certain bits.
• It is interesting to note that some microcontroller manufacturers have
gone as far as integrating an ADC (analog-to- digital converter) and
other peripherals into the microcontroller.
OVERVIEW OF THE 8051 FAMILY

• In 1981, Intel Corporation introduced an 8-bit microcontroller called


the 8051.
• This microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM,
two timers, one serial port, and four ports (each 8-bits wide) all on a
single chip.
• At the time, it was also referred to as a “system on a chip.”
• The 8051 is an 8-bit processor, meaning that the CPU can work on
only 8 bits of data at a time.
• Data larger than 8 bits has to be broken into 8-bit pieces to be
processed by the CPU.
• The 8051 has a total of four I/O ports, each 8-bits wide.
OVERVIEW OF THE 8051 FAMILY

• See Figure 2.
• Although the 8051 can have a maximum of 64K bytes of on-chip ROM,
many manufacturers have put only 4K bytes on the chip.
• The 8051 became widely popular after Intel allowed other
manufacturers to make and market any flavors of the 8051 they please
with the condition that they remain code-compatible with the 8051.
• This has led to many versions of the 8051 with different speeds and
amounts of on-chip ROM marketed by more than half a dozen
manufacturers.
OVERVIEW OF THE 8051 FAMILY

• It is important to note that although there are different flavors of the


8051 in terms of speed and amount of on-chip ROM, they are all
compatible with the original 8051 as far as the instructions are
concerned.
• This means that if you write your program for one, it will run on any of
them regardless of the manufacturer.
8051 REGISTERS

• In the CPU, registers are used to store information temporarily.


• That 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 registers are 8-bit registers.
• In the 8051, there is only one data type: 8 bits.
• The 8 bits of a register are shown in the diagram from the MSB (most
significant bit) D7 to the LSB (least significant bit) D0.
8051 REGISTERS

• With an 8-bit data type, any data larger than 8 bits must be broken
into 8-bit chunks before it is processed.
• Since there are a large number of registers in the 8051, we will
concentrate on some of the widely used general-purpose registers.
• The most widely used registers of the 8051 are A (accumulator), B,
R0, R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer), and PC
(program counter).
• All of the above registers are 8 bits, except DPTR and the program
counter.
MOV INSTRUCTION
PIN DIAGRAM
PORT 0

• Port 0 occupies a total of 8 pins (pins 32–39).


• It can be used for input or output.
• For example, the following code will continuously send out to port 0
the alternating values of 55H and AAH.
PORT 0 AS INPUT

• In order to make it an input, the port must be programmed by writing


1 to all the bits.
• In the following code, port 0 is configured first as an input port by
writing 1s to it, and then data is received from that port and sent to
P1.
DUAL ROLE OF PORT 0

• As shown in Figure 1, port 0 is also designated as AD0–AD7, allowing


it to be used for both address and data.
• When connecting an 8051/31 to an external memory, port 0 provides
both address and data.
• The 8051 multiplexes address and data through port 0 to save pins
using ALE same as in 8086.
PORT 1

• Port 1 occupies a total of 8 pins (pins 0 through 7).


• It can be used as input or output.
• Upon reset, port 1 is configured as an input port.
• The following code will continuously send out to port 1 the alternating
values 55H and AAH.
PORT 1 AS INPUT

• If port 1 has been configured as an output port, to make it an input


port again, it must be programmed as such by writing 1 to all its bits.
• In the following code, port 1 is configured first as an input port by
writing 1s to it, then data is received from that port and saved in R7,
R6, and R5.
PORT 2 AS INPUT

• To make port 2 an input, it must programmed as such by writing 1 to


all its bits.
• In the following code, port 2 is configured first as an input port by
writing 1s to it.
• Then data is received from that port and is sent to P1 continuously.
PORT 3

• Port 3 occupies a total of 8 pins, pins 10 through 17.


• It can be used as input or output.
• Although port 3 is configured as an input port upon reset,
this is not the way it is most commonly used.
• Port 3 has the additional function of providing some
extremely important signals such as interrupts. T
• able 1 provides these alternate functions of P3.
• This information applies to both 8051 and 8031 chips.
PORT 3

• P3.0 and P3.1 are used for the RxD and TxD serial communication
signals.
• Bits P3.2 and P3.3 are set aside for external interrupts.
• Bits P3.4 and P3.5 are used for timers 0 and 1.
• Finally, P3.6 and P3.7 are used to provide the WR and RD signals of
external memories connected in 8031-based systems.
• In systems based on the 8751, 89C51, or DS89C4x0, pins 3.6 and 3.7
are used for I/O while the rest of the pins in port 3 are normally used
in the alternate function role.
TIME DELAY FOR 8051

• The CPU takes a certain number of clock cycles to execute an


instruction.
• In the 8051 family, these clock cycles are referred to as machine cycles
(MC).
• The original 8051 design used 12 clock periods per machine cycle.
• The frequency of the crystal connected to the 8051 family can vary
from 4 MHz to 30 MHz, depending on the chip rating and
manufacturer.
• Very often the 11.0592 MHz crystal oscillator is used to make the
8051-based system compatible with the serial port of the x86 PC.
TIME DELAY FOR 8051
Every instruction is assumed to take 1 Machine Cycle
TIMER
WHAT ARE TIMERS?

• Timers are hardware components in the 8051 microcontroller


designed to track time intervals or count external events.
• They operate by incrementing or decrementing a register based on an
internal clock signal.
• The 8051 has two timers/counters.
• They can be used either as timers to generate a time delay or as
counters to count events happening outside the microcontroller.
WHAT ARE TIMERS?

• The 8051 has two timers: Timer 0 and Timer 1.


• They can be used either as timers or as event counters.
• Both Timer 0 and Timer 1 are 16 bits wide. S
• ince the 8051 has an 8-bit architecture, each 16-bit timer is accessed as
two separate registers of low byte and high byte.
TIMER 0 REGISTERS

• The 16-bit register of Timer 0 is accessed as low byte and high byte.
• The low-byte register is called TL0 (Timer 0 low byte) and the high-byte register is
referred to as TH0 (Timer 0 high byte).
• These registers can be accessed like any other register, such as A, B, R0, R1, or R2.
• For example, the instruction “MOV TL0,#4FH” moves the value 4FH into TL0, the low
byte of Timer 0.
• These registers can also be read like any other register.
TIMER 1 REGISTERS

• Timer 1 is also 16 bits, and its 16-bit register is split into two bytes,
referred to as TL1 (Timer 1 low byte) and TH1 (Timer 1 high byte).
• These registers are accessible in the same way as the registers of
Timer 0.
TMOD (TIMER MODE) REGISTER

• Both timers 0 and 1 use the same register, called TMOD, to set the
various timer operation modes.
• TMOD is an 8-bit register in which the lower 4 bits are set aside for
Timer 0 and the upper 4 bits for Timer 1.
• In each case, the lower 2 bits are used to set the timer mode and the
upper 2 bits to specify the operation.
• These options are discussed next.

You might also like