Module 1 - Introduction - Microcontroller 8051 - EE6603 - v1
Module 1 - Introduction - Microcontroller 8051 - EE6603 - v1
and Applications
COURSE CODE: EE6603, CREDITS: 3-0-0-3
Faculty
Dr. Arunangshu Ghosh Department of Electrical Engineering
1 NIT Patna
Course Outcomes
▶ Objectives: Microcontrollers are everywhere available in versatile configurations, and may be used as tool
for different kind of applications in real time environment. This course introduces a microcontroller; 8051,
Architecture, Instruction set, Addressing mode, Interfacing and Programming. Further development of hardware
interfaces for different applications is an essential objective. Use of assembler directives and programming in
assembly language using Assembler MASM/ TASM and C is included in the course.
▶ Pre requisite: Digital Electronics, Microprocessors and Applications.
▶ Outcome: After study of this course, the students will be able to:
1. Acquire basic concepts of microprocessor microcontroller 8051
2. Identify different blocks of digital hardware required for microcontroller-based design
3. Develop and analyze microcontroller-based circuits and programs for different applications
4. Develop software and use software tools for microcontroller-based systems
5. Interface peripheral ICs and devices with microcontroller
6. Design and develop interfaces for measurement and instrumentation, process control and write programmers for
different applications
Objective
▶ To understand and carry out the following aspects for Microcontroller 8051
▶ Architecture
▶ Pin configuration
▶ Instruction Set
▶ Programming
▶ Interfacing
▶ System development
▶ The methodology of teaching is aimed to arm students to handle any
microcontrollers of recent days.
DETAILED SYLLABUS
Unit 1. Introduction: Microprocessors and Micro-controllers, External memory, Processor Architecture – Harvard v/s
Princeton; CISC v/s RISC. 2 Lectures
Unit 2. The 8051 microcontrollers: Features, 8051 Architecture, RAM organization, ROM structure, Hardware
Features: 8051 – Device packaging, Chip technology, Power considerations, Reset, System clock/oscillators, brief
discussion on Parallel I/O, Timers, Interrupts, Serial I/O, Pin configuration. 10 Lectures
Unit 3. Instructions Set and programming of 8051: Brief description of assemblers, linkers and loaders, types of
instructions, instruction size, addressing modes, Assembly language Programming using Simulator, Instruction set –
data movement; arithmetic; bit operators; branch, Software development tools like assemblers; simulators; cross-
compilers, Output file formats, programming examples. 10 Lectures
Unit 4. Timers and counters in 8051: Features, architecture and block diagram, Timer modes, states, timing
generation and event counting, different techniques to generate delays, programming examples and applications.
4 Lectures
Unit 5. Serial communication: Introduction to serial communication, Features of serial communication in 8051, serial
communication modes, programming examples, different techniques to of serial communication using interrupts and
polling technique, programming and applications. 4 Lectures
Unit 6. Interfacing IO devices with 8051: Interfacing of LEDs, Push Buttons, Relays, Latch connections, ADC, DAC,
Seven Segment display, LCD displays, Keyboards, Stepper motors, Interfacing problems and programming.
8 Lectures
Unit 7. Introduction to advanced microcontrollers: Introduction to PIC, and ARM based microcontrollers; Features
and Applications. 2 Lectures
Suggested Readings
Text Books:
1. Kenneth J. Ayala, The 8051 Microcontroller - Architecture, Programming, And Applications, Thomson
Delmar Learning, 2007
2. Muhammad Ali Mazidi, Janice G. Mazidi, Rolin D. McKinlay, The 8051 Microcontroller and Embedded
Systems, Pearson Education
3. Scott Mackenzie, The 8051 Microcontroller, Pearson Education
Reference Books:
1. M. Predko, Programming and Customizing the 8051 Microcontroller, TMH.
2. John B. Peatman, Design with PIC Microcontrollers, Pearson.
3. John Catsoulis, Designing Embedded Hardware, Shroff. Pub. and Distr.
4. John. B. Pitman Design with Micro-controllers, Mc-Graw Hill
Assessment Pattern (100 Marks)
7
8 A microcomputer system
ADDRESS BUS
CONTROL BUS
CPU
ROM RAM Interfacing Circuits
(Microprocessor)
IO and other
peripheral devices
(Timers, UART, KBDC,
Interrupt controllers,
DATA BUS
9 Microprocessors
ALU
ACCUMULATOR
PROGRAM
STACK POINTER
COUNTER REGISTERS
IO PORTS
TIMER/COUNTER
ALU
ACCUMULATOR IO PORTS
REGISTERS
INTERNAL SERIAL IO PORT
ROM
INTERNAL RAM
INTERRUPT
CIRCUITS
STACK POINTER
IC name Features
8031 0 Byte ROM, 128 Byte RAM, 2 – 16 bit counters
8032 0 Byte ROM, 256 Byte RAM, 3 – 16 bit counters
8051 4K Byte MROM, 128 Byte RAM, 2 – 16 bit counters
8052 8K Byte MROM, 256 Byte RAM, 3 – 16 bit counters
8751 4K Byte EPROM, 128 Byte RAM, 2 – 16 bit counters
8752 8K Byte EPROM, 256 Byte RAM, 3 – 16 bit counters
8951 4K Byte Flash ROM, 128 Byte RAM, 2 – 16 bit counters
8952 8K Byte Flash ROM, 256 Byte RAM, 3 – 16 bit counters
17 8051 Microcontroller Features
First member of MCS51 family of Intel microcontrollers
40 pin, +5V single supply, 1-16 MHz
Harvard Architecture
4K factory masked ROM, 128 Byte RAM
4 Nos of 8 bit IO ports
2 nos of 16 bit timers
Serial Interface (USART)
64K external code memory space
64K external data memory space
Operates on single bits
210 bit addressable locations available
4 µs Multiply/Divide facility
ARCHITECTURE
of
18
Intel 8051
Architecture Block
Diagram
19 of 8051
Internal ROM and RAM
I/O Ports with programmable pins
Timers/counters modules
Serial data communication modules
Eight bit CPU with registers A (Accumulator) and B
Sixteen bit program counter (PC) and Data pointer
(DPTR)
Eight bit program status word (PSW)
Eight bit stack pointer (SP)
Internal ROM or EPROM (8751) of 0 (8031) to 4K (8051)
Internal RAM of 128 Bytes:
Four register banks each containing 8 registers
Sixteen bytes, which may be addressed at bit level
Eighty bytes of general purpose data memory
32 I/O pins arranged as 4 eight bit ports P0-P3
Two 16 bit timers/counters
Full duplex serial data receiver/transmitter: SBUF
Control registers TCON, TMOD, SCON, PCON, IP, and IE
Two external and three internal interrupt sources
Oscillator and clock circuits
Programming
model
20 of 8051
• ‘*’ indicates the register is
both byte and bit
addressable
• The registers of 8051 can be
identified by their 8 bit
internal address
• Program counter PC do not
have internal 8 bit addresses
assigned to it
• DPTR as a 16 bit register is
not assigned any internal
address. However DPH and
DPL have their internal 8 bit
address
Pin configuration
Four eight bit ports are available; P0, P1, P2, P3.
The pins of each port are marked by Px.y (P3.0:
port 3 pin 0). Thus 32 pins may be used for I/O
purpose
Port 0 can also act as 8 bit multiplexed address
data bus when external memory is connected
Port 1 is a dedicated I/O port
Port 2 is again multifunctional with IO function
and can also be used to provide higher order
address when external memory is connected.
Port 3 can be used as an IO port. It can also be
used to provide pins to the external world for
interrupt, timers, USART and memory controls
Rest of the pins are for connecting crystal, power
supply, ground, enabling external ROM access,
ALE and EA-bar signals
21
8051 oscillator and clock
22
23 Program counter (PC)
Points to the 16 bit memory address (internal or external) from where next
instruction word has to be fetched.
Auto-increments after each and every code fetch operation
Is not under programmers’ control.
The status of EA-bar pin affects the operation of memory selection as
follows:
If EA-bar is tied high (disabled state):
Internal ROM will be considered for code fetch if address range in PC is (0000H – 0FFFH)
If PC address is in range (1000H-FFFFH) then external ROM will be selected for code
fetch
PORT 0
Can be configured as input-output port
If used as an output port, external pull-up resistance must be connected between port
pins and supply to allow valid logic states to appear as output information on the
concerned port/port pins .
Best use as an input port/pin
If external memory is connected, port 0 pins can be used as lower order address-
data multiplexed pins (AD7-AD0)
Internal circuitry of port 0 determines how the pins should behave depending on
the instruction to be executed, memory pointers used, value of address and
status of 𝐸𝐴 signal.
• When data transfer operation is required:
• Input Pin: Port 0 Circuit
• If D=1
33 • Then:
• Q-bar=0
• Both T1 and T2 OFF
• Thus Pin0.x floats and acts as input
pin
• The pin status may be read when
“Read pin data” signal is activated
internally
• Output Pin:
• An external pull-up resistance must be
connected between Pin 0.X and Vcc, so that
pins of port 0 provides a stable voltage output
• If D=1
• Then:
• Q-bar=0
• Both T1 and T2 OFF
• But Pin0.x will produce valid logic
HIGH state if the external pull-up
resistor is connected
• P0.X=HIGH
• If D=0
• Then:
• Q-bar=1
• T1 OFF and T2 ON
• Thus Pin0.x will produce valid logic
LOW state if external pull-up resistor
is connected
• P0.X=LOW
• The best use of PORT0 is as an input port
34 Port 0 Circuit: Address output operation
• When an external memory has to be connected t0 8051,
PORT0 pins will be used to provide lower order address/data
to port 0 pins
• When address output to external memory operation is
selected:
• No external pull-up resistance is required
• Internal control signals switch the address lines to the
gates of the FET:
• If D=1
• Then:
• Q-bar=0
• T1 ON and T2 OFF
• Thus Pin0.x will produce logic HIGH
• If D=0
• Then:
• Q-bar=1
• T1 OFF and T2 ON
• Thus Pin0.x will produce logic LOW
• After address status is provided on port 0 pins ALE pin
status will change accordingly.
• After ALE again goes low the pins of port 0 are turned
around to be data pins again.
• To read data, internal control logic sets the port pins to
logic -1 (configured as input).
• To write data port latches will supply required logic
states to be written to external memory connected.
35 PORT 1 Circuit
36 PORT 2 Circuit
PORT 3 Circuit
37