MPMC Unit 3
MPMC Unit 3
(EC T53)
Course Outcome
Describe the architecture, Classify the Instruction set and implement
CO 1 algorithms using 8085
Explore the architectures of 8086 with its instruction set and Compare it
CO 4 with advanced 16 bit Microprocessors
Memory
Address Bus 0
Program
CPU
Fetch Bus Harvard
Address Bus 0
Architecture
Data Bus Data
Criteria for Choosing a Microcontroller
• Speed
• Packaging
• Power consumpti on
• The amount of RAM and ROM on chip
• The number of I/O pins and the timer on chip
• How e a sy to upgrade to higher performance or lower
power- consumpti on versions
• Cost per unit
8051 Architecture
Features of 8051
• 8 bit CPU
CY AC F0 RS1 RS0 OV -- P
• 16 bit address
• 16 bit register
• RS1 and RS0 (4TH BIT AND 3RD BIT) program status word select
the bank
• Each bank contains R0 TO R7
BANK 2 (R0-R7)
10-17
BANK 1 (R0-R7)
08-0F
We can observe the frequency on the XTAL2 pin using the
oscilloscope.
RST (Pin 9)
RESET pin is an input and is active high (normally low)
Upon applying a high pulse to this pin, the microcontroller will
reset and terminate all activities
This is often referred to as a power-on reset
Activating a power-on reset will cause all values in the registers
to be lost
EA ( pin 31 ): external access
externally.
P0.0 - P0.7 I/O Port 0: Port 0 is an open-drain, bi-directional I/O port. Port
0 is also the multiplexed low-order address and data bus
during accesses to external program and data memory.
P2.0 - P2.7 I/O Port 2: Port 2 is an 8-bit bidirectional I/O. Port 2 emits the
high order address byte during fetches from external
program memory and during accesses to external data
memory that use 16 bit addresses.
P3.0 - P3.7 I/O Port 3: Port 3 is an 8 bit bidirectional I/O port. Port 3 also
serves special features as explained.
Pin Description Summary
PIN TYPE NAME AND FUNCTION
RST I Reset: A high on this pin for two machine cycles while the
oscillator is running, resets the device.
ALE O Address Latch Enable: Output pulse for latching the low byte
of the address during an access to external memory.
PSEN O Program Store Enable: The read strobe to external program
memory. When executing code from the external program
memory, PSEN* is activated twice each machine cycle,
except that two PSEN* activations are skipped during each
access to external data memory.
MOV A, #6AH
Register Specific Addressing Mode
SWAP A
SWAP DPTR
Register Indexed Addressing Mode
MOVC A, @A+DPTR
8051 Instruction Set
Classification of Instruction Set
Arithmetic instructions
Logical instructions
• Exchange instructions
XCH a, byte ;exchange accumulator and byte
XCHD a, byte ;exchange low nibbles of
;accumulator and byte
MOV
MOV A,#0FFH
MOV P0,A
MOV R0, A
MOV A, R1
MOVX A,@DPTR
MOVC A,@DPTR
Stack
Direct addressing mode must be used in Push and Pop
push acc
Push
psw
Push b
Exchange Instructions
Arithmetic Instructions
Logic Instructions
Arithmetic Instructions
• Add
• Subtract
• Increment
• Decrement
• Multiply
• Divide
Arithmetic Instructions
Mnemonic Description
C = 1
AC = 1
OV = 0
Logic Instructions
CLR A
CLR byte (direct mode)
CLR Ri (register mode)
CLR @Ri (register indirect
mode)
Rotate
• Rotate instructions operate only on a
RLA
RRA
RRC A
C
MOV A, #0A9H ; A = A9
ADD A, #14H ; A = BD (10111101), C=0
RRC A ; A = 01011110, C=1
RLC A C
SWAP A
SWAP A ; a = 27h
Program Flow Control
• Unconditional jumps
Program transfer is
permanent
• Conditional jumps
Program transfer is
• Call and return
temporary
Unconditional Jumps
•Mnemonic • Description
•JZ <rel addr> •Jump if a = 0
Mnemonic Description
CJNE A, #data <rel addr> Compare A and data, jump
if not equal
CJNE Rn, #data <rel addr> Compare Rn and data,
jump if not equal
CJNE @Rn, #data <rel addr> Compare Rn and memory,
jump if not equal
DJNZ Rn, <rel addr> Decrement Rn and then
jump if not zero
; PC = stack
– ret
Bit-Oriented Data Transfer
mov C, P0.0
mov C, 67h
mov C, 2ch.7
Bit-Oriented Data Transfer
• CLR Bit
Ex:- CLR C, CLR P1.2
• SETB Bit
Ex:- SETB C, SET P1.2, SETB PSW.3
• CPL Bit
CPL C
• Single bit Logical Operation Instructions
AND Operation: ANL C, PSW.2
OR Operation : ORL C , ACC.7
Memory Organization
Memory Structure
External Code Memory
External Data Memory
On-chip Memory Internal RAM
Registers
Bit Addressable Memory
Special Function Register
Special Function Register
Parallel Ports
Hardware Structure of IO pin
Hardware Structure of IO pin
Hardware Structure of IO pin
Writing 1 to Output Pin P1.X
Writing 0 to Output Pin P1.X
Reading HIGH at Input pin
Reading LOW at Input pin
Port 3 Bit Latches and I/O Buffer
Port 0 with Pull Up Resistors
Timers and Counters
Timer Classification
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. The 8051 has
two timers:
• Timer 0,
• Timer 1.
GATE
• Gating control when set. Timer/counter is enable only while the INTx pin is high and
the TRx control pin is set. When cleared, the timer is enabled whenever the TRx
control bit is set.
Timers of 8051 do starting and stopping by either software or hardware control.
In using software to start and stop the timer where GATE=0
The start and stop of the timer are controlled by way of software by the
TR(timer start) bits TR0 and TR1
To start Timer, TR0 or TR1 must be high. or To stop Timer, TR0 or TR1 must be low.
These instructions start and stop the timers as long as GATE=0 in the TMOD register
The hardware way of starting and stopping the timer by an external source is
achieved by making GATE=1 in the TMOD register
TMOD Register
C/T
Timer or counter selected Cleared for timer operation (input from internal
system clock). Set for counter operation (input from Tx input pin).
If C/T = 0, it is used as a timer for time delay generation. The clock source for
the time delay is the crystal frequency of the 8051.
If C/T = 1, it is used as a counter for event counters to count events
happening outside the microcontroller
TMOD Register
TCON Register
Timers – Mode of Operations
Timer 0
Timer 0 – Mode 0
Timer 0 – Mode 1
Timer 0 – Mode 2
Timer 0 – Mode 3
Timer 1
Timer 1 – Mode 0
Timer 1 – Mode 1
Timer 1 – Mode 2
Programming Timers
Programming Timers
Programming Timers
Programming Timers
Interrupts
Interrupts
Interrupts
Interrupts
6 Interrupts in 8051
6 Interrupts in 8051
IE Register
Interrupt Priority
Interrupt Priority Register
Serial Communication
Serial Interface
Memory Organization
The memory module in the PIC microcontroller architecture consists
of
• RAM (Random Access Memory),
• ROM (Read Only Memory) and
• STACK
Random Access Memory (RAM)
RAM is used to store the data temporarily in its registers. The
RAM memory is classified into two banks, and each bank consists
of so many registers.
The RAM registers are classified into two types: Special Function
Registers (SFR) and General Purpose Registers (GPR).
General Purpose Registers (GPR): These registers are used for
general purpose only as the name implies. For example, if we
want to multiply two numbers by using the PIC microcontroller.
Registers are used for multiplying and storing the numbers in
other registers. So these registers don’t have any special
function, CPU can easily access the data in the registers.
Read Only Memory (ROM)
Flash Memory
Flash memory is also programmable read only memory
(PROM) in which we can read, write and erase the program in
many times. Generally, the PIC microcontroller uses this type
of ROM.
Stack
When an interrupt occurs, first the PIC microcontroller has to
execute the interrupt and the existing process address. Then
that is being executed is stored in the stack. After completing
the execution of the interrupt, the microcontroller calls the
process with the help of address, which is stored in the stack
and get executes the process.
Bus
BUS is used to transfer and receive the data from one
peripheral to another. It is classified into two types such as
data bus and address.
I/O Ports
The series of PIC16 consists of five ports such as Port A, Port B,
Port C, Port D & Port E.
Port A is an 16-bit port that can be used as input or output port
based on the status of the TRISA (Tradoc Intelligence Support
Activity) register.
Port B is an 8- bit port that can be used as both input and output
port.
Port C is an 8-bit and the input of output operation is decided by
the status of the TRISC register.
Port D is an 8-bit port acts as a slave port for connection to the
microprocessor BUS.
Port E is a 3-bit port, which serves the additional function of the
control signals to the analog to digital converter.
A/D converters
The analog to digital converter is to convert analog voltage
values to digital voltage values. A/D module of PIC
microcontroller consists of 5 inputs for 28 pin devices and 8
inputs for 40 pin devices.
Interrupts
PIC microcontroller consists of 20 internal interrupts and three
external interrupt sources, which are associated with different
peripherals like ADC, USART, and Timers and so on.
Serial Communication
USART: The USART stands for Universal synchronous and Asynchronous Receiver
and Transmitter, which is a serial communication for two protocols. It is used for
transmitting and receiving the data bit by bit over a single wire with respect to
clock pulses. The PIC microcontroller has two pins TXD and RXD. These pins are
used for transmitting and receiving the data serially.
SPI Protocol: The term SPI stands for Serial Peripheral Interface. This protocol
issused to send data between PIC microcontroller and other peripherals such as
SD cards, sensors and shift registers. PIC microcontroller support three wire SPI
communications between two devices on a common clock source. The data rate
of SPI protocol is more than that of the USART.
I2C Protocol: The term I2C stands for Inter Integrated Circuit and it is a serial
protocol which is used to connect low speed devices such as EEPROMS,
microcontrollers, A/D converters, etc. PIC microcontroller support two wires
Interface or I2C communication between two devices, which can work as both
Master, and Slave device
Oscillators
Oscillators are used for timing generation. PIC
microcontroller consists of external oscillators like RC
oscillators or crystal oscillators, where the crystal oscillator
is connected between the two oscillator pins.