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

Microcontroller - Architecture

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)
21 views

Microcontroller - Architecture

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/ 49

MICROCONTROLLER

MICROCONTROLLER
• A microcontroller is a small and low-cost microcomputer, which is
designed to perform the Specific tasks of embedded systems like
displaying microwave’s information, receiving remote signals, etc.
The general microcontroller consists of the processor, the memory
(RAM, ROM, and EPROM), Serial ports, peripherals (timers,
counters), etc.
MICROPROCESSOR VS MICROCONTROLLER
TYPES OF MICROCONTROLLERS

• Microcontrollers are divided into


various categories based on
memory, architecture, bits and
Instruction sets.
BIT
• 8-bit microcontroller − this type of microcontroller is used to execute
arithmetic and logical operations like addition, subtraction, multiplication
division, etc. For example, Intel 8031 and 8051 are 8 bits microcontroller.

• 16-bit microcontroller − this type of microcontroller is used to perform


arithmetic and logical operations where higher accuracy and performance is
required. For example, Intel 8096 is a 16-bit microcontroller.

• 32-bit microcontroller − this type of microcontroller is generally used in


automatically controlled appliances like automatic operational machines,
medical appliances, etc.
MEMORY

• Based on the memory configuration, the microcontroller is further divided into


two categories.
• External memory microcontroller − This type of microcontroller is
designed in such a way that they do not have a program memory on the
chip. Hence, it is named as external memory microcontroller. For
example: Intel 8031 microcontroller.

• Embedded memory microcontroller − this type of microcontroller is


designed in such a way that the microcontroller has all programs and
data memory, counters and timers, interrupts, I/O ports are embedded
on the chip. For example: Intel 8051 microcontroller.
INSTRUCTION SET
• Based on the instruction set configuration, the
microcontroller is further divided into two Categories.
• CISC − CISC stands for complex instruction set
computer. It allows the user to insert a single instruction
as an alternative to many simple instructions.
• RISC − RISC stands for Reduced Instruction Set
Computers. It reduces the operational time by shortening
the clock cycle per instruction.
APPLICATIONS OF MICROCONTROLLERS
• Microcontrollers are widely used in various different
devices such as −
• Light sensing and controlling devices like LED.
• Temperature sensing and controlling devices like
microwave oven, chimneys.
• Fire detection and safety devices like Fire alarm.
• Measuring devices like Volt Meter.
INTRODUCTION TO 8051 MICROCONTROLLER
• 8051 microcontroller is designed by Intel in 1981. It is an 8-bit
microcontroller.

• It is built with 40 pins DIP (dual inline package), 4kb of ROM


storage and 128 bytes of RAM storage, 2 16-bit timers.

• It consists of are four parallel 8-bit ports, which are programmable


as well as addressable as per the requirement.

• An on-chip crystal oscillator is integrated in the microcontroller


having crystal frequency of 12 MHz.
FEATURES OF 8051 MC
• 4K bytes internal ROM

• 128 bytes internal RAM

• Four 8-bit I/O ports (P0 - P3).

• Two 16-bit timers/counters

• One serial interface

• only 1 On chip oscillator (external crystal)

• 6 interrupt sources (2 external , 3 internal, Reset)

• 64K external code (program) memory(only read)PSEN

• 64K external data memory(can be read and write) by RD,WR

• Code memory is selectable by EA (internal or external)


FUNCTIONAL BLOCK DIAGRAM OF 8051
MICROCONTROLLER
• The Intel 8051 contains two separate buses for both program and data. So, it has two
distinctive memory spaces of 64K x 8 size for both program and data.

• It is based on an 8 bit central processing unit with an 8 bit accumulator and another
8-bit B register as main processing blocks.

• Other portions of the architecture include few 8 bit and 16b it registers and 8-bit
memory locations.

• It has some amount of data RAM built in the device for internal processing. This area is
used for stack operations and temporary storage of data.

• 8051 is supported with on-chip peripheral functions like I/O ports, Timers/ Counters,
Serial communication port
BLOCK DIAGRAM OF 8051
ARCHITECTURE OF 8051
CENTRAL PROCESSING UNIT

• The CPU is the brain of the microcontrollers it’s expected task is


reading user's programs and executing the as per instructions
stored there in.

• Its primary elements are an Accumulator (AC), Stack Pointer (SP)


Program Counter (PC), Program Status Word (PSW), Data Pointer
(DTPR) and few more 8-bit register.
ARITHMETIC LOGIC UNIT (ALU)

• The arithmetic / logic unit performs the computing functions; it


includes the accumulator, temporary register, arithmetic and logic
circuits.

• The temporary register is used to hold data during an arithmetic /


logic operation.

• The result is stored in the accumulator register


ACCUMULATOR

• The accumulator register (ACC or A) act as an operand register, in


case of some instructions.

• This may either be implicit or specified in the instruction.

• The ACC register has been allotted on address in the on-chip


special function register bank
PROGRAM STATUS WORD (PSW)

• This set of flags contains the status information and is considered


as one of the special function registers.
STACK POINTER (SP)
• This 8-bit register is incremented before the data is stored onto the stack using
PUSH or CALL instructions.
• This registers contains 8-bit stack top address. The stack may be defined
anywhere in the on-chip 128 byte RAM. After reset, the SP register is initialized
to 07.
• After each write two stack operation, the 8-bit contents of the operand are stored
onto the stack, after incrementing the SP register by 1.
• Thus if SP contains 07H, the forthcoming PUSH operation will store the date at
address 08H in the internal RAM.
• The SP content will be incremented to 08.the 8051 stack is not a top-down data
structure, like other Intel processors.
• This register has also been allotted on address in th especial function register
bank.
DATA POINTER (DTPR)

• This 16-bit register contains a higher byte (DPH) and the lower byte (DPL) of a
16-bit external data RAM address.

• It is accessed as a 16-bit register or two 8-bit registers as specified above. It has


been allotted to two address in the special function register bank, for its two
bytes DPH and DPL.
PORT 0 TO 3 LACHES AND DRIVERS

• This four latches and driver pairs are allotted to each of the four
on-chip I/O ports.

• These latches have been allotted address in the especial function


register bank.

• Using the allotted addresses, the users can communicate with


these ports. These are identified as P0, P1 and P3.
SERIAL DATA BUFFER
• The serial data buffer internally contains two independent registers.
• One of them is a transmit buffer which is necessarily a parallel–in
serial–out (PISO) register.
• The other is called receive buffer which is a serial–in parallel–out
(SIPO) register.
• Loading a byte to the transmit buffer initiates serial transmission of
that byte.
• The serial data buffer is identified as SBUF and is one of the special
function register.
• If a byte is written to SBUF, it initiates serial transmission and if the
SBUF is read, it reads received serial data.
TIMER REGISTER
• These two 16-bit register can be accessed as the lower and upper
bytes.

• For examples, TL0 represents the lower byte of the timing register 0,
while TH0 represents the upper byte of the timing register 0.

• Similarly, TL1 and TH1 represent lower and higher byte of the timing
register 1.

• All these registers an be accessed using the four addresses allotted to


them which lie in the special function register (SFR) address
range,i.e.80Hto FF.
TIMER REGISTER
• These registers are known as Timer0 andTimer1. The timer registers can be
used in two modes. These modes are Timer mode and the Counter mode.

• TIMER MODE

• In the timer mode, the internal machine cycles are counted. So this register is
incremented in each machine cycle.

• COUNTER MODE

• In the counter mode, the external events are counted. In this mode, the timer
register is incremented for each 1 to 0 transition of the external input pin.
CONTROL REGISTER

• The special function register IP, IE, TMOD, TCON, SCON and
PCON contain control and status information for interrupts, Timer /
Counters and serial port.

• All of the registers have been allotted addresses in the special


function register bank of 8051.
TIMING AND CONTROL UNIT

• This unit derives all the necessary timing and control signals
recovered for the internal operation of the circuit.

• It also derives control signals recovered for controlling the system


bus.
OSCILLATOR

• This circuit generates the basic timing clock signal for the operation of the circuit
using crystal oscillator

INSTRUCTION REGISTER

• This register decodes the Opcode of an instruction to be executed and gives


information to the timing and control unit to generate necessary signal for the
execution of the instruction.

EPROM and Program Address Register

• This block provides an on-chip EPROM and a mechanism to internally address


it.
RAM and RAM Address Register

• These blocks provide internal 128 bytes of RAM and a mechanism to


address it internally.

SFR (Special Function Register) Register Bank

• This is a set of special function registers, which can be addressed using


their respective addresses which lie in the range 80H to FFH .

• Finally, the interrupt, serial port and timer units control and perform their
specific function under the control of the timing and control unit.
MEMORY ORGANISATION:
• The 8051 has a separate memory space for programs (Code) and
data.

• Program memory stores the programs to be executed, while data


memory stores the data like intermediate results, variable and
constants required for the execution of the program.
MEMORY ORGANISATION - 8051
EXTERNAL PROGRAM (CODE) MEMORY

• The executable program is stored in this code memory.


• The code memory size is limited to 64KBytes (in a standard 8051).
• The code memory is read-only in normal operation and is
programmed under special conditions. e.g. it is a PROM or a Flash
RAM type of memory.
EXTERNAL RAM DATA MEMORY

• This is read-write memory and is available for storage of data.


• Up to 64KBytes of external RAM data memory is supported (in a
standard 8051).
INTERNAL MEMORY

• The 8051’s on-chip memory consists of 256 memory bytes


organized as follows:

• The first 128 bytes of internal memory is organized as shown in


figure 2, and is referred to as Internal RAM, or IRAM.
REGISTER BANKS: 00H TO 1FH

• The 8051 uses 8 general-purpose registers R0 through R7 (R0,


R1, R2, R3, R4, R5, R6, and R7).

• These registers are used in instructions such as:

• ADD A, R2 ; adds the value contained in R2 to the accumulator


BIT ADDRESSABLE RAM: 20H TO 2FH

• The 8051 supports a special feature which allows access to bit variables.

• This is where individual memory bits in Internal RAM can be set or cleared.

• In all there are 128 bits numbered 00h to 7Fh.

• Being bit variables any one variable can have a value 0 or 1.

• A bit variable can be set with a command such as SETB and cleared with a
command such as CLR.
GENERAL PURPOSE RAM: 30H TO 7FH
• These 80 bytes of Internal RAM memory are available for general-purpose data
storage.

• Access to this area of memory is fast compared to access to the main memory
and special instructions with single byte operands are used.

• However, these 80 bytes are used by the system stack and in practice little
space is left

• for general storage.

• The general purpose RAM can be accessed using direct or indirect addressing
modes.
SFR REGISTERS
• The SFR registers are located within the Internal Memory in the address range 80h to
FFh, as shown in figure 3.

• Each SFR has a very specific function.

• Each SFR has an address (within the range 80h to FFh) and a name which reflects the
purpose of the SFR.

• Although 128 byes of the SFR address space is defined only 21 SFR registers are
defined in the standard 8051.

• Undefined SFR addresses should not be accessed as this might lead to some
unpredictable results.

• Note some of the SFR registers are bit addressable.

• SFRs are accessed just like normal Internal RAM locations.


SFR REGISTERS
ADDRESSING MODES OF 8051
• The following addressing modes are used to access
data:
• l. Immediate addressing mode
• 2. Register addressing mode
• 3. Direct addressing mode
• 4. Register indirect addressing mode
• 5. Indexed addressing mode.
IMMEDIATE ADDRESSING MODE
REGISTER ADDRESSING MODE
DIRECT ADDRESSING MODE
REGISTER INDIRECT ADDRESSING MODE
• In this mode a register is used as a pointer to the data. If the data
is inside the CPU, only registers R0 and Rl are used for this
purpose.

• When R0 and Rl hold the addresses of RAM locations they must


be preceded by the "@" sign.

• MOV @ R1, A: Move contents of A into RAM location whose


address is held by R1.

• MOV B, @ R0: Move contents of RAM location whose address is


held by R0 into B.
INDEXED ADDRESSING MODE
• Only the program memory can be accessed by this mode. This mode
is intended for reading lookup tables in the program memory.

• A 16 bit base registers (DPTR or PC) points to the base of the lookup
tables and accumulator carries the constant indicating table entry
number.

• The address of the exact location of the table is formed by adding the
accumulator data to the base pointer.

• MOVC A, @A+ DPTR: The contents of A are added to the DPTR to


form the 16-bit address of the needed data. 'C' means code.
8051 – ADDITION OF TWO 16-BIT NUMBERS
SUBTRACTION OF TWO 16 - BIT NUMBERS
MULTIPLICATION
DIVISION OF TWO 8- BIT NUMBERS

You might also like