ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051...

89
SESHASAYEE INSTITUTE OF TECHNOLOGY ARIYAMANGALAM , TRICHY – 620 010 ARCHITECTURE OF 8051 & THEIR PIN DETAILS UNIT I WELCOME

Transcript of ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051...

Page 1: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SESHASAYEE INSTITUTE OF TECHNOLOGYARIYAMANGALAM , TRICHY – 620 010

ARCHITECTURE OF 8051 & THEIR PIN DETAILS

UNIT I

WELCOME

Page 2: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

ARCHITECTURE OF 8051 & THEIR PIN DETAILS

U1.1 : Introduction to microprocessor & microcontroller : Architecture of 8085 -Functions of each block. Comparison of Microprocessor & Microcontroller -Features of microcontroller -Advantages of microcontroller -Applications Of microcontroller -Manufactures of microcontroller.

U1.2 : Architecture of 8051 : Block diagram of Microcontroller –Functions of each block. Pin details of 8051 -Oscillator and Clock -Clock Cycle -State - Machine Cycle -Instruction cycle –Reset - Power on Reset - Special function registers:Program Counter -PSW register -Stack - I/O Ports .

U1.3 : Memory Organisation & I/O port configuration: ROM RAM - Memory Organization of 8051,Interfacing external memory to 8051

Page 3: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Microcontroller vs. Microprocessors

1. A smaller computer

2. On-chip RAM, ROM, I/O

ports...

3. Example:Motorola’s 6811,

Intel’s 8051, Zilog’s Z8 and

PIC

1. CPU for Computers

2. No RAM, ROM, I/O on CPU chip

itself

3. Example:Intel’s x86, Motorola’s

680x0

Page 4: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 5: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Microcontroller vs. Microprocessors

Microprocessor

1. CPU is stand-alone, RAM, ROM, I/O, timer are separate

2. designer can decide on the amount of ROM, RAM and I/O ports.

3. expansive

4. versatility

5. general-purpose

Microcontroller

1. CPU, RAM, ROM, I/O and

timer are all on a single

chip

2. fix amount of on-chip

ROM, RAM, I/O ports

3. for applications in which

cost, power and space are

critical

4. single-purpose

Page 6: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 7: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

uP vs. uC – cont.

Applications

– uCs are suitable to control of I/O devices in designs requiring a minimum component

– uPs are suitable to processing information in computer systems.

Page 8: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

uP vs. uC – cont.

uC is easy to use and design.

– Only single chip can be a complete system

– interfacing to other devices,

• for example, motors, displays, sensors, and communicate with PC.

In contrast, similar system that builds from

uP would require a lot of additional units,

– such as RAM, UART, I/O , TIMER and etc.

Page 9: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Embedded Products Using Microcontrollers

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

Page 10: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Embedded Products Using Microcontrollers

Office

– Telephones, computers, security systems, fax machines, microwave, copier, laser printer, color printer, paging

Page 11: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Embedded Products Using Microcontrollers

Auto

– Trip computer, engine control, air bag, ABS, instrumentation, security system, transmission control, entertainment, climate control, cellular phone, keyless entry

Page 12: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Choosing A Microcontroller

Computing needs

– Speed, packaging, power consumption, RAM, ROM, I/O pins, timers, upgrade to high performance or low-power versions, cost

Software development tools

– Assembler, debugger, C compiler, emulator, technical support

Availability & source

Page 13: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Types of microcontrollers▪ ARM core processors (many vendors)

▪ includes ARM9, ARM Cortex-A8, Sitara ARM Microprocessor

▪ Atmel AVR (8-bit), AVR32 (32-bit), and AT91SAM (32-bit)

▪ Cypress Semiconductor's M8C Core used in their PSoC

▪ Freescale ColdFire (32-bit) and S08 (8-bit)

▪ Freescale 68HC11 (8-bit)

▪ Intel 8051

▪ Infineon: 8, 16, 32 Bit microcontrollers[9]

▪ MIPS

▪ Microchip Technology PIC,

▪ NXP Semiconductors LPC1000, LPC2000, LPC3000, LPC4000

▪ Parallax Propeller

▪ PowerPC ISE

▪ Rabbit 2000 (8-bit)

▪ Silicon Laboratories Pipelined 8-bit 8051 Microcontrollers and …

▪ Texas Instruments TI MSP430 (16-bit)

▪ Toshiba TLCS-870 (8-bit/16-bit).

Page 14: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Various 8051 Microcontrollers

8751 microcontroller

– UV-EPROM

AT89C51 from Atmel Corporation

– Flash (erase before write)

DS5000 from Dallas Semiconductor

– NV-RAM (changed one byte at a time), RTC (real-time clock)

OTP (one-time-programmable) version of 8051

8051 family from Philips

– AD, DA, extended I/O, OTP and flash

Page 15: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Companies Producing 8051

Table 1-2:Some Companies Producing a Member of the 8051 Family

Company Web Site

Intel www.intel.com/design/mcs51

Atmel www.atmel.com

Philips/Signetics www.semiconductors.philips.com

Siemens www.sci.siemens.com

Dallas Semiconductor www.dalsemi.com

Page 16: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Inside 8051 Microcontroller

Introduced by Intel in 1981

Page 17: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

ARCHITECTURE

Memory Organization

CPU Clock

Interrupt Structure

Port Structures

Timer/Counters

Reset

Page 18: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 20: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Functional Description Of Each Block :• Accumulator: (Acc) Acc is an 8 bit special function register. It acts an

operand register. Result is temporarily stored in this register. It is used in parallel I/O transfer.

• B Register : B register is 8 bit SFR. It is used during multiply and divide operations. For other operations , it can be used as a scratchpad register.

• Program Status Word (PSW) : PSW register is 8 bit SFR. It contains program status information. It is also used to select any one of the required register bank.

• Stack Pointer ( SP): It is 8 bit register. It is used to point the stack memory. The stack may reside in anywhere in on-chip memory. It is incremented before data is stored during PUSH & CALL instructions. After reset SP is initialized to 07h. This causes the stack begin at location 08h.

• Data Pointer (DPTR) : It is 16 bit register. It may be manipulated as a 16 bit register or as two independent 8 bit registers. Its function is to hold a 16 bit address. This register is used for external reference.

Page 21: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CONTINUED..• Port 0 to Port 3 : Each port contains separate address. Using this

address,User can communicate with these ports. Each port contains latch,output driver & input buffer.

• Serial Data Buffer : Serial data buffer contains two independent registers of a transmit buffer register and a receiver buffer register.

– Transmit buffer is a parallel in and Serial out register.

– Receiver buffer is a Serial in and parallel out register.

– When data is moved to SBUF, it goes to transmit buffer .

– When data is moved from SBUF, it comes from the receive buffer.

• Timer Registers : Register pairs (TH0,TL0) & (TH1,TL1) are the two 16 bit counting registers for Timer/Counter 0 and 1 respectively.

Page 22: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CONTINUED…• Control Registers : The special function registers IP,IE , TMOD, TCON SCON

and PCON contain control and status information for interrupts, timer/counters and serial port.

• Timing & Control Unit : This unit derives an necessary timing and control signals required for the internal operations of the circuit. It derives control signals required for controlling the external system bus. The interrupt, serial port and timer circuits are controlled by the control signals generated by timing & control unit.

• Oscillator : This circuit generates the basic timing clock signal for the operation of the circuit using crystal oscillator.

• Instruction Register : This register decodes the opcode of an instruction to be executed and gives information to the timing & control unit, and to generate necessary signals for the execution of the instruction.

Page 23: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CONTINUED…..• EPROM & Program Address Register : These blocks

provide an onchip EPROM and a Mechanism to internally address it.

• RAM & RAM address register : These blocks provide an onchip RAM and a mechanism to internally address it.

• ALU : The Arithmetic And Logic Unit performs 8 bit arithmetic and logical operations over the operands held by the temporary registers TMP 1 and TMP 2. User cannot access these temporary registers

• SFR Register Banks : It is a set of registers, which can be addressed using their respective addresses which lie in the range 80h to FFh.

Page 24: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

XTAL Connection to 8051

• Find the machine cycle for• (a) XTAL = 11.0592 MHz • (b) XTAL = 16 MHz.• Solution:(a) 11.0592 MHz / 12

= 921.6 kHz; machine cycle = 1 / 921.6 kHz

= 1.085 (b) 16 MHz / 12 = 1.333 MHz;

machine cycle = 1 / 1.333 MHz = 0.75 s

Page 25: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Power-On RESET• RST(pin 9):reset(i) input pin and active high

(normally low).• The high pulse must be high

at least 2 machine cycles.(ii)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

(A) 00 ;(SP) 07 • (iii)power-on reset circuit -as shown in figure

Page 26: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

PIN DIAGRAM OF 8051

Page 27: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

PIN DETAILS• Pins 1 – 8:- Known as Port 1. Unlike other

ports, this port does not serve any other functions. Port 1 is an internally pulled up, quasi bi directional I/O port.

• Pin 9:- As explained before RESET pin is used to set the 8051 microcontroller to its initial values, while the microcontroller is working or at the initial start of application. To reset the microcontroller ,the reset pin must be set high for 2 machine cycles.

Page 28: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CONTD…• Pins 10 – 17:- Known as Port 3. This port also

serves some other functions like interrupts, timer input, control signals for external memory interfacing RD and WR , serial communication signals RxD and TxD etc. This is a quasi bi directional port with internal pull up resister. It is also called multifunctional port

• Pins 18 and 19:- Used for connecting an crystal externally to provide system clock.

• Pin 20:- Named as Vss – it represents ground (0 V) connection.

Page 29: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CONTD…• Pins- 21-28:- Known as Port 2 (P 2.0 to P 2.7) – in

addition to serving as I/O port, higher order address bus signals are multiplexed with this port.

• Pin- 29:- PSEN or Program Store Enable is used to read data from external program memory.

• Pin-30:- ALE Address Latch Enable is used to de multiplex the address and data signal of port 0 (for external memory interfacing.) When address moves on port 0,ALE will be high. It is the indication to hold the Address in latch .

• Pin-31:- EA External Access input is used to enable or disable external memory interfacing. It is low enable pin. If there is no external memory requirement, this pin is pulled high by connecting it to Vcc.

Page 30: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CONTD…

• Pins 32-39: Known as Port 0 (P0.0 to P0.7) – In addition to serving as I/O port, lower order address and data are multiplexed with this port (16 bit address is used for the purpose of external memory interfacing). This is a bi directional I/O port and external pull up resistors are required to use this port as I/O.

• Pin-40 : This pin is named as VCC. Usually +5V DC is given to this pin.

Page 31: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

8051 Family

Table 1-4:Comparison of 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: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 33: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SESHASAYEE INSTITUTE OF TECHNOLOGYARIYAMANGALAM , TRICHY – 620 010

ARCHITECTURE OF 8051 & THEIR PIN DETAILS

UNIT I

WELCOME

Page 34: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

ARCHITECTURE OF 8051 & THEIR PIN DETAILS

U1.1 : Introduction to microprocessor & microcontroller : Architecture of 8085 -Functions of each block. Comparison of Microprocessor & Microcontroller -Features of microcontroller -Advantages of microcontroller -Applications Of microcontroller -Manufactures of microcontroller.

U1.2 : Architecture of 8051 : Block diagram of Microcontroller –Functions of each block. Pin details of 8051 -Oscillator and Clock -Clock Cycle -State - Machine Cycle -Instruction cycle –Reset - Power on Reset - Special function registers:Program Counter -PSW register -Stack - I/O Ports .

U1.3 : Memory Organisation & I/O port configuration: ROM RAM - Memory Organization of 8051,Interfacing external memory to 8051

Page 35: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

1.3 MEMORY ORGANISATION

• The 8051 architecture provides both on chip memory as well as off chip memory expansion capabilities.

• It supports several distinctive ‘physical’ address spaces, functionally EA separated at the hardware level by different addressing mechanisms, read and write controls signals or both.

• The 8051 has on chip memory of 4 Kbytes of internal Program Memory and 128 bytes of internal Data memory.

• It can access upto 64 K program memory and 64Kdata memory.

Page 36: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

The 3 different address spaces of 8051i) 64 Kbyte program memory ii) 64 Kbyte external data memory iii) 256 byte internal data memory. Internal Data Memory (256bytes) is divided into two

physically separate and distinct blocks.i) 128 Bytes Internal RAM Area. This area is further divided

into three.a) 4 Register banks :

[each bank has eight 8 bit registers]( address range 00 – 1Fh)

b) 16 bytes bit addressable locations :( address range 20h – 2Fh)

c) 80 bytes byte addressable locations ( address range 30h – 7Fh)

ii) 128 Bytes SFR Area ( address range 80h – 0FFh )

Page 37: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

1.3 MEMORY ORGANISATION

Page 38: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CONNECTING EXTERNAL MEMORY TO MICROCONTROLLER

Page 39: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

MEMORY ORGANISATION CONTD..

Page 40: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

INTERNAL RAM

Page 41: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

INTERNAL RAM

Page 42: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SPECIAL FUNCTION REGISTERS (SFRS)

• Special Function Registers (SFRs) are a sort of control table used for running and monitoring the operation of the microcontroller.

• Each of these registers as well as each bit they include, has its name, address in the scope of RAM and precisely defined purpose such as timer control, interrupt control, serial communication control etc.. All types of 8051 microcontrollers, has only 21 such registers..

Page 43: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SPECIAL FUNCTION REGISTERSSN SFR NAME

BYTE

ADDRESS

IN HEXA

SN SFR NAME

BYTE

ADDRESS IN

HEXA

01 ACC* Accumulator 0E0 12 IE* InterruptEnable control 0A8

02 B* B register 0F0 13 TMOD Timer mode control 89

03 PSW* Program status word 0D0 14 TCON* Timer control 88

04 SP Stack pointer 81 15 TH0 Timer/counter0 high byte 8C

05 DPL Low byte 82 16 TL0 Timer/counter0 low byte 8A

06 DPH High byte 83 17 TH1 Timer/counter1 high byte 8D

07 P0* Port 0 80 18 TL1 Timer/counter1 low byte 8B

08 P1* Port 1 90 19 SCON* Serial control 98

09 P2* Port 2 0A0 20 SBUF SerialData buffer 99

10 P3* Port 3 0B0 21 PCON Power control 87

11 IP*Interrupt Priority

control0B8 22 PC Program Counter (No address)

Page 44: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SFR’s (BOTH BYTE AND BIT ADDRESSABLE REGISTERS)

SN SFR NAMEBYTE ADDRESS

IN HEXABIT ADDRESS IN HEXA

01 ACC* Accumulator 0E0 E7 – E0

02 B* B register 0F0 F7 – F0

03 PSW* Program status word 0D0 D7 – D0

04 P0* Port 0 80 87 – 80

05 P1* Port 1 90 97 – 90

06 P2* Port 2 0A0 A7 – A0

07 P3* Port 3 0B0 B7 – B0

08 IP* Interrupt Priority control 0B8 BF – B8

09 IE* Interrupt Enable control 0A8 AF – A8

10 TCON* Timer control 88 8F – 88

11 SCON* Serial control 98 9F - 98

Page 45: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

FORMAT OF PSW

BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0

D7 D6 D5 D4 D3 D2 D1 D0

CY AC F0 RS1 RS0 OV - P

BIT POSITION

BIT ADDRESS

BIT NAME

Page 46: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 47: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

DETAILS OF PSWBit Symbol Address Description

PSW.7 CY D7H Carry flag

PSW.6 AC D6H Auxiliary carry flag

PSW.5 F0 D5H Flag 0

PSW.4 RS1 D4H Register bank select 1

PSW.3 RS0 D3H Register bank select 0PSW.2 OV D2H Overflow flag

PSW.1 -- D1H Reserved

PSW.0 P D0H Even parity flag

Page 48: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Carry FlagThe carry flag has two functions.• It is used as the carry-out in 8-bit addition/subtraction.

For example, if the accumulator contains FDH and we add 3 to the contents of the accumulator (ADD A, #3), the accumulator will then contain zero and the carry flag will be set. It is also set if a subtraction causes a borrow into bit 7. In other words, if a number is subtracted from another number smaller than it, the carry flag will be set.For example, if A contains 3DH and R3 contains 4BH, the instruction

SUBB A, R3 will result in the carry bit being set (4BH is greater than 3DH).•The carry flag is also used during Boolean operations.

For example AND the contents of bit 3DH with the carry flag, the result being placed in the carry flag - ANL C, 3DH

Register Bank Select BitsBits 3 and 4 of the PSW are used for selecting the register bank. Since there are four register banks, two bits are required for selecting a bank, as detailed below.

Page 49: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

REGISTER BANK SELECTION

PSW.4

RS1PSW.3

RS0SELECTED Register

BankAddress of Register

Bank

0 0 0 00H to 07H

0 1 1 08H to 0FH

1 0 2 10H to 17H

1 1 3 18H to 1FH

Page 50: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Flag 0 : Flag 0 is a general-purpose flag available to the programmer.

Parity Bit : The parity bit is automatically set or cleared inevery machine cycle to ensure even parity with theaccumulator. The number of 1-bits in the accumulator plusthe parity bit is always even.

In other words, if the number of 1s in the accumulator is oddparity bit is set to 1.

if the number of 1s in the accumulator is even paritybit is set to 0.

For example, if the accumulator holds the number 05H, this is0000 0101 in binary => the accumulator has an even numberof 1s, therefore the parity bit is cleared.

If the accumulator holds the number F2H, this is 1111 0010 =>the accumulator has an odd number of 1s, therefore theparity bit is set to make the overall number of 1s even.

Page 51: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CY, the carry flag

This flag is set whenever there is a carry out from the D7 bit.This flag bit is affected after an 8-bit addition or subtraction.It can also be set to 1 or 0 directly by an instruction such as “SETB C” and “CLR C” where “SETB C” stands for “set bit carry” and “CLR C” for “clear carry”.

AC, the auxiliary carry flagIf there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is cleared.This flag is used by instructions that perform BCD (binary coded decimal) arithmetic.

OV, the overflow flagThis flag is set whenever the result of a signed number operation is too large, causing the high-order bit to overflow into the sign bit.In general, the carry flag is used to detect errors in unsigned arithmetic operations.The overflow flag is only used to detect errors in signed arithmetic operations

Page 52: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 53: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SESHASAYEE INSTITUTE OF TECHNOLOGYARIYAMANGALAM , TRICHY – 620 010

ARCHITECTURE OF 8051 & THEIR PIN DETAILS

UNIT I

WELCOME

Page 54: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

ARCHITECTURE OF 8051 & THEIR PIN DETAILS

U1.1 : Introduction to microprocessor & microcontroller : Architecture of 8085 -Functions of each block. Comparison of Microprocessor & Microcontroller -Features of microcontroller -Advantages of microcontroller -Applications Of microcontroller -Manufactures of microcontroller.

U1.2 : Architecture of 8051 : Block diagram of Microcontroller –Functions of each block. Pin details of 8051 -Oscillator and Clock -Clock Cycle -State - Machine Cycle -Instruction cycle –Reset - Power on Reset - Special function registers:Program Counter -PSW register -Stack - I/O Ports .

U1.3 : Memory Organisation & I/O port configuration: ROM RAM - Memory Organization of 8051,Interfacing external memory to 8051

Page 55: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SPECIAL FUNCTION REGISTERS (SFRS)

• Special Function Registers (SFRs) are a sort of control table used for running and monitoring the operation of the microcontroller.

• Each of these registers as well as each bit they include, has its name, address in the scope of RAM and precisely defined purpose such as timer control, interrupt control, serial communication control etc.. All types of 8051 microcontrollers, has only 21 such registers..

Page 56: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SPECIAL FUNCTION REGISTERSSN SFR NAME

BYTE

ADDRESS

IN HEXA

SN SFR NAME

BYTE

ADDRESS IN

HEXA

01 ACC* Accumulator 0E0 12 IE* InterruptEnable control 0A8

02 B* B register 0F0 13 TMOD Timer mode control 89

03 PSW* Program status word 0D0 14 TCON* Timer control 88

04 SP Stack pointer 81 15 TH0 Timer/counter0 high byte 8C

05 DPL Low byte 82 16 TL0 Timer/counter0 low byte 8A

06 DPH High byte 83 17 TH1 Timer/counter1 high byte 8D

07 P0* Port 0 80 18 TL1 Timer/counter1 low byte 8B

08 P1* Port 1 90 19 SCON* Serial control 98

09 P2* Port 2 0A0 20 SBUF SerialData buffer 99

10 P3* Port 3 0B0 21 PCON Power control 87

11 IP*Interrupt Priority

control0B8 22 PC Program Counter (No address)

Page 57: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SFR’s (BOTH BYTE AND BIT ADDRESSABLE REGISTERS)

SN SFR NAMEBYTE ADDRESS

IN HEXABIT ADDRESS IN HEXA

01 ACC* Accumulator 0E0 E7 – E0

02 B* B register 0F0 F7 – F0

03 PSW* Program status word 0D0 D7 – D0

04 P0* Port 0 80 87 – 80

05 P1* Port 1 90 97 – 90

06 P2* Port 2 0A0 A7 – A0

07 P3* Port 3 0B0 B7 – B0

08 IP* Interrupt Priority control 0B8 BF – B8

09 IE* Interrupt Enable control 0A8 AF – A8

10 TCON* Timer control 88 8F – 88

11 SCON* Serial control 98 9F - 98

Page 58: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

FORMAT OF PSW

BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0

D7 D6 D5 D4 D3 D2 D1 D0

CY AC F0 RS1 RS0 OV - P

BIT POSITION

BIT ADDRESS

BIT NAME

Page 59: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 60: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

DETAILS OF PSWBit Symbol Address Description

PSW.7 CY D7H Carry flag

PSW.6 AC D6H Auxiliary carry flag

PSW.5 F0 D5H Flag 0

PSW.4 RS1 D4H Register bank select 1

PSW.3 RS0 D3H Register bank select 0PSW.2 OV D2H Overflow flag

PSW.1 -- D1H Reserved

PSW.0 P D0H Even parity flag

Page 61: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Carry FlagThe carry flag has two functions.• It is used as the carry-out in 8-bit addition/subtraction.

For example, if the accumulator contains FDH and we add 3 to the contents of the accumulator (ADD A, #3), the accumulator will then contain zero and the carry flag will be set. It is also set if a subtraction causes a borrow into bit 7. In other words, if a number is subtracted from another number smaller than it, the carry flag will be set.For example, if A contains 3DH and R3 contains 4BH, the instruction

SUBB A, R3 will result in the carry bit being set (4BH is greater than 3DH).•The carry flag is also used during Boolean operations.

For example AND the contents of bit 3DH with the carry flag, the result being placed in the carry flag - ANL C, 3DH

Register Bank Select BitsBits 3 and 4 of the PSW are used for selecting the register bank. Since there are four register banks, two bits are required for selecting a bank, as detailed below.

Page 62: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

REGISTER BANK SELECTION

PSW.4

RS1PSW.3

RS0SELECTED Register

BankAddress of Register

Bank

0 0 0 00H to 07H

0 1 1 08H to 0FH

1 0 2 10H to 17H

1 1 3 18H to 1FH

Page 63: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Flag 0 : Flag 0 is a general-purpose flag available to the programmer.

Parity Bit : The parity bit is automatically set or cleared inevery machine cycle to ensure even parity with theaccumulator. The number of 1-bits in the accumulator plusthe parity bit is always even.

In other words, if the number of 1s in the accumulator is oddparity bit is set to 1.

if the number of 1s in the accumulator is even paritybit is set to 0.

For example, if the accumulator holds the number 05H, this is0000 0101 in binary => the accumulator has an even numberof 1s, therefore the parity bit is cleared.

If the accumulator holds the number F2H, this is 1111 0010 =>the accumulator has an odd number of 1s, therefore theparity bit is set to make the overall number of 1s even.

Page 64: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

CY, the carry flag

This flag is set whenever there is a carry out from the D7 bit.This flag bit is affected after an 8-bit addition or subtraction.It can also be set to 1 or 0 directly by an instruction such as “SETB C” and “CLR C” where “SETB C” stands for “set bit carry” and “CLR C” for “clear carry”.

AC, the auxiliary carry flagIf there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is cleared.This flag is used by instructions that perform BCD (binary coded decimal) arithmetic.

OV, the overflow flagThis flag is set whenever the result of a signed number operation is too large, causing the high-order bit to overflow into the sign bit.In general, the carry flag is used to detect errors in unsigned arithmetic operations.The overflow flag is only used to detect errors in signed arithmetic operations

Page 65: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

i/o ports

Page 66: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 67: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

PORT 0 STRUCTURE

Page 68: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Port-0 can be configured as a normal bidirectional I/O port or it can be used

for address/data interfacing for accessing external memory.

When control is '1', the port is used for address/data interfacing.

When the control is '0', the port can be used as a normal bidirectional I/O

port.

Port-1 does not have any alternate function i.e. it is dedicated solely for I/O interfacing. When used as output port, the pin is pulled up or down through internal pull-up. To use port-1 as input port, '1' has to be written to the latch. In this input mode when '1' is written to the pin by the external device then it read fine. But when '0' is written to the pin by the external device then the external source must sink current due to internal pull-up. If the external device is not able to sink the current the pin voltage may rise, leading to a possible wrong reading.

Page 69: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

PORT 1 STRUCTURE

Page 70: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Port-2 is used for higher external address byte or a normal input/output port. The I/O operation is similar to Port-1.Port-2 latch remains stable when Port-2 pin are used for external

memory access. Here again due to internal pull-up there is limited current driving capability.

Each pin of Port-3 can be individually programmed for I/O operation or for alternate function. The alternate function can be activated only if the corresponding latch has been written to '1'. To use the port as input port, '1' should be written to the latch.This port also has internal pull-up and limited current driving capability.

Page 71: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

PORT 2 STRUCTURE

Page 72: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

PORT 3 STRUCTURE

Page 73: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 74: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Clock cycle

Page 75: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

• Machine cycle is the unit of time elapsed during the execution. It is the unit used to describe the operation of 8051operation.The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 family, these time elapsed are referred as machine cycles. The length of the machine cycle depends on the frequency of the crystal oscillator connected to the 8051 system. Usually 12 clock cycles are referred as machine cycles

• Instruction cycle is the time required to complete the execution of an instruction. The Instruction may take different machine cycles to complete execution. So the instruction cycle may be of one or more machine cycles.

Page 76: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

The interrupts refer to a notification, communicated to the controller, by a hardware device or software, on receipt of which controller momentarily stops and responds to the interrupt.Whenever an interrupt occurs the controller completes the execution of the current instruction and starts the execution of an Interrupt Service Routine (ISR) or Interrupt Handler. ISR is a piece of code that tells the processor or controller what to do when the interrupt occurs.After the execution of ISR, controller returns back to the instruction it has

jumped from (before the interrupt was received).A SYSTEM RESET is a special type of interrupt. It interrupts the running program and loads the PC with the vector address 0000H. This is the address the microcontroller begins with on power-up. Therefore, reset is similar to powering down and the powering up the system.

INTERRUPTS

Page 77: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Interrupt Vectors : When an interrupt occurs the address of the interrupt service routine is loaded into the PC. This address is

known as the interrupt vector.

Interrupt FlagVector

Address

External interrupt 0 IE0 0003H

Timer 0 TF0 000BH

External interrupt 1 IE1 0013H

Timer 1 TF1 001BH

Serial port RI or TI 0023H

Page 78: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

STACK• It is a part of RAM in which data will be stored temporary during execution of

program. STACK works on last in first out principle.

• To store and retrieve data during program execution in stack, push and pop instruction are used .

• PUSH is used to store data into stack. POP is used to retrieve data from stack.

Page 79: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

• During the execution of CALL instructions, the microcontroller stores the content of program counter in the stack memory.

• During the RET instructions , the content of stack is moved in to program counter.

• Stack Pointer is the register(SFR) used to point the address of stack.

• The address of stack memory is placed in stack pointer.

• The stack pointer in the 8051 is only 8 bits wide, which means that it can take value 00 to FFH.

• During PUSH operation ,the Stack Pointer has the next address of stack The stack pointer is incremented during PUSH.

• During POP operation ,the Stack Pointer has the address of stack from which data is accessed next.

• The Stack Pointer is used to indicate where the next value to be removed from the stack. The stack pointer is decremented during POP.

Page 80: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

TIMER

• 8051 has two on-chip timers that can be used for counting timing durations or for counting external events.

• Interval timing allows the programmer to perform operations at specific instants in time.

• For example, in our LED flashing program the LED was turned on for a specific length of time and then turned off for a specific length of time.

• We achieved this through the use of time delays. • Since the microcontroller operates at a specific frequency, we could work

out exactly how many iterations of the time delay was needed to give us the desired delay.

• However, this is difficult and imperfect. And there is another disadvantage is that CPU is occupied for the maintaining the delay.

• If we use the on-chip timers, the CPU could be doing something more useful work.

• The timers take care on timer work.

Page 81: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Timers' SFRs

• The 8051 has two 16-bit timers. The high byte for timer 1 (TH1) is at address 8DH while the low byte (TL1) is at address 8BH.The high byte for timer 0 (TH0) is at address 8CH while the low byte (TL0) is at address 8AH.

• Both timers can be used in a four number of different modes.

• The programmer sets the timers to a specific mode by loading the appropriate 8-bit number into the Timer Mode Register (TMOD) .

Page 82: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip
Page 83: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

SERIAL PORT

• The 8051 includes an on-chip serial port that can be programmed to operate in one of four different modes and at a range of frequencies.

• In serial communication the data is rate is known as the baud rate.

• The baud rate simply means the number of bits transmitted per second.

• In the serial port modes that allow variable baud rates, this baud rate is set by timer 1.

Page 84: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Diagram of Serial port (FIG A)

Page 85: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

• The 8051 serial port is full duplex. • In other words, it can transmit and receive data at the

same time. Shown in the Fig B Diagram of Serial port.• Location 99H the serial buffer special function register

(SBUF).• SBUF is in fact two distinct registers - the write-only

register and the read-only register.• Transmitted data is sent out from the write-only

register while received data is stored in the read-only register.

• There are two separate data lines, one for transmission (TXD) and one for reception (RXD).

• Therefore, the serial port can be transmitting data down the TXD line while it is at the same time receiving data on the RXD line.

Page 86: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

Diagram of Serial Communication (FIG B)

Page 87: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

• The TXD line is pin 11 of the microcontroller (P3.1) while the RXD line is on pin 10 (P3.0).

• Therefore, external access to the serial port is achieved by connecting to these pins.

• For example, if you wanted to connect a keyboard to the serial port you would connect the transmit line of the keyboard to pin 10 of the 8051.

• If you wanted to connect a display to the serial port you would connect the receive line of the display to pin 11 of the 8051.

• This is detailed in the Fig B Diagram of Serial Communication diagram below.

Page 88: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip

• Transmitting and Receiving Data

• Essentially, the job of the serial port is to change parallel data into serial data for transmission and to change received serial data into parallel data for use within the microcontroller.

Serial transmission is changing parallel data to serial data.

Serial reception is changing serial data into parallel data.

Both are achieved through the use of shift registers.

Page 89: ARCHITECTURE OF 8051 & THEIR PIN DETAILSsittrichy.in/Admin/FileFolder/Applications/366.pdf8051 Family Table 1-4:Comparison of 8051 Family Members Feature 8051 8052 8031 ROM (on chip