You are on page 1of 32

12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 1

 Compare and contrast microprocessors and microcontrollers


 Describe the advantages of microcontrollers for some
applications
 Explain the concept of embedded systems
 Discuss criteria for choosing a microcontroller
 Explain the variations of speed, packaging, memory, and
cost per unit and how these affect choosing a
microcontroller
 Explain the RISC and SISC Architecture

12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 2


 Microprocessor = CPU on a single chip.
▪ ALU + registers + control +…

 Micro-computer = small computer


▪ µP + I/O + memory + peripheral + …
 Microcontroller (uC)
▪ µ-Computer on a single chip of silicon

12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 3


General Purpose Microprocessors vs.
www. Micro Digital Ed. com
Microcontrollers BIHE university

• General Purpose Microprocessors


Data BUS

General Serial
IO
Purpose RAM ROM Timer COM
Port
Micro Port
processor Address BUS

Control BUS

• Microcontrollers

CPU RAM ROM

Serial
Timer I/O
Port

AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
www. Micro Digital Ed. com
µC base system BIHE university

• Small power consumption


• Single chip, small board
• Implementation is easy
• Low cost
• Can be used as Reconfigurable
Hardware
• µ C can reprogram on the fly(ISP)
AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
12/5/2020 Raafat S Habeeb 5
 A uP
▪ single-chip contained only CPU
▪ bus is available
▪ RAM capacity, num of port is selectable
▪ RAM is larger than ROM (usually)

 A uC
▪ single-chip contained CPU, RAM, ROM, Prepherals, I/O
port
▪ Communicate by port
▪ Internal hardware is fixed
▪ ROM is larger than RAM (usually)

12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 6


RISC vs. CISC

◼ CISC (Complex Instruction Set Computer)


◼ Put as many instruction as you can into the CPU
◼ Example Microprocessor 8086/8088
◼ Microcontroller 8051/8052
◼ It use a Von Neumann Architecture.
◼ RISC (Reduced Instruction Set Computer)
◼ Reduce the number of instructions, and use your
facilities in a more proper way.
◼ Example AVR Microcontroller Atmg328P which is used
in ARDUINO kit
◼ It use a Harverd Architecture.

AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
Von Neumann vs Harverd Architecture

AVR Microcontroller and Embedded System Using Assembly and C © 2011 Pearson Higher Education,
Mazidi, Naimi, and Naimi Upper Saddle River, NJ 07458. • All Rights Reserved.
 4K bytes internal ROM
 128 bytes internal RAM
 Four 8-bit I/O ports (P0 - P3).
 Two 16-bit timers/counters
 One serial interface

CPU RAM ROM


A single chip
I/O Serial
Timer COM Microcontroller
Port
Port

12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 9


External Interrupts

Interrupt 4k 128 bytes Timer 1


Control ROM RAM Timer 2

CPU

OSC Bus
4 I/O Ports Serial
Control

P0 P2 P1 P3 TXD RXD
Addr/Data
12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 10
 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)
 We may have External memory as data and code

12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 11


 meeting the computing needs of the task efficiently and
cost effectively
▪ speed, the amount of ROM and RAM, the number of I/O
ports and timers, size, packaging, power consumption
▪ easy to upgrade
▪ cost per unit
 availability of software development tools
▪ assemblers, debuggers, C compilers, emulator,
simulator, technical support
 wide availability and reliable sources of the
microcontrollers
12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 12
89XX ROM RAM Timer Int IO pin Other
Source
8951 4k 128 2 6 32 -

8952 8k 256 3 8 32 -

8953 12k 256 3 9 32 WD

8955 20k 256 3 8 32 WD

898252 8k 256 3 9 32 ISP

891051 1k 64 1 3 16 AC

892051 2k 128 2 6 16 AC

WD: Watch Dog Timer


AC: Analog Comparator
ISP: In System Programable

12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 13


8051
P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
Foot Print P1.3
P1.4
4
5
37
36
P0.2(AD2)
P0.3(AD3)
P1.5 6 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 8051 33 P0.6(AD6)
RST 9 (8031) 32 P0.7(AD7)
(RXD)P3.0 10 (8751) 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(8951)
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)

14 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


External Interrupts

Interrupt 4k 128 bytes Timer 1


Control ROM RAM Timer 2

CPU

OSC Bus
4 I/O Ports Serial
Control

P0 P2 P1 P3 TXD RXD
Addr/Data
12/5/2020 Raafat S Habeeb BIO Microprocessoe 2022 15
Important Pins (IO Ports)
 One of the most useful features = four I/O ports (P0 - P3)

 Port 0 :P0(P0.0~P0.7)
 8-bit R/W - General Purpose I/O ( Open Collector output )
 low byte address and data bus for external memory

 Port 1 :P1(P1.0~P1.7)
 Only 8-bit R/W - General Purpose I/O

 Port 2 :P2(P2.0~P2.7)
 8-bit R/W - General Purpose I/O
 high byte address for external memory

 Port 3 :P3(P3.0~P3.7)
 General Purpose I/O
 Timers(T0,T1) – ext. int (INT0, INT1) – Serial (TXD, RXD)- RD,WR

 Each port can be used as input or output (bi-direction)

16 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Port 3 Alternate Functions

17 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Important Pins
 PSEN’ (out): Program Store Enable
 Read for External Code Memory (active low)
 ALE (out): Address Latch Enable
 to latch address outputs at Port0 and Port2
 EA’ (in): External Access Enable
 to access external program memory 0 to 64K (active low)
 RXD,TXD: UART pins for serial I/O on Port 3
 Vcc(pin 40): +5V (3~5V for 89LV51)
 GND(pin 20): ground
 XTAL1 , XTAL2(pins 19,18)
 RST(pin 9):reset (active high)
18 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020
Basic Registers
 Accumulator ("A" register 8 Bits)
 Similar to Working register in PIC and Accumulator
in 8086/8088 microprocessor
 "R" registers ( 8 Bits)
 4 Banks of 8 registers each 8 bits
 "B" register 8 Bits
 Similar to A register
 Explicitly used by MUL AB and DIV AB
 Can also be used like 9th R register (only one B
register)

19 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Basic Registers
 Program Counter (PC)
 16 bits
 tells 8051 address of next instruction to be executed
 note length of instructions – some are 1 byte, others
are 2 and 3 bytes long. PC incremented according to
length of instruction code.
 PC not directly accessible

 Data pointer (DPTR)


 8051's only user accessible 16-bit register
 Points to external data memory
 Can be used to conveniently store 16-bit data that has
nothing to do with addresses.
20 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020
Basic Registers
 Stack Pointer (SP) 8 Bits
 The register used to access the stack is called SP (stack pointer)
register.
 Value pushed
 SP incremented
 Value stored
 Value popped
 Returns value
 SP decremented
 SP initialized to 07h on reset, i.e. first value pushed to 08h
 SP directly modified by six instructions:
PUSH, POP, ACALL, LCALL, RET, RETI
• The stack pointer in the 8051 is only 8 bits wide, which means that
it can take value 00 to FFh. When 8051 powered up, the SP register
contains value 07h.

21 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


8051 Registers
A
B DPTR

R0
DPH DPL
R1
R2 PC
R3
R4 Some 8051 16-bit Register
R5
R6
R7

Some 8-bit Registers of


the 8051
22 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020
Registers Reset Value

Register Reset Value

PC 0000

ACC 00

B 00

PSW 00

SP 07

DPTR 0000

RAM are all zero


Program Status Word (PSW)

24 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Types of Memory
• External Code Memory (64k)
• External RAM Data Memory (64k)
• Internal Code Memory
• 4k,8k,12k,20k
• ROM, EPROM, EEPROM
• Internal Data RAM
• First 128 bytes:
• 00h to 1Fh Register Banks
• 20h to 2Fh Bit Addressable RAM
• 30 to 7Fh General Purpose RAM
• Next 128 bytes:
• 80h to FFh Special Function Registers

25 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


On-Chip Memory Internal RAM

8052

26 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Bit Addressable Memory
2F 7F 78 20h – 2Fh
2E (16 locations  8-bits = 128 bits)
2D
2C Bit addressing:
2B
MOV C, 1Ah
2A
29 or
28 MOV C, 23h.2
27
26
25
24
1A
23
22 10

21 0F 08

20 07 06 05 04 03 02 01 00

27 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Summary of on-chip data memory
(RAM)
MOV C, 67H ≡ MOV C, 2CH.7

28 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Special Function Registers

❑DATA registers

❑CONTROL registers
❖Timers
❖Serial ports
❖Interrupt system
❖Analog to Digital converter
❖Digital to Analog converter Addresses 80h – FFh
❖Etc.
Direct Addressing used to
access SFRs

29 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


Summary of on-chip data memory (SFRs)

30 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020


31 Raafat S Habeeb BIO Microprocessoe 2022 12/5/2020
SELF STUDY
Reference Book: The 8051 Microcontroller and Embedded
Systems Using Assembly and C
BY: Mhammad Ali Mazidi
Chapter 1 from Pages 24-29
Chapter 2 Sec 2.4, 2.6, and 2.7
Chapter 5 Sec 5.3, and 5,4
Exercise Problems on pages 33,34
2- Pages 65,66 Problems
23,26,27,32,36,41,43,45
Raafat S Habeeb BIO
32 Microprocessoe 2022 12/5/2020

You might also like