A Presentation On Microcontroller 8051
A Presentation On Microcontroller 8051
INTRODUCTION:
8051 belongs to MCS-51 family of microcontrollers MCS-51 was developed by Intel but other manufacturers (e.g., Siemens, Philips) are second sources of this family. Features of the standard 8051 4K bytes internal ROM (program) 128 bytes internal RAM (data) Four 8-bit I/O ports Two 16-bit timers Serial interface 64K external code memory space 64K external data memory space 210 bit-addressable locations
Instruction set: Microprocessor instruction sets are processing Intensive Their instructions operate on nibbles, bytes, words, or even double words.
Addressing modes provide access to large arrays of data using pointers and offsets.
Microcontroller instruction sets cater to control of inputs and outputs They have instructions to set and clear individual bits and perform bit operations. They have instructions for input/output operations, event timing, enabling and setting priority levels for interrupts caused by external stimuli. Processing power of a microcontroller is much less than a microprocessor
8051 implements a separate memory space for programs (code) and data. Both code and data may be internal, however, both expand using external components to a maximum of 64K code memory and 64K data memory. Internal memory consists of on-chip ROM and on-chip data RAM. On-chip RAM contains a rich arrangement of general purpose storage, bit addressable storage, register banks, and special function registers. In the 8051, the registers and input/output ports are memory mapped and accessible like any other memory location. In the 8051, the stack resides within the internal RAM, rather than in external RAM.
Register Banks
The bottom 32 locations of internal memory contain the register banks 8051 supports 8 registers R0 to R7 and after a system reset (default) the registers are at address 00H to 07H MOV A, R5: reads the content of address 05H into the accumulator MOV A,05H will do the same thing The active register bank may be altered by changing the register bank select bits in the Program Status Word (PSW) Idea of register banks permits fast and effective context switching
Special Function Registers 8051 has 21 special function registers (SFRs) at the top of internal RAM from address 80H to FFH. Most of the addresses from 80H to FFH are not defined, except for 21 of them. Some SFRs are both bit-addressable and byte addressable, depending on the instruction accessing the register
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
1 3P 2 2P P 3 3P 4 2E 5 A 6 7 8 9 R ( 4V 1 X 1 2 G 14 S3 R0c 0 7A T90 1 6S I 82 2 5L 34 43 W0 52 61 70 89 T6 98 2 07 N5 1 . c T . X . N . 0 E 1 R / D A 0 5 1 3 2 4 1 3 7 4 0 5 V 6 1 6 7 3 D 0 / T 2 N ) 5 L 4 2 ( ) ( 0 P 1 ( P 2 1 P A R ) A 3 P D D 3 1 O P 9 . 8 1 3 4 5 6 7 . 0 G 3 2 4 3 5 2 6 4 7 1 0 ) ) 0 ) 1 ) . 2 3
8 0 5 1 ( 8 0 3 1 )
8051 (8031)
Vccpin 40 Vcc provides supply voltage to the chip. The voltage source is +5V. GNDpin 20ground XTAL1 and XTAL2pins 19,18 These 2 pins provide external clock. Way 1using a quartz crystal oscillator Way 2using a TTL oscillator Example 4-1 shows the relationship between XTAL and the machine cycle.
The high pulse must be high at least 2 machine cycles. 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
It is a power-on reset.
/EApin 31external 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. /PSENpin 29program store enable This is an output pin and is connected to the OE pin of the ROM.
The high pulse must be high at least 2 machine cycles. 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
It is a power-on reset.
Important features :
8-bit ALU, Accumulator and Registers; hence it is an 8-bit microcontroller 8-bit It provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer, etc.) in a single package data bus - It can access 8 bits of data in one operation 16-bit address bus - It can access 216 memory locations - 64 kB ( 65536 locations ) each of RAM and ROM
On-chip RAM - 128 bytes ("Data Memory") On-chip ROM - 4 kB ("Program Memory") Four byte bi-directional input/output port UART (serial port) Two 16-bit Counter/timers Two-level interrupt priority Power saving mode
Addressing Modes
Register Direct Register Indirect Immediate Relative Absolute Long Indexed
Interrupts
1. 2. 3.
Enabling and Disabling Interrupts Interrupt Priority Writing the ISR (Interrupt Service Routine)
Interrupt :
Advantages
Popular - readily available and widely supported, a full range of free and commercial support products is available Low cost - high level of system integration within one component, only a handful of components needed to create a working system. Constant improvements - improvements in silicon/design increase speed
Wide range - One set of tools covers the greatest horsepower range of any microcontroller family, the 8051 provides a real cost savings in tools, training, and software support. - Compatibility - opcodes and binaries are the SAME for all 80x51 variants (unlike most other microcontroller families). Multi-sourced - over 12 manufacturers, hundreds of varieties, something for everyone with the security of ready availability.
Applications:
Engine management systems in automobiles. Keyboard of a PC. Electronic measurement instruments (such as digital multimeters, frequency synthesisers, and oscilloscopes) Printers. Mobile phones. Televisions, radios, CD players, tape recording equipment. Hearing aids. Security alarm systems, fire alarm systems, and building services systems