0% found this document useful (0 votes)
64 views82 pages

Architecture and Hardware Lec

The document discusses an introduction to the 8051 microcontroller. It provides details on the 8051 architecture and hardware components, including its 4 I/O ports, RAM, special function registers, and alternate functions of port pins. The document also compares microprocessors and microcontrollers, listing common manufacturers of each.

Uploaded by

Muhammad Bilal
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)
64 views82 pages

Architecture and Hardware Lec

The document discusses an introduction to the 8051 microcontroller. It provides details on the 8051 architecture and hardware components, including its 4 I/O ports, RAM, special function registers, and alternate functions of port pins. The document also compares microprocessors and microcontrollers, listing common manufacturers of each.

Uploaded by

Muhammad Bilal
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/ 82

Microcontroller Based Design

Dr. Mohsin Tiwana


Week 2 – 8051 Microcontroller

Architecture and Hardware

2 Dr Mohsin Tiwana
Course Outline
S/no. Topic
1 Introduction
8051Microcontroller
2
 Architecture and Hardware
3  Assembly Language
4  Assembly Language Contd.
5  Timers and Counters
6  Serial Port
7  Interrupt
8  Design and Interface Examples
Arduino Microcontroller
9

PIC 18 F Microcontroller
10
 Introduction, Architecture, I/O Pins
11  Programming in C

12  Timers / Counters
13  Using Internal ADC of PIC
14  Peripherals of PIC 18F Microcontrollers
15 RTOS/ FPGA
3
Organization
 Microprocessors and Microcontrollers
 Introduction

 8051 Microcontroller
 Introduction
 Architecture
 Hardware
 Port Internal Structure
 RAM
 Special Function Register

4
Today we will learn

 What is a microprocessor?

 What is a microcontroller?

 What are the differences between both?

 Which one is better?

5
What is a Microprocessor
 A Microprocessor is the Central Processing Unit (CPU) of
a computer constructed within a single chip

 To make a complete Microcomputer, it needs to be


connected to
 Memory to store data and programs
 RAM
 ROM
 Input / Output devices to communicate with surroundings
 Control Circuits

6
Microprocessor
Introduced in 1971

 Intel 8080
 Motorola 6800
 RCA 1801
 Zilog Z80

7
Inside CPU
 Registers
 Temporarily store information
 Could be 8/ 16 / 32 bit
 Bigger the register size, better the CPU. But cost increases with
increase in number of bits
 ALU
 Performs arithmetic and logical functions e.g. Sum, AND, NOT etc
 Program Counter (PC)
 Points to the address of next instruction to be executed
 Contents of PC are placed on address bus to fetch the desired
instruction
 Instruction Decoder
 To interpret the instruction fetched into CPU

8
Inside CPU

9
Execution of an Instruction
Fetch / Execute Cycle – The operations to execute an instruction are
 Contents of PC are placed on the Address Bus
 A Read Control Signal is activated
 The data (or Op code) are read from memory and placed on data
bus
 The op code is latched into CPU internal instruction register
 PC is incremented to prepare for next fetch from memory

10
Execution of an Instruction
 After performing 1 fetch / execute cycle, computer
repeats this procedure forever – this is all computer does

 Important Note: Sequencing is all done automatically by


processor’s Control Unit
 All the programmer has to do is to put the list of instructions in
memory and set the PC to point to the first instruction

11
What is a Microcontroller?
 A Microcontroller is a microcomputer in a single chip

 Microcontroller is microprocessor plus memory plus IO


devices plus control circuits, all integrated in a chip

12
Microcontroller

13
Microcontroller
 A microcontroller can be as powerful as far larger
machines of few years ago

 There are many more embedded microcontroller based


systems in the world than PCs

 A ready made processor + IO + Memory + Control Circuits

14
Common Microcontroller Manufacturers
 AMCC
 Altera
 Analog Devices
 Atmel
 Charmed Labs
 Cypress Semiconductor
 Dallas Semiconductor
 ELAN Microelectronics Corp.
 Energy Micro AS
 EPSON Semiconductor
 Freescale Semiconductor
 Fujitsu
 Holtek
 Infineon
 Intel
 Lattice Semiconductor
 Microchip Technology

15
http://en.wikipedia.org/wiki/List_of_common_microcontrollers
Common Microcontroller Manufacturers
 National Semiconductor
 NEC
 Parallax
 NXP Semiconductors
 Rabbit Semiconductor
 Renesas Electronics
 SiLabs
 Silicon Motion
 Sony
 STMicroelectronics
 Texas Instruments
 Toshiba
 Ubicom
 Xemics
 Xilinx
 ZiLOG

16
http://en.wikipedia.org/wiki/List_of_common_microcontrollers
17
Choosing a Microcontroller
1. Meeting computing needs of the task efficiently
 Speed
 Power consumption
 RAM and ROM
 Number of I/Os
 Cost

2. How easy is it to develop product around it


 Availability of assembler, a code efficient C language
 Debugger, simulator or emulator

3. Readily available in market or not?

18
Microprocessor Vs Microcontroller

Microprocessor Microcontroller

 Chip does not have RAM,  Chip has RAM, ROM,


ROM, timer etc. Requires timer etc. Requires no
additional circuitry additional circuitry
 High power requirement  Low power requirement
 Operates on small
 Operates on large volume volumes of data bit and
of nibble, byte and word byte
 No bit addressing  Can address bits
 Faster  Slower
 More number of pins  Less number of pins
19
8051 Microcontroller

20
Microcontroller
 Intel – 1976
 8748 (MCS 48 Family)
 1700 transistors
 1 kB EPROM
 64 bytes RAM
 27 I/O lines
 8 bit timer

 Used as a video game console and in IBM PC keyboard

21
Microcontroller
 Intel – 1979
 MCS 41 Family
 2 kB of program memory
 128 bytes of data RAM
 40 pin package
 8 bit timer

 Used in keyboard and for simple applications

22
Microcontroller
 Intel – 1980
 8051 (MCS 51 Family)
 60,000 transistors
 4 kB ROM
 128 bytes of RAM
 32 I/O lines
 Two 16 bit timers
 Serial Port
 64 K External Code Memory Space
 64 K External Data Memory Space

Harvard architecture, complex instruction set computer (CISC) instruction set

23
Various 8051 Manufacturers
Over 1000 versions of 8051

 Intel
 Atmel
 Dallas
 AMD
 Infineon
 SiLabs
 Philips
 Seimens
 And many more

24
8051 by Atmel
 AT89C51
 Flash memory
 Electrical ROM burner required to
 Erase and
 Program
 Fast erasing as compared to UV erase which took around 20
minutes
 AT89C51-12PC by Atmel
 AT stands for Atmel
 C for CMOS – low power consumption
 12 indicates frequency of 12 Mhz
 P for Plastic DIP package
 C for commercial (for military M is used instead of C)
25
Block Diagram 8051

26
Detailed Block Diagram - 8051

27
Detailed Block Diagram - 8051

External interrupts
On-chip Timer/Counter

Interrupt ROM for


On-chip Timer 1 Counter
Control program
code RAM Timer 0 Inputs

CPU

Bus Serial
4 I/O Ports
OSC Control Port

P0 P1 P2 P3 TxD RxD
Address/Data

28 Block Diagram
Pin Description 8051

29
Pin Configuration
Pin Description 8051
 4 IO Ports
 Port 0 (P0.0 to P0.7)
 Port 1
 Port 2
 Port 3

 Vcc – 5 volts
 Vss – Gnd

 Oscillator
 XTAL1
 XTAL2

30
Pin Description 8051
 4 IO Ports
 Port 0 (P0.0 to P0.7)
 Port 1
 Port 2
 Port 3

 Vcc – 5 volts
 Vss – Gnd

 Oscillator
 XTAL1
 XTAL2

31
8051 Hardware
Alternate Functions - Port 3

 Serial Port
 P3.0 : Serial Input (RXD)
 P3.1 : Serial Output (TXD)

 External Interrupt
 P3.2 : External Interrupt 0 (INT0)
 P3.3 : External Interrupt 1(INT1)

 Timers / Counters
 P3.4 : Timer 0 External Input
 P3.5 : Timer 1 External Input

32
8051 Hardware
Alternate Functions - Port 3

 Serial Port
 P3.0 : Serial Input (RXD)
 P3.1 : Serial Output (TXD)

 External Interrupt
 P3.2 : External Interrupt 0 (INT0)
 P3.3 : External Interrupt 1(INT1)

 Timers / Counters
 P3.4 : Timer 0 External Input
 P3.5 : Timer 1 External Input

33
8051 Hardware
Special Pins

 ALE /
 Address Latch Enable
 Used to access external memory
 ALE = 1 for latching address on P0
 ALE = 0 for using P0 as data

 .
 Program Store Enable
 Output pin connected to
external memory (if used)

34
8051 Hardware
Special Pins

 .
 External Access Enable
 Should be strapped to Vcc for
internal memory usage
 EA = 1 for internal code
 EA = 0 for external code

35
8051 Hardware
Special Pins
 Oscillator (XTAL1 & XTAL2)
 Crystal 11.059 Mhz available
 Use following circuit

C1 = C2 = 30 pF ± 10 pF for crystals
33 pF easily available
36
8051 Hardware
Special Pins

 Reset Pin
 Normally 0
 1 to reset the controller
 Reset High must have a
minimum duration of two
machine cycles
 Following circuit may be
used

37
8051 Hardware
 Reset Pin

Reset Circuit
38
8051 Hardware

Hardware Considerations

 Buffers
 To provide current on IO pins
 To avoid loading on microcontroller
 Bidirectional Buffer on ports
 Ports are bidirectional
 Used for Input as well as Output

39
8051 Hardware
Hardware Considerations
 Port 0 Requires external Pull Up

Vcc
10
K
P0.0

Port
8051
0
P0.7
SIP Resistor Bank is locally
available
40
Why Pull-up Resistor on Pin 0

41
Pin Abs Ratings

SELF ASSIGNMENT: study the data sheet to see if the 3.3V logic high
and low output levels met the 5V logic high and low input levels.
8051 Hardware

Good Hardware Practice – Make Generic Board

 Connectors
 Voltage Regulator
 LEDs on all IO Ports (SIP LED Banks locally available)
 Buffers
 40 Pin Base / Ziff

43
Port Internal Structure

44
Output (Low)

45
Output (High)

46
Port as Input

47
Input (High)

48
Input (Low)

49
Port as Input without setting it High - Damage

50
Avoid Damaging the Port

51
Memory

52
Memory
 Internal On-Chip Memory
 Internal RAM (Data)
 Register Banks
 Bit Addressable Memory
 General Purpose Storage
 Accumulators
 Accumulators
 Special Function Registers
 Internal ROM (Code)
 Look-up tables can also be saved

 External Memory
 ROM (External Code Memory)
 RAM (External Data Memory)

53
Internal
Memory

54
Internal
Memory
General Purpose
RAM

Bit-Addressable
Locations

Register Banks

55
Register Banks

 4 Register Banks
 At a time only 1 Register Bank is active

56
Bit Addressable RAM

 Bits can directly be accessed


 Read bits
 Write
 0
 1

What if bits are not directly


accessible?

57
General Purpose RAM

58
Special Function
Registers

59
Special Function Registers

60
Special Function Registers
P0 – Port 0
 Address: 80h
 Bit-Addressable
 Each bit corresponds to
pin of the port
 Writing 1 to a bit will
set the corresponding
pin HIGH and vice
versa

61
Special Function Registers
SP – Stack Pointer
 Address: 81h
 Points to current stack
location
 Modified (automatically)
by instructions
 PUSH
 POP etc

62
Special Function Registers
PCON – Power Control
 Address: 87h
 To control power modes
 Certain modes allow 8051
to go in ‘Sleep’ mode
which requires less power

63
PCON

o SMOD – Doubles the baud rate of Serial Port


o GF1 – General Purpose Flag Bit 1
o GF0 – General Purpose Flag Bit 0
o PD – Power Down; sets the power down mode, only
exit is Reset
o IDL – Idle Mode; activates Idle Mode, only exit is
Interrupt or Reset

64
PCON
Power Down Mode
 Instruction that sets PD will be the last instruction that
will be executed before entering Power Down Mode
 Clock to CPU, Interrupt, Timer and Serial Port is cut off
 On-chip RAM contents are retained
 Port Pins retain their logic level
 Only exit is system reset
 Vcc can be as low as 2 volts

65
PCON
Idle (or Sleep) Mode
 Instruction that sets IDL will be the last instruction that
will be executed before entering Idle Mode
 Clock to CPU is cut off but not to Interrupt, Timer and
Serial Port is cut off
 On-chip RAM contents, CPU status and registers are
retained
 Port Pins retain their logic level
 Exit when either
 Interrupt or
 Reset

66
Special Function Registers
TCON – Timer Control
 Address: 88h
 Bit addressable
 Controls timers
 Run
 Stop
 Flags to indicate overflow

67
Special Function Registers
TMOD – Timer Mode
 Address: 89h
 Configures modes of
timers
 16 bit
 13 bit
 8 bit

68
Special Function Registers
TL0 / TH0 – Timer 0 Bytes
 Address: 8Ah / 8Ch
TL1 / TH1 – Timer 1 Bytes
 Address: 8Bh / 8Dh

 Both bytes make a 16 bit


number
 Value of Timer

69
Special Function Registers
P1 – Port 1
 Address: 80h
 Bit-Addressable
 Each bit corresponds to
pin of the port
 Writing 1 to a bit will
set the corresponding
pin HIGH and vice
versa

70
Special Function Registers
SCON – Serial Control
 Address: 98h
 Bit-Addressable
 Controls the on-chip
Serial Port

71
Special Function Registers
SBUF – Serial Buffer
 Address: 99h
 Used to receive or
transmit the data through
serial port
 Value stored in SBUF is
transmitted
 Value received by serial
port is stored in SBUF

72
Special Function Registers
P2 – Port 2
 Address: A0h
 Bit-Addressable
 Each bit corresponds to
pin of the port
 Writing 1 to a bit will
set the corresponding
pin HIGH and vice
versa

73
Special Function Registers
IE – Interrupt Enable
 Address: A8h
 Used to enable (or
disable) specific
interrupts
 A bit for every interrupt
 0 means interrupt
is disabled
 1 means interrupt enable
 Global Enable
 1 = interrupts enabled
according to the corresponding bits
 0 = means all interrupts disabled
(irrespective

74
Special Function Registers
P3 – Port 3
 Address: B0h
 Bit-Addressable
 Each bit corresponds to
pin of the port
 Writing 1 to a bit will
set the corresponding
pin HIGH and vice
versa

75
Port 3 – Alternate Functions
 Multiplexing on Port 3 i.e. more than 1 functions on each
pin

76
Special Function Registers
IP – Interrupt Priority
 Address: B8h
 Bit-Addressable
 Defines priorities of
interrupts
 2 interrupt priority levels
 Interrupt priority may be
 Low – 0 in corresponding
IP bit
 High – 1 in corresponding
IP bit

77
Special Function Registers
PSW – Program Status Word
 Address: D0h
 Bit-Addressable

 Contains important
bits and flags
(detail on next slides)

78
Program Status Word (PSW)

79
Overflow Flag
 OV = 1 IF there is
 Carry from Bit 6 to 7
OR
 Carry from bit 7 to 8

 OV = 0 IF there is
 No carry out
OR
 (Carry from bit 6 to 7) AND (carry from bit 7 to 8)

WHY?

80
Special Function Registers
ACC – Accumulator
 Address: E0h
 Bit-Addressable

 One of the most used


registers. Used by many
instructions

81
Special Function Registers
B – B Registar
 Address: F0h
 Bit-Addressable

 Used for
 Multiplication
 Division

 Also used as an auxiliary


register to temporarily store values

82

You might also like