Download - 8051 basics
![Page 1: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/1.jpg)
8051 microcontroller
Vishnu chittan.M
![Page 2: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/2.jpg)
What is an Embedded System? Application-specific systems which contain hardware and
software tailored for a particular task and are generally part
of a larger system.
Characteristics
Are dedicated to a particular application.
Include processors dedicated to specific functions.
Represent a subset of reactive (responsive to external
inputs) systems.
Contain real-time constraints.
![Page 3: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/3.jpg)
Embedded Systems Applications
Aerospace Navigation systems, automatic landing systems, flight attitude controls, engine controls, space exploration (e.g.. The mars pathfinder)
Automotive Fuel injection control, passenger environmental controls, anti-locking braking systems, air bag controls, GPS mapping, cruise control
Children's toys Video games, MindStone system
Communication
Satellites, network routers, switches, hubs
![Page 4: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/4.jpg)
Computer Peripherals
Printers, scanners, keyboards, displays, modems, hard disk drives, CD-ROM drives, USB
Home Dishwashers, microwave ovens, VCR’s, DVD, televisions, stereos, fire/security alarm systems, lawn sprinkler controls, thermostats, digital cameras, clock radios, cell phones
Industrial Elevator controls, surveillance systems, robots
Instrumentation Data collection, oscilloscopes, signal generators, signal analyzers, power supplies
Embedded Systems Applications
![Page 5: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/5.jpg)
Medical CT, One touch glucose meter, almost all medical facility
Office Automation
FAX machines, copiers, telephones,
Personal PDA’s, pagers, cell phones, video games, Ipod, MP3 players
Embedded Systems Applications
![Page 6: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/6.jpg)
Essential ComponentsEssential components :-
- Microcontroller / DSP core
- Sensors
- Converter ( A-D and D-A )
- Actuators
- Memory (on-chip and off-chip )
- Communication path with interfacing
environment
![Page 7: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/7.jpg)
Why do we need to learn Microcontrollers ?
• Its not an exaggeration if I say that ,today there is no
electronic gadget on the earth which is designed without a
Microcontroller. Ex: communication devices, digital
entertainment, portable devices etc…
Not believable ??? See the next slide
![Page 8: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/8.jpg)
• Personal information products: Cell phone, pager, watch, pocket
recorder, calculator
• Laptop components: mouse, keyboard, modem, fax card, sound
card, battery charger
• Home appliances: door lock, alarm clock, thermostat, air
conditioner, TV remote, VCR, small refrigerator, exercise
equipment, washer/dryer, microwave oven
• Industrial equipment: Temperature/pressure controllers,
Counters, timers, RPM Controllers
• Toys: video games, cars, dolls, etc.
![Page 9: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/9.jpg)
So, A good designer should always know what type of controller he/she is using ,their architecture, advantages , disadvantages , ways to reduce production costs and product reliability etc….
![Page 10: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/10.jpg)
Then What is a Microcontroller ? • A smaller computer
• On-chip RAM, ROM, I/O ports...
• Example : Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC
16X
RAM ROM
I/O Port
TimerSerial COM Port
CPU
A single chip Microcontroller
![Page 11: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/11.jpg)
How is it different from a Microprocessor ??
CPU for ComputersNo RAM, ROM, I/O on CPU chip itself
Example: Intel’s x86, Motorola’s 680x0
CPU
General-Purpose Micro-processor
RAM ROM I/O Port
TimerSerial COM Port
Data Bus
Address Bus
![Page 12: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/12.jpg)
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 versatility general-purpose
Microcontroller• CPU, RAM, ROM, I/O and
timer are all on a single chip• fix amount of on-chip ROM,
RAM, I/O ports• Highly bit addressable• for applications in which cost,
power and space are critical• single-purpose
Microprocessor vs. Microcontroller
![Page 13: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/13.jpg)
EVOLUTION Flashback !!!!
In the year 1976, Motorola created a Microprocessor chip called 6801 which replaced its brother 6800 with certain add-on chips to make a computer. This paved the way for the new revolution in the history of chip design and gave birth to a new entity called
MICROCONTROLLER.
The INTEL bagged the credit of producing the first Microcontroller 8048 with a CPU and 1K bytes of EPROM, 64 Bytes of RAM an 8-Bit Timer and 27 I/O pins in 1976.
![Page 14: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/14.jpg)
Evolution contd…• Then followed the most popular controller 8051 in the year
1980 with 4K bytes of ROM,128 Bytes of RAM , a serial port, two 16-bit Timers , and 32 I/O pins.
• The 8051 family has many additions and improvements over the years and remains a most soughtafter tool for todays circuit designers.
• The same INTEL introduced a 16 bit controller 8096 in the year 1982
![Page 15: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/15.jpg)
• Later INTEL introduced 80c196 series of 16-bit microcontrollers for mainly industrial applications
• Microchip, another company has introduced a microcontroller PIC 16C64 an 8-bit in the year 1985.
• 32-bit microcontrollers have been developed by IBM and Motorola-MPC 505 is a 32-bit RISC controller of Motorola
• The 403 GA is a 32 -bit RISC embedded controller of IBM
![Page 16: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/16.jpg)
ARM Controllers• In recent times ARM company (Advanced Risc machines)
has developed and introduced 32 bit controllers which are highend application devices,especially communication devices like mobiles , ipods etc..(Refer www.arm.com)
![Page 17: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/17.jpg)
Types of Microcontrollers
![Page 18: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/18.jpg)
Microcontrollers from different manufacturers
•Atmel •ARM •Intel
• 8-bit • 8XC42 • MCS48 • MCS51 • 8xC251
• 16-bit • MCS96 • MXS296
•National Semiconductor • COP8
•Microchip • 12-bit instruction PIC • 14-bit instruction PIC
• PIC16F84 • 16-bit instruction PIC
•NEC
•Motorola • 8-bit
• 68HC05 • 68HC08 • 68HC11
• 16-bit • 68HC12 • 68HC16
• 32-bit • 683xx
•Texas Instruments • TMS370 • MSP430
•Zilog • Z8 • Z86E02
![Page 19: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/19.jpg)
MCS-51 “Family” of MicrocontollersFeature 8031 8051 8052 8751 ROM NO 4kB 8kB 4kB UV
Eprom
RAM (Bytes) 128 128 256 128
TIMERS 2 2 3 2
I/O PINS 32 32 32 32
SERIAL PORTS 1 1 1 1
INTERRUPT 6 6 8 6 SOURCES
![Page 20: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/20.jpg)
Microcontroller Architectures
CPUProgram + Data
Address Bus
Data Bus
Memory
Von NeumannArchitecture
CPUProgram
Address Bus
Data Bus
HarvardArchitecture
Memory
Data
Address Bus
Fetch Bus
0
0
0
2n
![Page 21: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/21.jpg)
Important Features of 8051
•4K bytes ROM•128 bytes RAM•Four 8-bit I/O ports•Two 16-bit timers•Serial interface•64K external code memory space•64K data memory space
![Page 22: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/22.jpg)
“Original” 8051 MicrocontrollerOscillator and timing
4096 Bytes Program Memory
(ROM)
128 BytesData Memory
(RAM)
Two 16 Bit Timer/Event
Counters
8051 CPU
64 K Byte Bus Expansion
Control
Programmable I/O
Programmable Serial Port Full Duplex UART
Synchronous Shifter
Internal data bus
External interrupts
subsystem interrupts
Control Parallel portsAddress Data BusI/O pins
Serial InputSerial Output
![Page 23: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/23.jpg)
Pin Description of the 8051
• The 8051 is a 40 pin device, but out of these 40 pins, 32 are used for I/O.
• 24 of these are dual purpose, i.e. they can operate as I/O or a control line or as part of address or date bus.
![Page 24: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/24.jpg)
24
Inside Architecture of 8051
CPU
On-chip RAM
On-chip ROM for program code
4 I/O Ports
Timer 0
Serial Port
Inside the 8051 Microcontroller Block Diagram
OSC
Interrupt Control
External interrupts
Timer 1
Timer/Counter
Bus Control
TxD RxDP0 P1 P2 P3
Address/Data
Counter Inputs
![Page 25: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/25.jpg)
Microcontroller Packaging and Appearance
25
![Page 26: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/26.jpg)
26
Three criteria in Choosing a Microcontroller
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.
![Page 27: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/27.jpg)
27
![Page 28: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/28.jpg)
28
A Pin on Port 1
D Q
Ck Q
VccLoad (L1)
Read latch
Read pin
Write to latch
Internal CPU bus
M1
P1.X pinP1.X
TB1
TB2
![Page 29: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/29.jpg)
29
A Pin of Port 0
D Q
Clk Q
Read latch
Read pin
Write to latch
Internal CPU bus
M1
P0.X pinP0.X
TB1
TB2
![Page 30: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/30.jpg)
30
Memory mapping in 8051 ROM memory map in 8051 family
0000H
0FFFH
0000H
1FFFH
0000H
7FFFH
8751AT89C51 8752
AT89C52
4k
DS5000-32
8k 32k
from Atmel Corporationfrom Dallas Semiconductor
![Page 31: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/31.jpg)
31
221-Introduction to Embedded C
![Page 32: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/32.jpg)
32
Advantages It is a ‘mid-level’, with ‘high-level’ features (such as
support for functions and modules), and ‘low-level’
features (such as good access to hardware via
pointers) C is the most common Embedded language 85%, of
embedded applications are coded in C. It directly manipulates the hardware and memory
addresses. Cx51 Cross compiler supports all of the ANSI Standard
C directives.
![Page 33: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/33.jpg)
33
Data Types Data types Bits Bytes Value range • Bit 1 0 to 1• Signed char 8 1 -128 to +127• Unsigned char 8 1 0 to 255• Signed short 16 2 -32768 to +32767 • Unsigned short 16 2 0 to 65535• Signed int 16 2 -32768 to +32767 • Unsigned int 16 2 0 to 65535• Signed long 32 4 -2147483648 to
2147483647 • Unsigned long 32 4 0 to 4294967295• Float 32 4 ±1.175494E-38 to
±3.402823E+38 • sbit 1 0 to 1 • sfr 8 1 0 to 255
![Page 34: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/34.jpg)
34
8051 Memory Areas
• The 8051 architecture supports a number of
physically separate memory areas for program and
data. Each memory area offers certain advantages and
disadvantages.
Program Memory code Internal Data memory bdata, data,
idata External Data memory xdata, pdata
![Page 35: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/35.jpg)
35
code: Program memory (64 Kbytes); accessed by opcode
MOVC A, @A+DPTR.
data: Directly addressable internal data memory; fastest
access to full internal address space (256 bytes).
idata: Indirectly addressable internal data memory; accessed
across the internal address space (128 bytes).
bdata: Bit-addressable internal data memory; allows mixed
bit and byte access (16 bytes).
xdata: External data memory (64 Kbytes); accessed by
opcode
MOVX @DPTR. pdata: Paged (256 bytes) external data memory; accessed
by
opcode . MOVX @Rn.
Explicitly declared Memory types
![Page 36: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/36.jpg)
36
Memory models The memory model determines which default memory
type to use for automatic variables, and declarations with
no explicit memory type specifier. If the memory type specifier is omitted in a variable
declaration, the default or implicit memory type is
automatically selected. Automatic variables which cannot be located in registers
are also stored in the default memory area. The default memory type is determined by the SMALL,
COMPACT and LARGE compiler control directives.
![Page 37: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/37.jpg)
37
Small Model: Internal RAM 128 bytes
All variables, by default, reside in the internal data
memory of the 8051 system. It is the same as if they were declared explicitly using the
data memory --type specifier. Variable access is very efficient. Stack size is critical
because the real stack size depends upon the nesting
depth of the various functions. Using this memory model, the number of global variables
must be kept to a minimum to allow. However the amount
of space required for the stack must be kept in mind.
![Page 38: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/38.jpg)
38
Compact Model: RAM 256 bytes off-chip All variables, by default, reside in one page of external
data memory. It is as if they were explicitly declared using the pdata
memory type specifier. This memory model can
accommodate a maximum of 256 bytes of variables.
The limitation is due to the addressing scheme used,
which is indirect through registers R0 and R1 (@R0,
@R1.
![Page 39: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/39.jpg)
39
Compact Model: RAM 256 bytes off-chip The compact model is rarely used for an entire
program, but more usual in combination with the SMALL switch
reserved for interrupt routines. COMPACT is especially useful for programs with
a large number of medium speed 8 bit variables.
![Page 40: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/40.jpg)
40
Large Model: Total RAM up to 64KB
In this model, all variables, by default, reside in external
data memory (up to 64 Kbytes). It is the same as if they were explicitly declared using
the xdata memory type specifier. Memory access through this data pointer is inefficient,
especially on variables with a length of two or more
bytes. This type of data access mechanism generates more
code than the small or compact models, Permits slow
access to a very large memory space .
![Page 41: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/41.jpg)
Interfacing Dip Switches and Interfacing LEDs
![Page 42: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/42.jpg)
(a)
(b)
Interfacing Push-Button Keys
![Page 43: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/43.jpg)
What is a Keypad ? Collection of keys interfaced
to the microcontroller
Arranged in the form of two
dimensional matrix
Matrix arrangement used for
minimizing the number of
port lines
Junction of each row and
column forms the key
![Page 44: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/44.jpg)
Interfacing a Keyboard
![Page 45: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/45.jpg)
Applications of Microcontrollers
![Page 46: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/46.jpg)
Simple Interfacing Examples
![Page 47: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/47.jpg)
Seven segment Interfacing
![Page 48: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/48.jpg)
Traffic light controller
![Page 49: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/49.jpg)
![Page 50: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/50.jpg)
Closed loop control system-Temperature control example
![Page 51: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/51.jpg)
![Page 52: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/52.jpg)
![Page 53: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/53.jpg)
![Page 54: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/54.jpg)
![Page 55: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/55.jpg)
![Page 56: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/56.jpg)
![Page 57: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/57.jpg)
![Page 58: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/58.jpg)
![Page 59: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/59.jpg)
Home automation system
![Page 60: 8051 basics](https://reader034.vdocuments.site/reader034/viewer/2022051404/58cf9eeb1a28ab6b088b4797/html5/thumbnails/60.jpg)
Single Axis solar tracking system