Professional Documents
Culture Documents
8051
By
Siddhasen R Patil
Microcontroller 8051
Agenda
1. Features
2. Architecture
3. On chip Memory
4. Special Function Register
5. I/O Ports
6. Timer
7. Serial Interface
8. Interrupt
9. Power On Reset
10. Power Saving Modes
Features of 8051
Microcontroller 8051
Features:
1) 8-bit microcontroller
2) Operating speed 12MHz
3) Four 8-bit I/O Ports
4) Two 16-bit Timers
5) UART with variable baud rate
6) 128 Bytes RAM
7) 4K Bytes EPROM
8) 5 Interrupt Sources
9) Two Power Control Modes
10) Ideal Mode
11) Power down Mode
Features:
1) 8 bit Microcontroller
-ALU performs 8 bit operation on either Arithmetic
or Logical operation
- Internal Data bus is of 8-bit
8-bit 8-bit
8-bit
Features:
8051
2) Operating speed
- 8051 operates on 12MHz
- On chip Oscillator XTAL2
XTAL2
Features:
8051
2) Operating speed
- 8051 operates on 12MHz
- On chip Oscillator Xtal2
Xtal2
Features:
3) Four 8-bit I/O Ports
- All ports Bidirectional
- Each bit consist latch, input buffer and output driver
Port2 Port0
` Port3 Port1
Features:
4) Two 16-bit Timers
- Two 16-bit Timer/Counter Registers
- Both Timers Operates Separately any one mode
out of 4 Modes
- Both Timers/Counter Interrupts µC on Terminal Count
TxD
RxD
Features:
6) 128 Bytes of internal On Chip RAM
- 4 Register Bank (Each bank is of 8 Register)
- Bit addressable locations 20h to 27H
- Remaining part of Memory can use as scratch pad memory
7F
Scratch Pad
Memory
28
Bit Addressable 20 to 27
Register Bank0 1F
to Bank3
00
Features:
7) 4K Bytes EPROM
- User can use either 4KB Internal Memory
with 60KB External or 64KB External Memory
- To distinguish either Internal or External Memory
EA pin is used
8051
EA Address
64KB
EPROM
4KB Data
ROM
Features:
8) 5 Interrupt Sources
- Two External Interrupts i.e. INT0 and INT1
- Two Interrupts from Timer 0 and Timer 1
- One Interrupt by UART
8051
INT 0
TF0
INT 1 TF1
RI or TI
Features:
9) Two Power Control Modes
- Ideal Mode (oscillator runs UART, Interrupt, and Timer blocks),
but clock signal gated off to the CPU
- Power Down Mode (Oscillator frozen)
Features:
9) Two Power Control Modes
- Ideal Mode (oscillator runs UART, Interrupt, and Timer blocks),
but clock signal gated off to the CPU
- Power Down Mode (Oscillator frozen)
Architecture of 8051
Microcontroller 8051
Architecture:
1) 128 Byte on chip data memory
2) Special function register
3) Four 8-bit I/O Port
4) Timers and counters
5) Serial Interface
6) Interrupts
7) Reset
8) Power Saving Modes
Architecture
Onchip Memory of 8051
On chip Memory
1) 128 Byte on chip data memory
On chip Memory
2) Special function register
- The register in between memory location 80H to FFH are use as a SFR
- The unused locations are shown by blank and must not be used by 8051 programmer.
Special Function Register
Accumulator: 8 bit Register
B Register: Use during Multiply and Divide operation
Programmable Status Word: Contains Program Status Information
Special Function Register
Stack Pointer:
- Points Stack Memory.
- Increment during PUSH operation and decrement during
POP operation.
- Initialized 07H after reset so Stack memory starts from 08H.
Data Pointer (DPTR):
- Consist of High (DPH) and Low (DPL) Byte.
- Holds 16 bit address of external memory.
Port Registers (P0 , P1 , P2 , P3):
- P0 to P3 are SFR latches of ports P0 to P3 respectively.
Serial Data Buffer:
- These are two separate register i.e. Transmit Buffer and Receive Buffer.
- When data moved to SBUF it goes to Transmit Buffer.
- When data moved from SBUF it comes from Receive Buffer.
Timer Register:
- These are 16-bit counter register.
Control Registers:
- IP, IE, TMOD, TCON, SCON, PCON contains control and status bits.
I/O Port
Four 8-bit I/O Port
Port0 and Port2 are also used to access external memory
Port3 pins are multifunction that are listed below
Timer/Counter0 External
P3.0 RxD Serial input Pin P3.4
Input
Timer/Counter1 External
P3.1 TxD Serial output Pin P3.5
Input
Wr External Memory Write
P3.2 Int0 External Interrupt0 P3.6
Strobe
Rd External Memory Read
P3.3 Int1 External Interrupt1 P3.7
Strobe
I/O Port
Port 0
All 8 pins can be used either Input or Output
Need to connect external Pull-up resistor since P0 is an Open drain port
Vcc
10K
8051
Port 0
I/O Port
Port 0
- To make Port0 as a input port, port must be programmed by writing ‘1’
to all bits.
I/O Port
Port 0
- To make Port0 as a input port, port must be programmed by writing ‘1’
to all bits.
- What happened if we write ‘0’ before reading ?
- Port0 is also used to access external memory
I/O Port
Port 1
- All 8 pins can be used either Input or Output.
- Need not to connect external Pull-up resistor since P1 has internal
pull up resistor.
- To make Port1 as a input port, port must be programmed by writing ‘1’ to all bits.
I/O Port
Port 2
- All 8 pins can be used either Input or Output.
- Need not to connect external Pull-up resistor since P1 has internal
pull up resistor.
- Port 2 is also used to access external memory
I/O Port
Port 3
- All 8 pins can be used either Input or Output.
- Need not to connect external Pull-up resistor since P1 has internal
pull up resistor.
- Port 3 has some additional functions like RxD, TxD, Int0, Int1, T0, T1,
Wr, and Rd.
Timer/Counter
- 8051 has two 16 bit Timers (Timer0 and Timer1)
- Both can be operated either as Timer or event Counter
- In Timer function Timer counts machine cycle
- So Timer increments by1 after every 12 oscillator cycle (1/12)
- In Counter function Counter increments by 1 in the response
to 1-to-0 transition at external input pin i.e. T0 or T1.
- Timer/Counter operates in 4 different modes
1) Mode0 – 13 bit Timer Mode
2) Mode1 – 16 bit Timer Mode
3) Mode2 – 8 bit Auto-Reload Mode
4) Mode3 – Split Timer Mode
Timer/Counter
Timer Mode Control Register
MSB LSB
Gate1 C/T1 M1 M0 Gate0 C/T0 M1 M0
Timer 1 Timer 0
Gatex: Allows the Timer to control by external input Intx.
C/Tx: To Select Timer or Counter Operation.
M1 & M0: To select mode out of 3 Modes.
8051 8051
TxD RxD
RxD TxD
MSB LSB
SM0 SM1 SM2 REN TB8 RB8 TI RI
Osc. Frequency
Baud Rate =
12
Serial Interface
Operating Modes:
Mode 1:
- 10 bits are transmitted or received
- a start bit (0), 8 data bit (LSB first), and one stop bit (1).
- Variable Baud rate using Timer 1(Mode 2 i.e. Auto reload mode).
Interrupt Sources
TF0
Interrupt Sources
TF1
Architecture
6) Interrupts
- Serial Interrupt generated by logical OR TI and RI of Serial Port
Control register.
- Both TI and RI flags are set by serial control hardware on valid data bits
transmitted or received in SBUF register.
TI
Interrupt Source
RI