Embedded systems, 8051 microcontroller

24
SUBMITTED TO PRESENTED BY Mr. ABHISHEK SHARMA AMANDEEP SINGH 100640418009 ECE-A

description

 

Transcript of Embedded systems, 8051 microcontroller

Page 1: Embedded systems, 8051 microcontroller

SUBMITTED TO PRESENTED BYMr. ABHISHEK SHARMA AMANDEEP SINGH 100640418009 ECE-A

Page 2: Embedded systems, 8051 microcontroller

Embedded System Introduction “An embedded system is some combination of computer

hardware and software, with either fixed or programmable capabilities, that is specifically designed for a particular kind of application device”

Embedded systems are very specific, and built to handle a

particular task. Industrial machines, automobiles, airplanes, trains, medical

equipment, video cameras, phones, PDAs, home appliances, vending machines, and toys are among the many possible hosts of an embedded system.

Page 3: Embedded systems, 8051 microcontroller

Embedded Systems Are Found in.. Personal information products: Cell Phone, Digital watches,

Pocket recorder, Calculator.

Computer components: Mouse, Keyboard, Modem, Sound card.

Home appliances: Door locks, Alarm clock, Thermostat, Air conditioner, TV remote, VCR, Refrigerator, Exercise equipment, Washer/dryer, Microwave oven.

Industrial equipment: Temperature/pressure controllers, Counters, Timers, RPM Controllers.

Toys: Video games, Consoles, Remote controlled cars.

Page 4: Embedded systems, 8051 microcontroller

Why do we need to learn about Embedded Systems? Embedded Systems has witnessed tremendous growth in the last one

decade.

Nowadays nearly all the communication, digital entertainment, portable devices, are controlled by them.

Conventionally chip manufacturers laid emphasis on developing faster processors to meet the ever increasing performance requirements, but now have started manufacturing compact devices, while efficiently managing power consumption and also improving their performance.

Greater value to mobility is one of the prominent reasons for the rise and development of Embedded Technologies.

Page 5: Embedded systems, 8051 microcontroller

Microcontrollers Are designed to do some specific task. On-chip memory and ram, rom, I/O ports, timers, and other

peripherals. Used in applications where, the space circuit takes, the

power it consumes, and the price per unit are much more critical considerations than the computing power.

Example : Intel’s 8051, PIC 16C72, Motorola 68000

RAM ROM

I/O Port

TimerSerial COM Port

CPU

A single chip Microcontroller

Page 6: Embedded systems, 8051 microcontroller

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 7: Embedded systems, 8051 microcontroller

Overview of 8051 family8051 is a 8-bit microcontroller, first introduced by Intel corporation in 19818051 is the original member of the 8051 family.Other members of 8051 family8052 and 8031 are the other family members of 8051. The followingtable gives comparison of 8051 family members.

Feature 8051 8052 8031ROM(on-chip program space in bytes) 4K 8K 0K

RAM(bytes) 128 256 128

Timers 2 3 2

1/O pins 32 32 32

Serial Port 1 1 1

Interrupt sources 6 8 6

Page 8: Embedded systems, 8051 microcontroller

8-Bit CPU optimized for control applications

128 bytes RAM 4K bytes ROM Four bi-directional I/O ports UART (serial port)

Two 16-bit counters/timers 8-bit data bus-It can access 8 bits of

data in one operation 16-bit address bus-It can access 216

memory locations of RAM and ROM

Features of 8051

Page 9: Embedded systems, 8051 microcontroller

8051 PIN DESCRIPTIONP1.0

P1.1

P1.2

P1.3

P1.4

P1.5

P1.6

P1.7

RST

(RXD) P3.0

(TXD) P3.1

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

(T0) P3.4

(T1) P3.5

(WR) P3.6

(RD) P3.7

XTAL2

XTAL1

GND

P2.7 (A15)

P2.6 (A14)

P2.5 (A13)

P2.4 (A12)

P2.3 (A11)

P2.2 (A10)

P2.1 (A9)

P2.0 (A8)

PSEN

ALE/PROG

EA/VPP

P0.7 (AD7)

P0.6 (AD6)

P0.5 (AD5)

P0.4 (AD4)

P0.3 (AD3)

P0.2 (AD2)

P0.1 (AD1)

P0.0 (AD0)

Vcc

20

19

18

17

16

15

14

13

12

11

10

9

8

7

6

5

4

3

2

1

23

22

21

24

25

2627

28

29

30

31

32

33

34

35

36

37

38

39

40

8051

Page 10: Embedded systems, 8051 microcontroller

I/0 Ports8051 microcontroller has 4 I/O ports P0, P1, P2 and P3 each use 8 pins, making them 8 bit ports. All the ports upon RESET are configured as input, ready to be used as input ports. When first 0 is written to a port, it becomes output port. To reconfigure it as input, a 1 must be sent to the port.

Port 0: Port 0 occupies a total of 8 pins (pins 32-39).It can be used for input or output. To use the pins of port 0 as both input and output ports, each pin must be connected externally to a 10K ohm pull-up resistor. Port 1: Port 1 occupies a total of 8 pins (pins 1- 8). It can be used as input or output. This port does not need any pull-up resistors since it already has pull-up resistors internally.Port 2 : Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or output. Just like P1, P2 does not need any pull-up resistors.Port 3 : Port 3 occupies a total of 8 pins (pins 10 -17). It can be used as input or output. P3 does not need any pull-up resistors. Port 3 has the additional function of providing some extremely important signals such as interrupts, timers, etc.

Page 11: Embedded systems, 8051 microcontroller

Port 3 Pins Pin number Description

RXD (Pin 10) TXD (Pin 11)

Used for receiving data seriallyUsed for transmitting data serially

INT0 (Pin12) INT1 (Pin13)

External interrupt 0 External interrupt 1

T0 (Pin14) and T1 (Pin15)

Timer/counter 0Timer/counter 1

WR (Pin 16) RD (Pin 17)

Write to external memoryRead from external memory

Page 12: Embedded systems, 8051 microcontroller

Pin number DescriptionVcc (Pin 40) Provides supply voltage to the chip.

GND (Pin 20) It is the Ground.

XTAL1 (Pin19) and XTAL2 (Pin18)

The 8051 has an on-chip oscillator but requires an external clock to run it. Most often quartz crystal oscillator is connected to inputs XTAL1(Pin 19) and XTAL2(Pin 18).

RST (Pin 9) It is the input pin. Upon applying high pulse to this pin the microcontroller will reset and terminate all activities.

EA /VPP(Pin 31) Enable Access pin. EA should be connected to Vcc to indicate that the program code is stored in microcontroller's on-chip ROM. To indicate that the program is stored in external ROM this pin is connected to Ground.

PSEN (Pin 29) PSEN stands for “Program store enable” This signal is mainly used for fetching instructions from external code memory.

ALE/PROG (Pin 30) ALE(address latch enable) is an output pin and is used for both data and address transmission.

Page 13: Embedded systems, 8051 microcontroller

Timers/CountersMicrocontroller 8051 has two timers/counters:- Timer T0 Timer T1

Each are of 16 bits, so can counts 216 = 65536

Both these registers can be configured to operate either as timers or event counters.

Each counter may be programmed to count internal clock pulses acting as a timer and if programmed to count external clock pulses then it is called counter.

Page 14: Embedded systems, 8051 microcontroller

8051 Interrupts

“An interrupt is an external or internal event that disturbs the microcontroller to inform it that a device needs its service”

A Microcontroller can serve various devices. There are two ways to do that:

Interrupts Polling

The program which is associated with the interrupt is called the interrupt service routine (ISR) or interrupt handler.

Page 15: Embedded systems, 8051 microcontroller

Interrupt Vs Polling1) Interrupts

Whenever any device needs its service, the device notifies the microcontroller by sending it an interrupt signal.

Upon receiving an interrupt signal, the microcontroller interrupts whatever it is doing and serves the device.

The program which is associated with the interrupt is called the interrupt service routine (ISR) or interrupt handler.

2) Polling The microcontroller continuously monitors the status of a given

device. When the conditions met, it performs the service. After that, it moves on to monitor the next device until every

one is serviced.

Page 16: Embedded systems, 8051 microcontroller

RAM Allocation in 8051There are 128 bytes of RAM in the 8051assigned addresses from 00 to 7FH

The 128 bytes are divided into 3 differentgroups as follows:-

A total of 32 bytes from locations 00 to 1F hex are set aside for 4 register banks.

A total of 16 bytes from locations 20H to 2FH are set aside for Bit-Addressable RAM.

A total of 80 bytes from locations 30H to 7FH are used for read and write storage, called scratch pad.

Scratch Pad

Bit-Addressable RAM

Register Bank 3

Register Bank 2

Register Bank 1

Register Bank 0

Page 17: Embedded systems, 8051 microcontroller

8051 Addressing ModesThe CPU can access data in various ways, which arecalled addressing modes. Different addressing modes are:

Immediate Addressing Direct Addressing Register Addressing Register Indirect Addressing

Page 18: Embedded systems, 8051 microcontroller

Immediate Addressing Used to Load information into a register. Source operand is constant. The immediate data must be preceded by “#”

Example MOV A, #10H ; Loads 10H to A MOV R4, #10 ; Loads the decimal value 10 to R4 MOV DPTR, #1000H ; DPTR=1000H

Direct Addressing Value to be stored in memory is obtained by directly retrieving it

from another memory location. All 128 bytes of RAM can be accessed, but it is mainly used for

accessing memory locations 30-7FH.

Example MOV A,30H ; Copy data from address 30H into Accumulator.

Page 19: Embedded systems, 8051 microcontroller

Register AddressingInvolves the use of registers to hold the data to be manipulated. The source and destination registers must match in size. MOV DPTR, A will give an errorThe movement of data between Rn registers is not allowed. MOV R4, R7 is invalid

Example MOV A, R0 ; Copy the contents of R0 into A MOV R4, A ; Copy the contents of A into R4 ADD A, R7 ; Adds contents of R7 to the contents of A

Register Indirect Addressing An address is considered to be the address of an address, rather than the address of a value.Only registers R0 and R1 are used for this purpose

Example MOV A, @R1 ; The value inside R1 is considered as an address, which holds the data to be transferred to accumulator.

Page 20: Embedded systems, 8051 microcontroller

Applications Of Microcontrollers Energy Management: Efficient metering systems help in controlling energy

usage in homes and industrial applications. These metering systems are made capable by incorporating microcontrollers.

Touch screens: Large number of microcontroller providers incorporate touch-sensing capabilities in their designs. Portable electronics such as cell phones, media players and gaming devices are examples of microcontroller-based touch screens.

Automobiles: 8051 finds wide acceptance in providing automobile solutions. They are widely used in hybrid vehicles to manage engine variants. Additionally, functions such as cruise control, anti-brake system, fuel management, safety system have been made more efficient with the use of microcontrollers.

Medical Devices: Portable medical devices such as blood pressure and glucose monitors use microcontrollers will to display data, thus providing higher reliability in providing medical results.

Page 21: Embedded systems, 8051 microcontroller

Recent Wonders

“Hand Speak”

Enhance the abilities of deaf and dumb people.

M16/62 converts American Sign Language (ASL) movements into alphanumeric characters that are displayed on lcd.

Characters can also be transferred/viewed on PC or hand-held device PDA.

Page 22: Embedded systems, 8051 microcontroller

“Weasure”

A clever system designed not only to weight, but also to measure packages of shipments.

With a touch of a button the weight and dimensions are shown on display and uploaded to PC through serial port.

Recent Wonders

Page 23: Embedded systems, 8051 microcontroller

“Shoes”

The microprocessor embedded in this adidas running shoe calculates the pressure between the runner's foot and the ground five million times per second and continuously changes the cushioning to match an adjustable comfort level.

The computer controls a motor that lengthens and shortens a cable attached to a plastic cushioning element.

Recent Wonders

Adidas Salomon AG

Page 24: Embedded systems, 8051 microcontroller