microprocessor 8051

34
PRESENTATION ON MICROPROCESSOR MICROPROCESSOR 8051 By: - ANIL MAURYA ELECTRICAL & ELECTRONICS ENGINEER

Upload: krishnaakshatanil

Post on 06-May-2015

268 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: Microprocessor 8051

PRESENTATION ON

MICROPROCESSOR MICROPROCESSOR 8051

By: -ANIL MAURYAELECTRICAL & ELECTRONICS ENGINEER

Page 2: Microprocessor 8051
Page 3: Microprocessor 8051
Page 4: Microprocessor 8051

GENERIC 8051 FEATURES

� •Eight bit CPU with registers A and B� •Sixteen bit program counter (PC) and data pointer (DPTR)� •Eight-bit program status word (PSW)� •Eight bit stack pointer (SP)� •128 bytes of RAM and 4K ROM� •Thirty two input / output pins arranged as four 8 bit ports: P0-P3

•Two 16-bit timers /counters: T0 and T1� •Two 16-bit timers /counters: T0 and T1� •Full duplex serial data receiver and transmitter: SBUF� •Two external and three internal interrupt sources� •Control registers TCON, TMOD, SCON, PCON, IP and IE.� •Oscillator and the clock circuits.

Page 5: Microprocessor 8051

Math Register� A and B CPU Registers:� A Register (Accumulator)

� B Register

� Multiplication and division can be performed only upon numbers stored in the A and Bregisters. All other instructions in the program can use this register as a spareaccumulator (A).

Page 6: Microprocessor 8051

Program Status Word (PSW) Register

P - Parity bit. If a number stored in the accumulator is even then this bit will be automatically set(1), otherwise it will be cleared (0). It is mainly used during data transmit and receive via serialcommunication.communication.OV Overflow occurs when the result of an arithmetical operation is larger than 255 and cannot bestored in one register. Overflow condition causes the OV bit to be set (1). Otherwise, it will be cleared(0).RS0, RS1 - Register bank select bits. These two bits are used to select one of four register banks of RAM. By setting and clearing these bits, registers R0-R7 are stored in one of four banks of RAM.

Page 7: Microprocessor 8051

� F0 - Flag 0. This is a general-purpose bit available for use.

� AC - Auxiliary Carry Flag is used for BCD operations only.

� CY - Carry Flag is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions.

Page 8: Microprocessor 8051

INTRNAL RAM

Page 9: Microprocessor 8051

REGISTER Bank

BANK1 BANK2 BANK3BANK0

Page 10: Microprocessor 8051

Internal ROM� Microcontroller has a 4 K byte internal ROM. The opcodes of the instruction stored in the ROM.

The opcode fetch from the internal ROM.

Page 11: Microprocessor 8051

DATA POINTER

Page 12: Microprocessor 8051

Stack Pointer (SP) Register

Page 13: Microprocessor 8051

I/O Ports:

� Port 0: Port 0 is 8 bit port. It used as a input port or output port .when used as a output port ,the pinlatches that programmed to a 0 ,if used as a output port ,the pin latches that programmed to a 1.it Alsoprovide the facility for low order adders bus for external memory.

� Port 1: Port 1is 8 bit port. It used as a input port or output port .when used as a output port ,the pin latchesthat programmed to a 0 ,if used as a output port ,the pin latches that programmed to a 1.

� Port 2: Port 0 is 8 bit port. It used as a input port or output port .when used as a output port ,the pinlatches that programmed to a 0 ,if used as a output port ,the pin latches that programmed to a 1.it Alsoprovide the facility for high order adders bus for external memory.

� Port 3: Port 1is 8 bit port. It used as a input port or output port .when used as a output port ,the pinlatches that programmed to a 0 ,if used as a output port ,the pin latches that programmed to a 1.Theport 3 alternate uses shown in the following table:

Page 14: Microprocessor 8051
Page 15: Microprocessor 8051

TIMERS AND COUNTERS

The 8051 comes equipped with two 16 bit timers (T0, T1), both ofwhich may be controlled, set, read, and configured individually.The 8051 timers have two general functions:1 Count internal -acting as timer2. Count external -acting as counter

All counter action is controlled by the TMOD and the TCON registers.

Page 16: Microprocessor 8051

TMOD Register: TMOD Register:

GATE 1 /0 enables and disables Timer 1/0 by means of a signal brought to the

Timer 1 Timer 0

GATE 1 /0 enables and disables Timer 1/0 by means of a signal brought to the INT1/0 pin (P3.3/P3.2)

1 - Timer 1 operates only if the INT1 bit is set. 0 - Timer 1 operates regardless of the logic state of the INT1 bit.

C/T 1/0 selects pulses to be counted up by the timer/counter 1: 1 - Timer counts pulses from external source ,brought to the T1 pin (P3.5)(counter) 0 - Timer counts pulses from internal oscillator(timer)

T1M1,T1M0 These two bits select the operational mode of the Timer 1.

Page 17: Microprocessor 8051
Page 18: Microprocessor 8051

Different modes of timers

Page 19: Microprocessor 8051

Different modes of timers

Page 20: Microprocessor 8051

TCON RegisterTCON Register

TF1 bit is automatically set on the Timer 1 overflow (ie when counting is over) TF1 bit is automatically set on the Timer 1 overflow (ie when counting is over) TR1 bit enables the Timer 1.

1 - Timer 1 is enabled. 0 - Timer 1 is disabled.

TF0 bit is automatically set on the Timer 0 overflow (ie when counting is over). TR0 bit enables the timer 0.

1 - Timer 0 is enabled. 0 - Timer 0 is disabled.

Page 21: Microprocessor 8051

� IE1 – External interrupt 1. set when INT1 is active(pin 3.3).Not related with timer/counter

� IT1 – If IT1 =1 , INT1 is enabled by falling edge signal to generate interrupt

If IT1 =0 , INT1 is enabled by low signal to generate interrupt

� IE0 –External interrupt 0. set when INT0 is active(pin 3.2). Not related with timer/counter

� IT0 –If IT1 =1 , INT0 is enabled by falling edge signal to generate interrupt

If IT1 =0 , INT0 is enabled by low signal to generate interrupt

Page 22: Microprocessor 8051

UART (Universal Asynchronous Receiver and Transmitter)

SBUF register holds the dataSCON register controls the data communicationPCON register controls data rate

Page 23: Microprocessor 8051

Serial Port Control (SCON) Register

SM0 – Serial port mode control bit 0SM1 – Serial port mode control bit 1SM2 – Multi processor communication bitSM2 – Multi processor communication bit

- In mode 2 and 3, if set to 1 then interrupt is generated 9th bit of received data is 1. No interrupt is generated if 9th bit is 0

- In mode 1 , no interrupt is generated until a stop bit is received- in mode 0,it is cleared

REN- Receive enable control bit . Set to 1,to enable reception.Cleared to 0 to disable receptionTB8 – transmit bit 8. set and cleared by program in mode 2 and mode 3 RB8 – Receive bit 8. set and cleared by program in mode 2 and mode 3TI – Transmit interrupt flagRI - Receive interrupt flag

Page 24: Microprocessor 8051
Page 25: Microprocessor 8051

Different mode of serial data transmission

MODE 0

� Bit pattern

BAUD RATE = f/12

f:crystal frequency

Page 26: Microprocessor 8051

Different mode of serial data transmission

MODE 1� Bit pattern

BAUD RATE = 2SMOD *k* oscillator freq /32*12*[256-TH1]If SMOD=0 ,then k=1If SMOD =1, then k =2f:crystal frequency(11.0592 MHz)

Page 27: Microprocessor 8051

Different mode of serial data transmission

MODE 2

� Bit pattern

BAUD RATE = f/32,f/64

Page 28: Microprocessor 8051

Different mode of serial data transmissionMODE 3

� Bit pattern

BAUD RATE = 2SMOD*k*oscillator freq /32*12*[256-TH1]

Page 29: Microprocessor 8051

INTERRUPT

Five interrupts are provided in 8051,three of these are generatedautomatically by internal operation two interrupts are triggered by externalsignals provided by circuitry that is connected to pins INT0 and INT1.

Timer flag interrupt: when a timer and counter overflow the correspondingtimer flag TF0 or TF1 is set to 1.

Serial port interrupt: if a data byte is received an interrupt bit, RI is setto 1 in the SCON register when a data byte has binn transmitted aninterrupt bit TI is set to be 1.

External interrupt: pins ~INT0 and ~INT1 are used by external circuitry.Input on these pins can set the interrupt flag IE0 and IE1 in the TCONreregister to 1 by two different methods.

Page 30: Microprocessor 8051
Page 31: Microprocessor 8051

Interrupt Enable RegisterInterrupt Enable Register

EA - global interrupt enable/disable: EX1 - bit enables or disables external 1 interrupt: EA - global interrupt enable/disable: 0 - disables all interrupt requests. 1 - enables all individual interrupt requests.

ET2 - Reserved

ES - enables or disables serial interrupt: 0 - UART system cannot generate an interrupt. 1 - UART system enables an interrupt.

ET1 - bit enables or disables Timer 1 interrupt: 0 - Timer 1 cannot generate an interrupt. 1 - Timer 1 enables an interrupt.

EX1 - bit enables or disables external 1 interrupt: 0 - change of the pin INT1 logic state cannot generate an interrupt. 1 - enables an external interrupt on the pin INT1 state change.

ET0 - bit enables or disables timer 0 interrupt: 0 - Timer 0 cannot generate an interrupt. 1 - enables timer 0 interrupt.

EX0 - bit enables or disables external 0 interrupt:

Page 32: Microprocessor 8051

Interrupt Vector Location Priority

External hardware interrupt 0(INT0)

0003H Highest

Timer 0 interrupt ( T0) 000BHTimer 0 interrupt ( T0) 000BH

External hardware interrupt 1(INT1) 0013H

Timer 1interrupt ( 1) 001BH

Serial communication interrupt (RI and TI)

0023H lowest

Page 33: Microprocessor 8051

Interrupt priority RegisterInterrupt priority Register

PS - Serial Port Interrupt priority bit PS - Serial Port Interrupt priority bit Priority 0 Priority 1

PT1 - Timer 1 interrupt priority Priority 0 Priority 1

PX1 - External Interrupt INT1 priority Priority 0 Priority 1

PT0 - Timer 0 Interrupt Priority Priority 0 Priority 1

PX0 - External Interrupt INT0 Priority Priority 0 Priority 1

Page 34: Microprocessor 8051