KEMBAR78
Basics of micro controllers for biginners | PPT
ETU 07421:
MICROPROCESSOR
APPLICATIONS
CLASS NOTES
MICROPROCESSORS
Overview
MICROPROCESSOR
Microprocessor
• Is a programmable digital component that in cooperates
the function of CPU on a single semiconducting
integrated circuit.
• Is the integration of number of useful function into a
single IC package that has;
-Ability to execute a stored set of instruction to carry out
user defined task.
- Ability to access the external memory chips to both read
and write data to and from the memory
Functional Block of
Microprocessor
Basic architecture
• Von neumann Architecture.
• Harvard architecture
Von Neumann Architecture.
• The design has a single memory bank for
storing both program and data.
• It has single bus which is multiplexed to be used
as both address bus and data bus.
• The content of RAM can be used for both
variable storage as well as program storage.
Harvard Architecture
• Separate memory banks for program and data
storage.
• It has RAM for data storage and separate ROM
for storing program
• It has two separate address bus for
-Program memory
- Data memory
Comparison
Von Neumann Versus Harvard
Von Neumann Harvard
• Single memory for both
program and data
• Separate memory for
program and data
• Single bus used to access
both data and memory
• Separate buses available to
access program and data
• Instruction parallelism is not
possible
• Instruction parallelism can
be done
• It takes more than one
machine cycle (Fetching and
execution are done)
• It takes only one machine
cycle. Fetching and
execution are done
simultaneous
Advantages of Von Neumann
Architecture
• It simplifies the microcontroller chip design
because only one memory is accessed.
• The content of RAM can be used for both
variable (data) as well as program
(instruction) storage
Advantages of Harvard
Architecture
• The Harvard architecture tends to execute
instruction in fewer instruction cycle than
Von Neumann architecture. This is
because greater amount of parallelism is
possible.
Instruction Set
• CISC- Complex Instruction Set Computer
• RISC- Reduced Instruction Set Computer
Complex Instruction Set
Computer
• Is Microprocessor that understand large number
of complex instruction but it process them
relatively slowly
• Internal instruction involves many individual
execution steps and thus many clock cycles.
• The design is complex, costly and also
instruction set consist of more than 100
instruction
Reduced Instruction Set
Computer
• Is Microprocessor that uses relatively
simple architecture with fewer built in
command.
• Increase in speed.
• Design is relatively simpler, economical
and usually has less than 100 instructions
Comparison
RISC versus RISC
RISC CISC
• Less number of Instruction • More number of Instruction
• All are single cycle instruction • Each instruction take at least 2 or 3
machine cycle.
• Design of architecture is easier and
cheap
• Design of architecture is complex
and costly
• Program length get increased due
to shortage of instructions
• Program length is less because
variety of instructions is available
• Execution speed is faster since most
instruction are single cycled
• Execution speed is low since the
instruction takes many machine
cycles
• Example; PIC series, ARM
processors
• Examples; 8051 families, Pentium
MICROCONTROLLERS
 Is a small (micro) single chip computer designed to
perform a specific function, and the specific function is to
control objects, process or events.
 It is dedicated to one task or set of closely related task. It
is similar to PC(it has similar components but onto a
single chip)
-CPU, memory (ROM and RAM).
-I/O ports, serial ports.
- Timers e.t.c
Functional block of
Microcontroller
Comparison
Microprocessor Versus Microcontroller
Microprocessor Microcontroller
• Memoryhastobeinterfacedexternally • Hasinbuiltprogramanddatamemory
• I/Oportshastobeinterfaced • HasInbuiltdigital/analogueI/Oports
• HasnointernalTimers,serialportsetc • HasTimer,serialportsandotherfeatures
• Highclockrates >3GHz • Slowclockrates(4–20MHz)
• Buswidthverywide • Buswidthverynarrow
• Expensive • Lessexpensive
In Summary
Microprocessor
Is a general purpose chip and is used in multifunction
computer or device with the help of multiple chips to
handle various tasks
Microcontroller
Is a self contained, CPU, RAM, ROM, I/O ports and Timers
on the same chip function independently as a single chip
computer dedicated to specific task to control single
system
Why Microcontroller?
• Task specific.
• Add computer power to the device to enable it to perform
more better at low cost.
• Low cost, small packaging, low power requirements.
• Ideal for application in which low cost, power and space
is crucial.
• Easy integration with other circuits
• Programmable and re-programmable.
Embedded System
• The system to control, monitor or assist the
operation of equipment, machinery or plant.
The term “Embedded” reflect the fact that they are
integral part of the system they control.
Common characteristics of
Embedded Systems
• Specific and single functioned
Execute a single instruction repeatedly
• Optimized for hardware
Compact, low cost, fast, low power.
• Reactive and operated in real time
PIC Microcontrollers
MICROCONTROLLER BASED
PROJECTS
HOW TO SELECT A SUITABLE
MICROCONTROLLER FOR THE
PROJECT
Step 1: Make a list of required
hardware interfaces
Step 2: Examine the software
architecture
• How heavy or how light the processing requirements will
determine whether you go with an 80 MHz DSP or an 8
MHz 8051
• Are there any high frequency control loops or sensors?
• Estimate how long and how often each task will need to
run
• How much processing power will be needed.
• The amount of computing power required will be one of
the biggest requirements for the architecture and
frequency of the microcontroller.(how fast a machine can
perform an operation).
Step 3: Select the architecture
• Can the application get by with eight bit
architectures? How about 16 bits? Does it
require a 32 bit ARM core?
• Microcontroller selection can be an
iterative process. You may select a 16-bit
part in this step but then in a later step find
that a 32 bit ARM part works better.
Step 4: Identify Memory Needs
• Flash and RAM are two very critical
components of any microcontrollers.
Making sure that you don’t run out of
program space or variable space is
undoubtedly of highest priority.
Step 5: Start searching for
microcontrollers
• One place that can be a good place to
start is with a microcontroller supplier
Step 6: Examine Costs and
Power Constraints
• Examine the power requirements and cost
of the part.
 If the device will be powered from a battery and
mobile, then making sure the parts are low-power
 If it doesn’t meet power requirements then keep weeding
the list down until you have a select few.
Step 7: Check part availability
• Starts checking on how available the part
is.
• What are your requirements for
availability?
Step 8: Select a development kit
• One of the best parts of selecting a new
microcontroller is finding a development kit
to play with and learn the inner working of
the controller.
Step 9: Investigate compilers
and tools
• Examine the compiler and tools that are
available.
 It is important to make sure that all the necessary
tools are available for the part. Without the right tools the
development process could become tedious and
expensive.
Step 10: Start Experimenting
Programming Language
The preferred programming language is C
language.
Why C language is preferable
language
Software Architecture
Software architecture that will be used is
Super loop Architecture.
Super loop
• A super loop is a program structure comprised of an
infinite loop, with all the tasks of the system
contained in that loop.
• General pseudo-code for a super-loop
implementation is given as:
Function Main_Function()
{
Initialization();
Do_Forever
{
Check_Status();
Do_Calculations();
Output_Response();
}
}
Why Super-loop is needed
• We have no operating system to return to,
so the application will keep looping until
the system power is removed.
• It help to perform all the tasks of the
system in a reasonable amount of time
• It help task to be performed in good order.
Strength of Super loop
Weakness of Super loop
Compiler
• A compiler is a computer program (or set
of programs) that transforms source code
written in a programming language (the
source language) into another computer
language (the target language, often
having a binary form known as object
code).
• The preferred compiler is Mikro C compiler
Why Mikro C is the preferred compiler?
• lots of hardware and software libraries.
• Compiler comes with comprehensive Help
file and lots of ready-to-use examples
designed to get you started in no time.
Characteristics
• RISC CPUs
– 8-bit
– 16-bit
• Number of I/O pins: 4-70
• Memory types and sizes:
– Flash; OTP; ROM
– 0.5k – 256k
Speeds
• All PICs require oscillators to execute
instructions:
– Internal*
(low speeds, up to 8 MHz)
– External (high speeds, up to 40 MHz)
• Instructions are executed at least at ¼
oscillator speed (4 clocks/instruction)
(*
Note: not all PICs have internal oscillators)
A/D converters and C/C modules
• All PICs have between 0 and 16 A/D
converters with 8/10-bit resolution
• 8-16 bit Timers/Counters
• Comparator Modules (0-2)
Example: PIC16F877A
5/6 Programming pins
8 A/D channels
2 Oscillator Inputs
2 RS-232 inputs
33 I/O ports

Basics of micro controllers for biginners

  • 1.
  • 2.
  • 3.
    MICROPROCESSOR Microprocessor • Is aprogrammable digital component that in cooperates the function of CPU on a single semiconducting integrated circuit. • Is the integration of number of useful function into a single IC package that has; -Ability to execute a stored set of instruction to carry out user defined task. - Ability to access the external memory chips to both read and write data to and from the memory
  • 4.
  • 5.
    Basic architecture • Vonneumann Architecture. • Harvard architecture
  • 6.
    Von Neumann Architecture. •The design has a single memory bank for storing both program and data. • It has single bus which is multiplexed to be used as both address bus and data bus. • The content of RAM can be used for both variable storage as well as program storage.
  • 7.
    Harvard Architecture • Separatememory banks for program and data storage. • It has RAM for data storage and separate ROM for storing program • It has two separate address bus for -Program memory - Data memory
  • 8.
    Comparison Von Neumann VersusHarvard Von Neumann Harvard • Single memory for both program and data • Separate memory for program and data • Single bus used to access both data and memory • Separate buses available to access program and data • Instruction parallelism is not possible • Instruction parallelism can be done • It takes more than one machine cycle (Fetching and execution are done) • It takes only one machine cycle. Fetching and execution are done simultaneous
  • 9.
    Advantages of VonNeumann Architecture • It simplifies the microcontroller chip design because only one memory is accessed. • The content of RAM can be used for both variable (data) as well as program (instruction) storage
  • 10.
    Advantages of Harvard Architecture •The Harvard architecture tends to execute instruction in fewer instruction cycle than Von Neumann architecture. This is because greater amount of parallelism is possible.
  • 11.
    Instruction Set • CISC-Complex Instruction Set Computer • RISC- Reduced Instruction Set Computer
  • 12.
    Complex Instruction Set Computer •Is Microprocessor that understand large number of complex instruction but it process them relatively slowly • Internal instruction involves many individual execution steps and thus many clock cycles. • The design is complex, costly and also instruction set consist of more than 100 instruction
  • 13.
    Reduced Instruction Set Computer •Is Microprocessor that uses relatively simple architecture with fewer built in command. • Increase in speed. • Design is relatively simpler, economical and usually has less than 100 instructions
  • 14.
    Comparison RISC versus RISC RISCCISC • Less number of Instruction • More number of Instruction • All are single cycle instruction • Each instruction take at least 2 or 3 machine cycle. • Design of architecture is easier and cheap • Design of architecture is complex and costly • Program length get increased due to shortage of instructions • Program length is less because variety of instructions is available • Execution speed is faster since most instruction are single cycled • Execution speed is low since the instruction takes many machine cycles • Example; PIC series, ARM processors • Examples; 8051 families, Pentium
  • 15.
    MICROCONTROLLERS  Is asmall (micro) single chip computer designed to perform a specific function, and the specific function is to control objects, process or events.  It is dedicated to one task or set of closely related task. It is similar to PC(it has similar components but onto a single chip) -CPU, memory (ROM and RAM). -I/O ports, serial ports. - Timers e.t.c
  • 16.
  • 17.
    Comparison Microprocessor Versus Microcontroller MicroprocessorMicrocontroller • Memoryhastobeinterfacedexternally • Hasinbuiltprogramanddatamemory • I/Oportshastobeinterfaced • HasInbuiltdigital/analogueI/Oports • HasnointernalTimers,serialportsetc • HasTimer,serialportsandotherfeatures • Highclockrates >3GHz • Slowclockrates(4–20MHz) • Buswidthverywide • Buswidthverynarrow • Expensive • Lessexpensive
  • 18.
    In Summary Microprocessor Is ageneral purpose chip and is used in multifunction computer or device with the help of multiple chips to handle various tasks Microcontroller Is a self contained, CPU, RAM, ROM, I/O ports and Timers on the same chip function independently as a single chip computer dedicated to specific task to control single system
  • 19.
    Why Microcontroller? • Taskspecific. • Add computer power to the device to enable it to perform more better at low cost. • Low cost, small packaging, low power requirements. • Ideal for application in which low cost, power and space is crucial. • Easy integration with other circuits • Programmable and re-programmable.
  • 20.
    Embedded System • Thesystem to control, monitor or assist the operation of equipment, machinery or plant. The term “Embedded” reflect the fact that they are integral part of the system they control.
  • 21.
    Common characteristics of EmbeddedSystems • Specific and single functioned Execute a single instruction repeatedly • Optimized for hardware Compact, low cost, fast, low power. • Reactive and operated in real time
  • 22.
  • 23.
    MICROCONTROLLER BASED PROJECTS HOW TOSELECT A SUITABLE MICROCONTROLLER FOR THE PROJECT
  • 24.
    Step 1: Makea list of required hardware interfaces
  • 25.
    Step 2: Examinethe software architecture • How heavy or how light the processing requirements will determine whether you go with an 80 MHz DSP or an 8 MHz 8051 • Are there any high frequency control loops or sensors? • Estimate how long and how often each task will need to run • How much processing power will be needed. • The amount of computing power required will be one of the biggest requirements for the architecture and frequency of the microcontroller.(how fast a machine can perform an operation).
  • 26.
    Step 3: Selectthe architecture • Can the application get by with eight bit architectures? How about 16 bits? Does it require a 32 bit ARM core? • Microcontroller selection can be an iterative process. You may select a 16-bit part in this step but then in a later step find that a 32 bit ARM part works better.
  • 27.
    Step 4: IdentifyMemory Needs • Flash and RAM are two very critical components of any microcontrollers. Making sure that you don’t run out of program space or variable space is undoubtedly of highest priority.
  • 28.
    Step 5: Startsearching for microcontrollers • One place that can be a good place to start is with a microcontroller supplier
  • 29.
    Step 6: ExamineCosts and Power Constraints • Examine the power requirements and cost of the part.  If the device will be powered from a battery and mobile, then making sure the parts are low-power  If it doesn’t meet power requirements then keep weeding the list down until you have a select few.
  • 30.
    Step 7: Checkpart availability • Starts checking on how available the part is. • What are your requirements for availability?
  • 31.
    Step 8: Selecta development kit • One of the best parts of selecting a new microcontroller is finding a development kit to play with and learn the inner working of the controller.
  • 32.
    Step 9: Investigatecompilers and tools • Examine the compiler and tools that are available.  It is important to make sure that all the necessary tools are available for the part. Without the right tools the development process could become tedious and expensive.
  • 33.
    Step 10: StartExperimenting
  • 34.
    Programming Language The preferredprogramming language is C language.
  • 35.
    Why C languageis preferable language
  • 36.
    Software Architecture Software architecturethat will be used is Super loop Architecture.
  • 37.
    Super loop • Asuper loop is a program structure comprised of an infinite loop, with all the tasks of the system contained in that loop. • General pseudo-code for a super-loop implementation is given as: Function Main_Function() { Initialization(); Do_Forever { Check_Status(); Do_Calculations(); Output_Response(); } }
  • 38.
    Why Super-loop isneeded • We have no operating system to return to, so the application will keep looping until the system power is removed. • It help to perform all the tasks of the system in a reasonable amount of time • It help task to be performed in good order.
  • 39.
  • 40.
  • 41.
    Compiler • A compileris a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code). • The preferred compiler is Mikro C compiler
  • 42.
    Why Mikro Cis the preferred compiler? • lots of hardware and software libraries. • Compiler comes with comprehensive Help file and lots of ready-to-use examples designed to get you started in no time.
  • 43.
    Characteristics • RISC CPUs –8-bit – 16-bit • Number of I/O pins: 4-70 • Memory types and sizes: – Flash; OTP; ROM – 0.5k – 256k
  • 44.
    Speeds • All PICsrequire oscillators to execute instructions: – Internal* (low speeds, up to 8 MHz) – External (high speeds, up to 40 MHz) • Instructions are executed at least at ¼ oscillator speed (4 clocks/instruction) (* Note: not all PICs have internal oscillators)
  • 45.
    A/D converters andC/C modules • All PICs have between 0 and 16 A/D converters with 8/10-bit resolution • 8-16 bit Timers/Counters • Comparator Modules (0-2)
  • 46.
    Example: PIC16F877A 5/6 Programmingpins 8 A/D channels 2 Oscillator Inputs 2 RS-232 inputs 33 I/O ports