42
INTRODUCTION TO MICROCONTROLLER RAVI DADSENA

Uc1(vii sem)

Embed Size (px)

DESCRIPTION

Introduction to microcontroller

Citation preview

Page 1: Uc1(vii sem)

INTRODUCTION TO MICROCONTROLLER

RAVI DADSENA

Page 2: Uc1(vii sem)

Microcontroller 8051• A microcontroller is a highly integrated single chip, which consists of on

chip CPU (Central Processing Unit), RAM (Random Access Memory), EPROM/PROM/ROM (Erasable Programmable Read Only Memory), I/O (input/output) – serial and parallel, timers, interrupt controller,analog to digital converter,digital to analog converter,serial interfacing ports,oscillatory circuits.

• A microcontroller internally consist of all features required for computing system and functions as a computer without adding any external digital parts in it.

• Most of the pins in the uc chip can be made programmable by the user.• It is capable of handling boolean functions and it has many bit handling

instructions that can be easily understood by programmer.• Easy to design,small size,low cost and high speed performance.• Microcontroller are used in automatically controlled products and

devices,such as automobile engine control systems,implantable medical devices,remote controls,office machines,appliances,toys and other embeded systems.

Page 3: Uc1(vii sem)

ADDRESSING MODES OF 8051 The way in which the data operands are accessed by different instructions is known as the addressing modes. There are various methods of denoting the data operands in the instruction. The 8051 microcontroller supports mainly 5 addressing modes. They are 1.Immediate addressing mode2.Direct Addressing mode3.Register addressing mode4. Register Indirect addressing mode5.Indexed addressing mode• Immediate addressing mode : The addressing mode in which the data

operand is a constant and it is a part of the instruction itself is known as Immediate addressing mode. Normally the data must be preceded by a # sign. This addressing mode can be used to transfer the data into any of the registers including DPTR.

Eg: MOV A , # 27 H : The data (constant) 27 is moved to the accumulator register ADD R1 ,#45 H : Add the constant 45 to the contents of the accumulator

Page 4: Uc1(vii sem)

• Direct addressing mode: The addressing mode in which the data operand is in the RAM location (00 -7FH) and the address of the data operand is given in the instruction is known as Direct addressing mode. The direct addressing mode uses the lower 128 bytes of Internal RAM and the SFRs. Eg-(a)MOV R1, 42H Move the contents of RAM location 42 into R1 register, (b) MOV 49H,A : Move the contents of the accumulator into the RAM location 49.

• Register addressing mode :The addressing mode in which the data operand to be manipulated lies in one of the registers is known as register addressing mode. Eg-(a) MOV A,R0 : Move the contents of the register R0 to the accumulator, (b)ADD A,R6 :Add the contents of R6 register to the accumulator.

• Register Indirect addressing mode :The addressing mode in which a register is used as a pointer to the data memory block is known as Register indirect addressing mode. Eg-(a) MOV @ R1 , B : Move the contents of B into RAM location whose address is held by R1.

One of the advantages of register indirect addressing mode is that it makes accessing the data more dynamic than static as in the case of direct addressing mode.• Indexed addressing mode : This addressing mode is used in accessing the

data elements of lookup table entries located in program ROM space of 8051. Eg-(a) MOVC A,@ A+DPTR (The 16-bit register DPTR and register A are used to form the address of the data element stored in on-chip ROM. Here C denotes code .In this instruction the contents of A are added to the 16-bit DPTR register to form the 16-bit address of the data operand)

Page 5: Uc1(vii sem)

BLOCK DIAGRAM OF A MICROCONTROLLER

Page 6: Uc1(vii sem)

Operation of microcontroller• Power supply is turned off and then load the program in the microcontroller

chip and then wait what is about to come.• Now switch on the power supply and evrything starts with a high speed,the

control logic unit keeps everything under control.The control logic disables all other circuits except quartz crystal to operate.

• As the power supply voltage reached to its maximum value then oscillator frequency becomes stable.SFRs are being filled with bits reflecting the state of all circuits within the uc.Now all pins are configured as inputs and then overall electronics starts operation in rhythm with pulse sequence and on time is measured in nano and micro seconds.

• The value of program counter is initially set to zero and instruction from the address is send to the instruction decoder which recognizes it and program execution takes place.

• After the execution of program the value of program counter is incremented by 1 and whole process is repeated again and again ,several million times per second.

Page 7: Uc1(vii sem)

Salient features of 8051 uc• 4 KB on chip program memory (ROM or EPROM)).• 128 bytes on chip data memory(RAM).• 8-bit data bus• 16-bit address bus• 32 general purpose registers each of 8 bits• Two -16 bit timers T0 and T1

• Five Interrupts (3 internal and 2 external).• Four Parallel ports each of 8-bits (PORT0, PORT1,PORT2,PORT3) with a

total of 32 I/O lines.• One 16-bit program counter and One 16-bit DPTR ( data pointer)• One 8-bit stack pointer.• One Microsecond instruction cycle with 12 MHz Crystal.• One full duplex serial communication port.

Page 8: Uc1(vii sem)

Criteria for selecting uc1. Meeting the computing needs of the task efficiently and cost

effectively• speed, the amount of ROM and RAM, the number of I/O ports

and timers, size, packaging, power consumption• easy to upgrade,cost per unit,power consumption,packaging,no

of I/O pins and timer on chip.

2. Availability of software development tools• assemblers, debuggers, C compilers, emulator, simulator,

technical support

3. Wide availability and reliable sources of the microcontrollers.

A single chip RAM ROM

I/O Port

TimerSerial COM Port

Microcontroller

CPU

Page 9: Uc1(vii sem)

TYPES OF MICROCONTROLLERS

Microcontrollers can be classified on the basis of internal bus width, architecture, memory and instruction set as 4-bit,8-bit,16-bit and 32-bit micrcontrollers.• 4-bit Microcontrollers: These 4-bit microcontrollers are small size,

minimum pin count and low cost controllers which are widely used for low end applications like LED & LCD display drivers ,portable battery chargers etc.. Their power consumption is also low. The popular 4-bit controllers are Renasa M34501 which is a 20 pin DIP chip with 4kB of ROM,256 Bytes of RAM,2-Counters and 14 I/O Pins. Similarly ATAM862 series from ATMEL.

• 8-bit Microcontrollers : These are the most popular and widely used microcontrollers .About 55% of all CPU sold in the world are 8-bit microcontrollers only.The 8-bit microcontroller has 8-bitinternal bus and the ALU performs all the arithmetic and logical operations on a byte instruction. The well known 8-bit microcontroller is 8051 which was designed by Intel in the year 1980 for the use in embedded systems. Other 8-bit microcontrollers are Intel 8031/8052 and Motorola MC68HC11 and AVR Microcontrollers, Microchip’s PIC Microcontrollers 12C5XX ,16C5X and 16C505 etc

Page 10: Uc1(vii sem)

• 16-bit Microcontrollers : When the microcontroller performs 16-bit arithmetic and logical operations at an instruction, the microcontroller is said to be a 16-bit microcontroller. The internal bus width of 16-bit microcontroller is of 16-bit. These microcontrollers are having increased memory size and speed of operation when compared to 8-bit microcontrollers.These are most suitable for programming in Highlevel languages like C or C++ .They find applications in disk drivers,modems,printers,scanners and servomotor control. Examples of 16-bit microcontrollers are Intel 8096 family and Motorola MC68HC12 and MC68332 families, The performance and computing capability of 16 bit microcontrollers are enhanced with greater precision as compared to the 8-bit microcontrollers.

• 32-Bit Microcontrollers :These microcontrollers used in highend applications like Automative control, Communication networks,Robotics,Cell phones ,GPRS & PDAs etc..For EX:PIC32,ARM 7,ARM9 ,SHARP LH79520 ,ATMEL 32 (AVR) ,Texas Instrument’s –. TMS320F2802x/2803x etc..are some of the popular 32-bit microcontrollers.

Page 11: Uc1(vii sem)

Advantages of uc• Microcontroller act as a microcomputer without any digital parts.• Easily interface additional RAM,ROM,I/O ports.• Low time required for performing operations.• Most of the pins are programmed by user for performing different

functions.• Usage is simple,easy for troubleshoot and system maintaining.

Disadvantages of uc• Microcontroller got more complex arhitectur then that of up.• Mostly used in uequipment.• Only perform limited no of executions simultaneusly.• Cannot interface high power device directly.

Page 12: Uc1(vii sem)

Applications of uc• Home appliances - Intercom, telephones, security systems, garage door

openers, answering machines, fax machines, home computers, TVs, cable TV tuner, VCR, camcorder, remote controls, video games, cellular phones, musical instruments, sewing machines, lighting control, paging, camera, pinball machines, toys, exercise equipment etc.

• Office Equipments - Telephones, computers, security systems, fax machines, microwave, copier, laser printer, color printer, paging etc.

• Automobiles - Trip computer, engine control, air bag, ABS, instrumentation, security system, transmission control, entertainment, climate control, cellular phone, keyless entry,flight control systems,printers etc.

• Industrial Applications – Industrial controllers,DAS etc.• Used in biomedical equipments, communication systems, robotics,

peripheral control in pc.• Military applications.

Page 13: Uc1(vii sem)

Need of uc over up• Microprocessor is an IC which has only the CPU inside them i.e. only the

processing powers such as Intel’s Pentium 1,2,3,4, core 2 duo, i3, i5 etc. These microprocessors don’t have RAM, ROM, and other peripheral on the chip. A system designer has to add them externally to make them functional. Application of microprocessor includes Desktop PC’s, Laptops, notepads etc.

• But this is not the case with Microcontrollers. Microcontroller has a CPU, in addition with a fixed amount of RAM, ROM and other peripherals all embedded on a single chip. At times it is also termed as a mini computer or a computer on a single chip. Today different manufacturers produce microcontrollers with a wide range of features available in different versions. Some manufacturers are ATMEL, Microchip, TI, Freescale, Philips, Motorola etc.

Page 14: Uc1(vii sem)

• Microprocessor find applications where tasks are unspecific like developing software, games, websites, photo editing, creating documents etc. In such cases the relationship between input and output is not defined. They need high amount of resources like RAM, ROM, I/O ports etc. The clock speed of the microprocessor is quite high as compared to the microcontroller. Whereas the ucontrollers operate from a few mhz to 30 to 50 mhz, today’s uprocessor operate above 1ghz as they perform complex tasks.

• Microcontrollers are designed to perform specific tasks. Specific means applications where the relationship of input and output is defined. Depending on the input, some processing needs to be done and output is delivered. For example, keyboards, mouse, washing machine, digicam, pendrive, remote, microwave, cars, bikes, telephone, mobiles, watches, etc. Since the applications are very specific, they need small resources like RAM, ROM, I/O ports etc and hence can be embedded on a single chip. This in turn reduces the size and the cost.

Page 15: Uc1(vii sem)

• So to make a complete ucomputer system only up is not sufficent.It is necessary to add other peripherals such as ROM,RAM,I/O PORTS,DECODERS,DRIVERS to make a complete ucomputer system.Also some special purpose devices such as interrupt controller programmable timers,programmable input device may be added to improve the capacity performance and flexibility of ucomputer system.Basically we have to design a ucomputer based computer system to design a system with greater flexibility.So that to configure a large or small system by adding peripherals.

• While microcontroller incorporates all the features that found in up.It has also added features to make a complete ucomputer system on its own.The uc has built in ROM,RAM,I/O PORTS,TIMER,COUNTER,INTERRUPT CONTROL,CLOCK CIRCUIT.

The 8051 family has the largest number of diversified (multiple source) suppliers

• Intel (original)• Atmel

• Philips/Signetics• AMD

• Infineon (formerly Siemens)• Matra

• Dallas Semiconductor/Maxim

Page 16: Uc1(vii sem)

Difference uc & upup

a) Up contains ALU,general purpose register,stack pointer,program counter,clock timing ckt and interupt ckt.

b) Many inst to move data between memory and cpu

c) One or 2 bit handling inst.d) More accsess time for memory

and input devicese) System requires more hardware.f) System is more flexible in design

point of view.g) Single memory map for data &

code.h) Less no of pins are

multifunctioned.i) System is bulky.

uca) Uc contains the circuitry of up

and in addition it has built in ROM,RAM,input device,timers and counters.

b) 1 or 2 inst to move data batween memory and cpu.

c) Many bit handling inst.d) Less access time.

e) Less hardware.f) Less flexible.

g) Separate memory map for data and code.

h) More no of pins

i) Simple

Page 17: Uc1(vii sem)

a) Boolean operation is not possible directly.

b) It takes many instructions to read and write data from external memory.

c) 16 bit stack pointer.d) Down counter are used in up so

that after each clock pulse the count value decreases.

a) Boolean operation is directly possible.

b) Onlt takes few inst.

c) 8bit stack pointer.d) Up counters are used so that

after each clock pulse count value increases.

Page 18: Uc1(vii sem)

Block diagragm of uc 8051

Page 19: Uc1(vii sem)

Microcontroller consist of 4 basic functional blocks:a) Main CPU.b) Data memory-RAM & memory for monitoring the program which is to be

stored in ROM/EPROM or flash memory.c) Timers/counters.d) I/O ports to interface with external peripheral components.The uc has on chip(built in) peripheral devices.These on chip peripherals make to possible to have a single chip ucomputer system.Advantages of built in peripherals are:e) Built in peripherals have similar access time hence speed is more.f) Hardware reduces due to single chip ucomputer system.g) Less hardware reduces PCB size and increase reliability of system.The CPU of 8051 consists of 8 bit ALU with associated registers like A,B,PWS,SP, 16 bit program counter & data pointer registers it has a set of special functn registers.Unique feature of this architecture is that ALU can manipulate 1 bit as 8 bit data types.h) This 8bit uc which was developed by intel in 1981 has 128 bytes of RAM for

storing data called data memory & 4k bytes of on-chip ROM for program storation called code memory.

i) One serial port for performing serial or parallel communication and 2 timers which can be used as timer as well as counter.

Page 20: Uc1(vii sem)

a) 4 bidirectional I/O ports are used each 8 bit wide,all these are in a single chip.

b) This 8051 is an 8bit processor i.e. CPU can work on only 8 bits of data at a time,if data is larger than 8 bits then it is to be broken into 8 pieces to be processed by CPU.Whereas 8051 can have max of 64k bytes of on-chip ROM,many manufacturers have put only 4k bytes on the chip.

Pin Diagram of 8051• The 8051 is a 40 pin configuration.It is imp that many pins of 8051 are

used for more than one function.• It has 32 I/O pins configured as 4 eight bit parellel ports(P0,P1,P2,P3).All

are bidirectional i.e configured as both input and output.• All port pins are multiplexed except the port pin 1.Each port consists of a

latch,an output driver and an input buffer.

Page 21: Uc1(vii sem)

Pin Description of the 8051

1234567891011121314151617181920

4039383736353433323130292827262524232221

P1.0P1.1P1.2P1.3P1.4P1.5P1.6P1.7RST

(RXD)P3.0(TXD)P3.1

(T0)P3.4(T1)P3.5

XTAL2XTAL1

GND

(INT0)P3.2(INT1)P3.3

(RD)P3.7(WR)P3.6

VccP0.0(AD0)P0.1(AD1)P0.2(AD2)P0.3(AD3)P0.4(AD4)P0.5(AD5)P0.6(AD6)P0.7(AD7)EA/VPPALE/PROGPSENP2.7(A15)P2.6(A14)P2.5(A13)P2.4(A12)P2.3(A11)P2.2(A10)P2.1(A9)P2.0(A8)

8051(8031)

Page 22: Uc1(vii sem)

• Vcc ( pin 40 ):– Vcc provides supply voltage to the chip. – The voltage source is +5V.

• GND ( pin 20 ): ground• XTAL1 and XTAL2 ( pins 19,18 )• RST ( pin 9 ): reset

– It is an input pin and is active high ( normally low ) .• The high pulse must be high at least 2 machine cycles.

– It is a power-on reset.• Upon applying a high pulse to RST, the microcontroller will reset

and all values in registers will be lost.• Reset values of some 8051 registers.

• /PSEN ( pin 29 ): program store enable(It is a active low o/p control signal used to activate the enable signal of the external ROM/EPROM)– This is an output pin and is connected to the OE pin of the ROM.

Page 23: Uc1(vii sem)

• /EA ( pin 31 ): external access– There is no on-chip ROM in 8031 and 8032 .– The /EA pin is connected to GND to indicate the code is stored

externally.– /PSEN & ALE are used for external ROM.– For 8051, /EA pin is connected to Vcc.– “/” means active low.

• ALE ( pin 30 ): address latch enable– It is an output pin and is active high.– 8051 port 0 provides both address and data.– The ALE pin is used for de-multiplexing the address and data by

connecting to the G pin of the 74LS373 latch.• I/O port pins

– The four ports P0, P1, P2, and P3.– Each port uses 8 pins.– All I/O pins are bi-directional.

Page 24: Uc1(vii sem)

• Using a quartz crystal oscillator• We can observe the frequency on the XTAL2 pin.

XTAL Connection to 8051 Power-On RESET Circuit

C2

30pF

C1

30pF

XTAL2

XTAL1

GND

Vcc

30 pF

30 pF

8.2 K

10 uF

+

11.0592 MHz

EA/VPPX1

X2

RST

31

19

18

9

Page 25: Uc1(vii sem)

Power On Reset Circuit• The power on reset circuit is an electronic device incorporated into the circuit that

detects the power applied to the chip and generates a reset impulsethat goes to the entire ckt placing it into known state.

• A simple POR is composed of RC device that chargesw with the rising of the supply voltage.A schmitt trigger is used so that rising charged voltage of the RC network generates an impulse.This impulse is generated based on2 threshold voltages of the schmitt trigger.

• When the input voltage at the schmitt trigger coming from the RC network reaches the 1st threshold voltage the output of the schmitt trigger switches so that it generates the 1st edge of the input.The charging of the RC network should be long enough so that the POR can reset all the internal ckts before the charging voltage reaches the other threshold voltage of the schmitt trigger and output to switch back.

• One of the issues with using RC network to genrate POR pulse is the sensitivity of the R & C values to thepower supply ramp characterstics.When the power supply ramp is rapid the R & C values can be calculated so that the time to reach the switching threshold of the schmitt trigger is enough to apply a long enough reset pulse.

• When the power supply ramp itself is slow,the RC network tends to get charged upalong with the power supply ramp-up.So when the input stage is all powered upand ready,the input voltage from RC network would already have crossed the schmitt trigger point.

Page 26: Uc1(vii sem)

Pins of I/O ports• The 8051 has four I/O ports

– Port 0 ( pins 32-39 ): P0 ( P0.0 ~ P0.7 )– Port 1 ( pins 1-8 ) : P1 ( P1.0 ~ P1.7 )– Port 2 ( pins 21-28 ): P2 ( P2.0 ~ P2.7 )– Port 3 ( pins 10-17 ): P3 ( P3.0 ~ P3.7 )– Each port has 8 pins.

• Named P0.X ( X=0,1,...,7 ) , P1.X, P2.X, P3.X• Ex : P0.0 is the bit 0 ( LSB ) of P0 • Ex : P0.7 is the bit 7 ( MSB ) of P0• These 8 bits form a byte.

• Each port can be used as input or output (bi-direction).

Page 27: Uc1(vii sem)

Port 0 (1). Port 0 is 8-bitbidirectional I/O port.

(2). Port 0 pins can be used as high-impedance inputs.

(3). Port 0 is also the multiplexed low-order address and data bus during accesses to external program and data memory.

(4). We r using pins no. from 32 to 39.

(5). When used as an output the pin latches are programmed to 0.

(5). When used as an input the pin latches are programmed to 1.

Page 28: Uc1(vii sem)

Port 1

(1). Port 1 is an 8-bit bidirectional I/0 port.

(2). We r using pins no. from 1 to 9.

(3). Port 1 have no dual functions.

(4). When used as an output the pin latches are programmed to 0.

(5). When used as an input the pin latches are programmed to 1.

Page 29: Uc1(vii sem)

Port 2(1). Port 2 is an 8-bit bidirectional I/O port.

(2). Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that use 16-bit addresses (MOVX @DPTR).

(3). When used as an output the pin latches are programmed to 0.

(4). When used as an input the pin latches are programmed to 1.

(5). We r using pins no. from 21 to 28.

Page 30: Uc1(vii sem)

Port 3(1). Port 3 is an 8-bit bi-directional I/0 port. (2). We r using pins no. from 10 to 17.

• RXD (P3.0): Serial input port,• TXD (P3.1): Serial output port,• INT0 (P3.2): External interrupt,• INT1 (P3.3): External interrupt,• T0 T0 (P3.4): Timer 0 external input,• T1 (P3.5): Timer 1 external input,• WR (P3.6): External data memory write strobe,• RD (P3.7): External data memory read strobe,

Page 31: Uc1(vii sem)

8051 family members

Feature 8051 8052 8031

ROM(on chip program space in bytes) 4k 8k 0k

RAM(bytes) 128 256 128

Timers 2 3 2

I/O pins 32 32 32

Serial port 1 1 1

Interrupt sources 6 8 6

Page 32: Uc1(vii sem)

Comparasion AT89C51,8751 & DS5000Feature AT89C51 8751 DS5000

ROM(on chip) 4 KB (flash) 4 KB (UV-ROM) 8 KB (NV-RAM)

RAM 128 BYTES 128 BYTES 128 BYTES

Timers 2 2 2

I/O pins 32 32 32

Serial port 1 1 1

Inrerrupt sources 6 6 8

Page 33: Uc1(vii sem)

Memory structure of 8051

Program Memory(on-chip ROM)

Page 34: Uc1(vii sem)

Data Memory(RAM)

Page 35: Uc1(vii sem)

RAM Allocation in 8051The 8051 has 128 byte internal RAM used for storing data.These internal RAM memory is organized into 3 categories:a) Register bankb) Bit addressablec) General purposea) Register bank• The 1st 32 byte from address 00H to 1FH of internal RAM constitute 32

working registers.They are organized int 4 banks of 8 registers each.These 4 banks are no from 0-3 and named as R0 to R7.

• Each register can be addressed by its name or RAM address.• At a time only one register bank is in use.Bits RS0 to RS7 in PSW determine

which bank is currently in use.And on reset bank 0 is selected therfore it is a default register bank.When register banks are not selected then it can be used as general purpose RAM.

RS1(PSW.4) RSO(PSW.3) BANK SELECTION0 0 Bank 00 1 Bank 11 0 Bank 21 1 Bank 3

Page 36: Uc1(vii sem)

a) Bit/byte addressable - Its location is from 20H to 2FH i.e. 16 bytes provides 128 bits,16*8=128,i.e. from 0 to 127 in decimal or 00-7FH.

b) General purpose RAM-The RAM area above bit addressable area from 30H-7FH calles general purpose RAM.It is addressable as byte.

7FH

30H

2FH

20H

1FH

17H

10H

0FH

07H

08H

18H

00HRegister Bank 0

(Stack ) 1Register Bank

Register Bank 2

Register Bank 3

Bit-Addressable RAM

Scratch pad RAM

Page 37: Uc1(vii sem)

Crystal Oscillator Circuit

Page 38: Uc1(vii sem)

OTP 8051OTP means one time programmable.Thus when the application is loaded into the device,it cannot be changed anymore.Advantages of OTP :• Lowest prices than their flash counterparts.• Not possible to re-program thus a device can’t be hacked by malicious software

updates.EPROM & UV-EPROM :• EPROM was invented to allow malikg chaqnges in the contents pf PROM after it is

burned .In EPROM, one can program the memory chip and erase it thousands of time.This is especially needed during the design of any microprocessro based project.

• A widely used EPROM is called UV-EPROM where UV stands for ultraviolet.The only problem with UV-EPROM is that it takes upto 20 min for erasing the contents.

• All UV-EPROM chips have a window through which the programmer can shine UV radiation to erase its contents for the reason,EPROM is also reffered to as UV erasable EPROM or simply UV-EPROM.

Page 39: Uc1(vii sem)

• For programming into a UV-EPROM following steps are :• Its contents must be erased.To erase a chip, remove it from its socket on the

system board and place it in EPROM erasure equipment to expose it to UV radiation for 15-20 min.

• Program the chip.To program a UV-EPROM chip,place it in the ROM burner(programmer).To burn code or data into EPROM,the ROM burner uses 12.5 volts or higher,depending on the EPROM type.This voltage is reffered to as Vpp in the UV-EPROM data sheet.

• Now place the chip back into its socket on the system board.

8751 uc • It has 4k bytes of on-chip UV-EPROM.Using this chip for the development access

to a PROM burner,as well as a UV-EPROM insid the 8751 chip because we can program it again.Because the on-chip ROM for 8751 is UV-EPROM, it takes around 20 min to erase the 8751 before it can be programed again

• 8751 uses 128 bytes on-chip RAM.• 1 serial & 4 parallel ports.• 2 timer/counter.• 6 interrupts.• 32 bit input/output pins.

Page 40: Uc1(vii sem)

8051 Stack• The register used to access the stack is called SP (stack pointer) register.• The stack pointer in the 8051 is only 8 bits wide, which means that it can

take value 00 to FFH. When 8051 powered up, the SP register contains value 07.

• The storing of a CPU register in the stack is called a PUSH– SP is pointing to the last used location of the stack– As we push data onto the stack, the SP is incremented by one– This is different from many microprocessors.eg-MOV SP,#13H

• Loading the contents of the stack back into a CPU register is called a POP– With every pop, the top byte of the stack is copied to the register

specified by the instruction and the stack pointer is decremented once

Page 41: Uc1(vii sem)
Page 42: Uc1(vii sem)

Address of special function registersS.No Symbol Name of SFR Address (Hex)

1 ACC* Accumulator 0E0

2 B* B-Register 0F0

3 PSW* Program Status word register 0DO

4 SP Stack Pointer Register 81

5

DPTR

DPL Data pointer low byte 82

DPH Data pointer high byte 83

6 P0* Port 0 80

P1* Port 1 90

8 P2* Port 2 0A

9 P3* Port 3 0B

10 IP* Interrupt Priority control 0B8

11 IE* Interrupt Enable control 0A8

12 TMOD Tmier mode register 89

13 TCON* Timer control register 88

14 TH0 Timer 0 Higher byte 8C

15 TL0 Timer 0 Lower byte 8A

16 TH1 Timer 1Higher byte 8D

17 TL1 Timer 1 lower byte 8B

18 SCON* Serial control register 98

19 SBUF Serial buffer register 99

20 PCON Power control register 87