Professional Documents
Culture Documents
of Electronics VESIT
Microcontroller-8051 (AD)
Contents:
Introduction Block Diagram and Pin Description of the 8051 Registers Some Simple Instructions Structure of Assembly language and Running an 8051 program Memory mapping in 8051 8051 Flag bits and the PSW register Addressing Modes 16-bit, BCD and Signed Arithmetic in 8051 Stack in the 8051 LOOP and JUMP Instructions CALL Instructions I/O Port Programming
Microcontroller-8051 (AD)
Introduction
General-purpose microprocessor
CPU for Computers No RAM, ROM, I/O on CPU chip itself ExampleIntels x86, Motorolas 680x0
CPU GeneralPurpose Microprocessor
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
Microcontroller-8051 (AD)
Microprocessor CPU is stand-alone, RAM, ROM, I/O, timer are separate designer can decide on the amount of ROM, RAM and I/O ports. expansive versatile general-purpose
Microcontroller-8051 (AD)
Microcontroller CPU, RAM, ROM, I/O and timer are all on a single chip fixed amount of on-chip ROM, RAM, I/O ports for applications in which cost, power and space are critical single-purpose
Embedded System
Embedded system means the processor is embedded into that application. An embedded product uses a microprocessor or microcontroller to do one task only. In an embedded system, there is only one application software that is typically burned into ROM. Exampleprinter, keyboard, video game player
Microcontroller-8051 (AD)
2.
3.
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 Availability of software development tools Assemblers, Debuggers, C compilers, emulator, Simulator, Technical support Wide availability and reliable sources of the microcontrollers.
Microcontroller-8051 (AD)
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
Microcontroller-8051 (AD)
8051 Family
Feature 8051 8052
ROM (program space in bytes) (bytes) Timers I/O pins Serial port Interrupt sources
4K 128 2 32 1 6
8K 256 3 32 1 8
Microcontroller-8051 (AD)
Microcontroller-8051 (AD)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
8051 (8031)
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
Vcc P0.0(AD0) P0.1(AD1) P0.2(AD2) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) EA/VPP ALE/PROG PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8)
Pins of 80511/4
Vccpin 40 Vcc provides supply voltage to the chip. The voltage source is +5V. GNDpin 20 ground XTAL1 and XTAL2 pins 19,18 These 2 pins provide external clock. Way 1 using a quartz crystal oscillator Way 2 using a TTL oscillator
Microcontroller-8051 (AD)
Pins of 80512/4
RSTpin 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 are fixed.
Microcontroller-8051 (AD)
Pins of 80513/4
/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.
/PSEN pin 29 Program Store Enable This is an output pin and is connected to the OE pin of the ROM.
Microcontroller-8051 (AD)
Pins of 80514/4
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.
The four ports P0, P1, P2, and P3. Each port uses 8 pins. All I/O pins are bi-directional.
Microcontroller-8051 (AD)
Using a quartz crystal oscillator We can observe the frequency on the XTAL2 pin.
Microcontroller-8051 (AD)
N C
XTAL2
XTAL1
GND
Microcontroller-8051 (AD)
Example :
Find the machine cycle for
Solution:
(a) 11.0592 MHz / 12 = 921.6 kHz; machine cycle = 1 / 921.6 kHz = 1.085 s
Microcontroller-8051 (AD)
19
Microcontroller-8051 (AD)
The 8051 has four I/O ports Port 0 pins 32-39 P0 ( P0.0 . P0.7 ) Port 1pins 1-8 P1 ( P1.0 . P1.7 ) Port 2pins 21-28 P2 ( P2.0 . P2.7 ) Port 3pins 10-17 P3 ( P3.0 . P3.7 ) Each port has 8 pins. Ex P0.0 is the bit 0 LSB of P0 ExP0.7 is the bit 7 MSB of P0
Microcontroller-8051 (AD)
Microcontroller-8051 (AD)
Registers
A B R0 DPTR R1 R2 R3 R4 R5 R6 R7 Some 8-bitt Registers of the 8051 PC PC DPH DPL
Microcontroller-8051 (AD)
Microcontroller-8051 (AD)
Microcontroller-8051 (AD)
Microcontroller-8051 (AD)