25
Orientation To 8051Programming Yogesh Misra Mody Institute of Technology & Science (Deemed University) Faculty of Engineering & Technology Sikar [Raj.]

8051 Programming

Embed Size (px)

DESCRIPTION

8051 Basics

Citation preview

Page 1: 8051 Programming

Orientation

To

8051Programming

Yogesh MisraMody Institute of Technology & Science(Deemed University)Faculty of Engineering & TechnologySikar [Raj.]

Page 2: 8051 Programming

Sensor ADC Processor ActuatorDAC

Embedded System Structure

Essential Components

• Processor (µP, µC , DSP or ASIC)

• Sensor (it convert a physical quantity into electrical signal)

• Converters (ADC and DAC)

• Actuator (it transforms electrical energy into mechanical energy)

• Memory (On-chip / Off chip)

• Communication path with the interacting environment

Page 3: 8051 Programming

DEVELOPMENT OF MICROPROCESSORFirst Generation (1940-1956) Vacuum Tubes

First generation computers relied on machine language

Page 4: 8051 Programming

Back section of ENIAC showing vaccum tubesThe 1946 ENIAC computer used 17,468 vacuum tubes and consumed 150kW of power

Page 5: 8051 Programming

Second Generation (1956-1963) Transistors

The transistor was invented in 1947

Vaccum tubes of first generation computer are now replaced by semiconductor devices.

Second-generation computers moved from machine language to assembly languages.

DEVELOPMENT OF MICROPROCESSOR

Page 6: 8051 Programming

Third Generation (1964-1971) Integrated Circuits

The first integrated circuit (IC) was developed in the 1950s by Jack Kilby of Texas Instruments and Robert Noyce of Fairchild Semiconductor.

Fourth Generation (1971-Present) Microprocessors

The microprocessor brought the fourth generation of computers, as thousands of integrated circuits were built onto a single silicon chip.

The Intel 4004 chip, developed in 1971

DEVELOPMENT OF MICROPROCESSOR

Page 7: 8051 Programming

Accumulator Flags

B C

D E

H L

Program Counter

Stack Pointer

Timing & Control

Unit

ALU Address Lines

Data Lines

Timing & Control Signals

INSIDE MICROPROCESSOR

Page 8: 8051 Programming

MICROPROCESSOR BASED SYSTEM

Page 9: 8051 Programming

EXPANDED MICROPROCESSOR BASED SYSTEM

Page 10: 8051 Programming

MEMORY

Page 11: 8051 Programming

LANGUAGE

Machine Language: Instructions in binary form.

Assembly language: Instructions in mnemonic form.

High-Level language: Program is written using statements.

Page 12: 8051 Programming

PROGRAMMING EXAMPLE

Program Explanation Hex Code Binary Code

MVI A , 04H A = 04H 45H , 04H 01000101 00000100

MVI B , 05H B = 05H 59H , 05H 01011001 00000101

ADD B A = A + B 24H 00100100

OUT 20 H Send the content of register A to output device whose address is 20H

29H , 20H 00101001 00100000

HLT Stop 76H 01110110

Page 13: 8051 Programming

Memory Address Binary Information

0000H MVI A [01000101]

0001H 04H [00000100]

0002H MVI B [01011001]

0003H 05H [00000101]

0004H ADD B [00100100]

0005H OUT [00101001]

0006H 20 H [00100000]

0007H HLT [01110110]

0008H

FFFFH

PROGRAMMING EXAMPLE

Page 14: 8051 Programming

MICROCONTROLLER

First microcontroller By Intel In 1976 4 bit 8048

First 8 bit microcontroller by Intel was 8051 (reffered as MCS-51) in 1981 

Page 15: 8051 Programming

Vcc(+5volt)Pin - 40

Ground(0 volt)Pin-20

Pin Description

Page 16: 8051 Programming

Pin Description

Port 0 fromPin-39 to pin-32

Used to excess bothdata & address

Dual functional

Page 17: 8051 Programming

Microcontroller 8051Pin Description

Port 1 fromPin-1 to pin-8

Used as I/O port

Page 18: 8051 Programming

Pin Description

Port 2 fromPin-21 to pin-28

Used to excessaddress & as I/O port

Page 19: 8051 Programming

Microcontroller 8051Pin Description

Port 3 from Pin-10 to Pin-17

P3.0 RXDP3.1 TXDP3.2 IN T0P3.3 IN T1P3.4 T0

P3.5 T1P3.6 WRP3.7 RD

Page 20: 8051 Programming

Pin Description

reset

crystal

External memory

Add. Latch enable

Program Store Enable

Page 21: 8051 Programming

Tools for developing Assembly Language Programs

Integrated Development Environment

Development Processor

Target Processor

Editor Program

Assembler Program

Debugger

Loader / Linker Program

Editor Assembler LinkerSource file (.a51)

Program Object file (.obj), List file (.LST), check syntax errors

Hex file (.hex)

MICROCONTROLLER

Loader

Page 22: 8051 Programming

Demo of downloading of a program in microcontrollerAIM: Write a program for traffic light control. The microcontroller AT89C51-20P is operated by a XTAL of frequency 11.0592 Mhz.

STEPS GREEN YELLOW RED

1 ON OFF OFF

2 ON ON OFF

3 OFF OFF ON

4 OFF ON ON

Page 23: 8051 Programming

AT89C51

P2.2

P2.1

P2.0

RED

YELLOW

GREEN

Reset

PINS OF INTERESTP2.0 Pin no. 20

P2.1 Pin no. 21

P2.2 Pin no. 22

Reset Pin no. 9

XTAL2 Pin no. 18

XTAL2 Pin no. 19

GND Pin no. 20

Pin no. 40 Vcc

Pin no. 31 EA

Page 24: 8051 Programming

HEX FILE

:10000000B29012000780F97B207AFF79FFC055D0AB:0C00100055C055D055D9F6DAF2DBEE22CF:00000001FF

• Red color hexadecimal number tells the loader how many bytes are in the line. (number of bytes in a line range from 00H to 10H)

• Blue color hexadecimal number is 16 bit ROM address where loader will load the first byte.

• Green color digits are either “00” or “10”.

“00” means is more line to come after this line.

“01” means this is last line and the loading should stop after this line.

Black Color this is hex code of the program

Brown Color last byte in the line is checksum byte used for error checking

Page 25: 8051 Programming

Thank You