Sei sulla pagina 1di 18

Introduction to Microcontroller

1
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Lecture 29
Programming Model of 8051 and Pin
Details
Lecture delivered by:
Pranupa S

2
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Objectives
At the end of this lecture, student will be able to:

• Explain the basic criteria for choosing microcontroller


• Discuss about the programming of microcontroller
• Distinguish between higher level and lower level programming
languages
• Discuss about the preprocessor is an integral part of the
preprocessor directive
• Explain the pin details of 8051 IC

3
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Topics

• Typical Microcontrollers
• Criteria for selecting microcontroller
• Programming microcontroller
• Advantages of higher programming languages
• Pre-processor directives

4
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Introduction
Microcontroller is a smaller computer containing of on chip RAM,
ROM, I/O Ports. A good designer should always know what type of
controller to be used, there architecture, advantages, disadvantages,
way to reduce production cost and product reliability

5
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Typical Microcontrollers
• The most common microcontrollers are 8-bit.

• 4-bit are used in high volume very low cost applications

• 16 & 32 bit are used in high-end applications.

• Typical clock frequencies are 12 - 24 MHz

6
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Criteria for Selecting Microcontroller
• Primary Criterion:

 It must meet the task at hand efficiently and effectively

 Must see whether an 8-bit,16 bit, or 32 bit microcontrollers can best


handle the computing needs of the task most effectively

 Speed: Highest clock frequency the microcontroller supports

 Packaging: Comes in 40 pin DIP (Dual inline package) or a QFP (Quad


flat package) or some other packaging format. Its important in terms of
space, assembling and prototyping the end product

 Power consumption: Critical for battery powered products

 Amount of RAM and ROM on the chip


7
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Criteria for Selecting Microcontroller
 Number of I/O pins and timers on the chip
 Ease of upgrade to higher performance or lower power
consumption version
 Cost per unit
• Second Criterion
 Availability of assembler
 Debugger
 Code efficient C language compiler
 Emulator
 Technical support
 Third party support (Suppliers other than chip manufacturers)
• Third Criterion: Availability in market in needed quantities both now
and in future
8
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Programming Microcontrollers
• The microcontroller executes the program loaded in its Flash memory.
This is the so called executable code comprised of seemingly meaningless
sequence of zeros and ones

• It is organized in 12-, 14- or 16-bit wide words, depending on the


microcontroller’s architecture

• Every word is considered by the CPU as a command being executed


during the operation of the microcontroller

• The executable code is often represented as a sequence of hexadecimal


numbers called a Hex code

• All instructions that the microcontroller can recognize are together called
the Instruction set. 9
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Programming Microcontrollers
• The main advantage of this programming language is its simplicity,
i.e. each program instruction corresponds to one memory location
in the microcontroller

10
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Programming Microcontrollers (Contd.)
• Similar to assembly language, a specialized program in a PC called
compiler is in charge of compiling program into machine language.

11
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Programming Microcontrollers (Contd.)
• Example

12
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Advantages of Higher Programming languages

13
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Preprocessor is an Integral Part of the
Preprocessor Directive
• A C compiler and its function is to recognize and execute
preprocessor instructions.
• These are special instructions which do not belong to C language,
but are a part of software package coming with the compiler.
• Each preprocessor command starts with ‘#’. Prior to program
compilation, C compiler activates the preprocessor which goes
through the program in search for these signs
• In order to speed up the process of writing a program, these
commands and declarations are usually grouped in particular files
that can easily be included in the program using this directive

14
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Preprocessor Directive

15
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
8051 pin details

16
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
pins of 8051

 Vcc(pin 40):
 Vcc provides supply voltage to the chip
 The voltage source is +5V
 GND(pin 20):ground
 XTAL1 and XTAL2(pins 19,18):
 These 2 pins provide crystal input to external clock
 RST(pin 9):reset
 input pin and active high(normally low).
 The high pulse must be high at least 2 machine cycles.
 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
 power-on reset circuit

17
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences
Summary
• A designer should always know the type of controller to be used,
based on architecture, way to reduce production cost and product
reliability
• Programming of microcontroller
• Advantage of using assembly programming languages is its
simplicity
• The preprocessor is an integral part of the preprocessor directive
• The 8051 IC contains 40 pins

18
Faculty of Engineering & Technology ©M. S. Ramaiah University of Applied Sciences

Potrebbero piacerti anche