Professional Documents
Culture Documents
8051
Microprocessors:
General-purpose microprocessor
CPU for Computers No RAM, ROM, I/O on CPU chip itself ExampleIntels x86, Motorolas 680x0
Many chips on mothers board
Data Bus
RAM
ROM
I/O Port
Timer
Microcontroller :
A smaller computer On-chip RAM, ROM, I/O ports... ExampleMotorolas 6811, Intels 8051, Zilogs Z8 and PIC 16X
CPU
RAM ROM
A single chip
I/O Port
Serial Timer COM Port Microcontroller
Advantages over mp
Cost is lower Standalone mp never used memory, I/O, clock necessary For mp- large size PCB Large PCB- more effort and cost Big physical size More difficult to trouble shoot mp based A mc is a mp with integrated peripherals.
Advantages of mc
Low cost Small size of product Easy to troubleshoot and maintain More reliable Additional mem, I/o can also be added Software security feature All features available with 40 pins. Useful for small dedicated applications and not for larger system designs which may require many more I/O ports. Mostly used to implement small control functions.
Block Diagram
External interrupts Interrupt Control On-chip ROM for program code
Timer/Counter
On-chip RAM
Timer 1 Timer 0
Counter Inputs
CPU
Serial Port
OSC
Bus Control
4 I/O Ports
P0 P1 P2 P3
TxD RxD
Address/Data
8051 (8031)
Starting 32 bytes of RAM general purpose reg, divided into 4 register banks of 8 registers each. Only one of these bank accessible at one time. RS1 and RS0 of PSW used to select bank.
P0-P3 port latches SP, PSW, IP Interrupt Priority, IE enable TCON timer/counter control reg to turn on/off the timers, interrupt control flags for ext. int like INT1 and INT0 TMOD modes of operation of timer/counter SCON serial port mode control reg SBUF serial data buffer for transmit and receive PCON Power control reg power down bit, idle bit
Registers
A B R0 R1 R2 R3 R4 R5 R6 R7 PSW (8) Some 8-bitt Registers of the 8051 SP (8) Some 8051 16-bit Register hold addresses DPTR DPH DPL
PC
PC
8051 features
Internal ROM 4K, RAM 128bytes Thirty two I/O pins as 4 8 bit ports P0 P3 Two 16 bit timer/counters T0 and T1
Full duplex serial data receiver/trans. SBUF
Control registers TCON, TMOD, SCON, PCON, IP and IE Two external and three Internal Interrupt sources Oscillator and clock circuits
PCON
Idle mode oscillator, serial port, interrupt, timer blocks are active but clock disabled. Can be terminated with INT or reset Power down mode on-chip osc stopped. RAM contents preserved. Hardware reset Two general purpose flags and a double baud bit.
TMOD Register:
TCON Register:
TF1: Timer 1 overflow flag. TR1: Timer 1 run control bit. TF0: Timer 0 overflag. TR0: Timer 0 run control bit. IE1: External interrupt 1 edge flag. IT1: External interrupt 1 type flag. IE0: External interrupt 0 edge flag. IT0: External interrupt 0 type flag.
Memory addressing
Intermediate results, variables, const 4KB internal from 0000 0FFFH 64KB external with PSEN, till FFFFH Internal external difference PSEN 64KB of external with DPTR signal Internal memory two parts - 128 bytes Internal RAM and secondly set of addresses from 80-FFH for SFRs 128 bytes from 00 7FH direct or indirect SFR addresses only direct addressing mode
Memory Addressing
Lower 128 bytes in three sections
00-1F 32 bytes 4 banks 00,01,10,11 each containing 8 registers of 8 bits each. Only one accessible at a time with PSW bits. 20-2FH 16bytes is bit addressable with addresses 0F to 7FH, 20.7 or 20.0, or 0-7 30-7F 80 bytes of general purpose data memory. It is byte addressable, used for stack
30H
2FH
Bit-Addressable RAM 20H 1FH 18H 17H 10H 0FH 08H 07H 00H Register Bank 2 (Stack) Register Bank 1 Register Bank 3
Register Bank 0
Interrupts of 8051
5 sources of Interrupts
INT0 and INT1 bars external interrupt inputs
These are processed internally by IE0 and IE1 flags
Two timers which generate int when FFFFH Serial port interrupt if R1 or T1 is set.
EA : Global enable/disable.
--: Undefined.
ET2 :Enable Timer 2 interrupt. ES :Enable Serial port interrupt. ET1 :Enable Timer 1 interrupt. EX1 :Enable External 1 interrupt. ET0 : Enable Timer 0 interrupt. EX0 : Enable External 0 interrupt.
Addressing modes
Direct - MOV R0, 89 H, Eg 89 of TMOD
operands 8 bit address field Internal data RAM and SFRS only
Indirect - ADD A, @ R0
Address is stored in R0 or R1 or SP if 8bits 16 bit addresses only in DPTR
Register specific (Register Implicit) RLA Immediate Mode ADD A, #100 Indexed Addressing
Addressing Modes
Indexed Addressing
MOVC A, @A+DPTR JMP @ A + DPTR
Used to access only program memory not data Used for look up table manipulations Only PC or data pointer 16 bit storage registers allowed Base address in PC or DPTR, relative addr in A
Explain the internal and external program memory as well as data memory of 8051 with the diagram showing their capacities. Draw the diagram to Interface Program memory of 16K x 8 EPROM to 8051and give its memory map. The address of memory map should start from 0000H. Discuss about various addressing modes of 8051. Explain the interrupt structure. Mention the priority. Explain how least priority is made as highest priority? Explain in 8051 instruction set to handle bit addressable RAM. Draw and discuss the formats and bit definitions of the following SFRs .(a) IP(b) TMOD(c) TCON(d) SCON (a) Explain the internal RAM organization of 8051? Discuss how switching between register banks is possible? What is the use of SFR? List out the SFR of 8051? Discuss the advantages of microcontroller based systems over microprocessor based systems? (b) With a neat sketch discuss the internal architecture of 8051? Explain the Flags d program status word of 8051 microcontroller? Explain the different types of Interrupt in 8051. Discuss the register set of 8051 Explain the addressing modes of 8051 microcontroller. Explain the different modes of operation of timer/counter in 8051. How does 8051 differentiate between the external and Internal prog mem