Microcontrollers - PowerPoint PPT Presentation

1 / 39
About This Presentation
Title:

Microcontrollers

Description:

Microcontrollers An Overview WHAT IS A MICROCONTROLLER ? Computer on a chip or single chip computer Programmable single chip which control a system or process Less ... – PowerPoint PPT presentation

Number of Views:222
Avg rating:3.0/5.0
Slides: 40
Provided by: RAVINDER4
Category:

less

Transcript and Presenter's Notes

Title: Microcontrollers


1
Microcontrollers
  • An Overview

By PARMENDER SINGH Assistant Professor EcE Deptt.
2
WHAT IS A MICROCONTROLLER ?
  • Computer on a chip or single chip computer
  • Programmable single chip which control a system
    or process
  • Less size power cost.
  • Components of microcontroller

  • CPU

  • MEMORY

  • TIMER

  • PHERIPHERAL DEVICES

  • I/O INTERFACE

  • INTERRUPTS CKT


3
Microcontroller versus Microprocessor
4
How to choose a MCU ?
  • PROCESSOR ARCHITECTURE
  • Harvard Architecture
  • Von-Neumann or Princeton Architecture
  • MEMORY
  • Embedded Memory
  • External Memory
  • TYPE OF MEMORY USED
  • None
  • PROM
  • EPROM
  • EEPROM
  • FLASH
  • COMPANY PRODUCING
  • INTEL
  • SIEMENS
  • MOTOROLA
  • PHILIPS
  • INSTRUCTIONS
  • CISC

5
PROCESSOR ARCHITECTURE
  • Von-Neumann or Princeton Architecture
  • Harvard Architecture

6
Acc. to Instructions
Instructions that can be understood by the
microcontroller are known as an instruction set.
When you write a program in assembly language,
you actually tell a story by specifying
instructions in the order they should be
executed. The main restriction in this process is
the number of available instructions. The
manufacturers stick to one of the two following
strategies RISC (Reduced Instruction Set
Computer) In this case, the microcontroller
recognizes and executes only basic operations
(addition, subtraction, copying etc.). All other
more complicated operations are performed by
combining these (for example, multiplication is
performed by performing successive addition). The
constrains are obvious (try by using only a few
words, to explain to someone how to reach the
airport in some other city). However, there are
also some great advantages. First of all, this
language is easy to learn. Besides, the
microcontroller is very fast so that it is not
possible to see all the arithmetic acrobatics
it performs. The user can only see the final
result of all those operations. At last, it is
not so difficult to explain where the airport is
if you use the right words. For example left,
right, kilometers . CISC (Complex Instruction Set
Computer) CISC is the opposite of RISC!
Microcontrollers designed to recognize more than
200 different instructions can do much and are
very fast. However, one needs to understand how
to take all that such a rich language offers,
which is not at all easy...
7
PIC microcontrollers
  • The real name of this microcontroller is
    PICmicro (Peripheral Interface Controller), but
    it is better known as PIC.
  • Its first ancestor was designed in 1975 by
    General Instruments. This chip called PIC1650 was
    meant for totally different purposes
  • .
  • About ten years later, by adding EEPROM memory,
    this circuit was transformed into a real PIC
    microcontroller.
  • Nowadays, Microchip Technology announces a
    manufacturing of the 5 billionth sample...

8
In order that you can better understand the
reasons for its popularity, we will briefly
describe several important things.
Family ROM Kbytes RAM bytes Pins Clock Freq. MHz A/D Inputs Resolution of A/D Converter Coma p r- ators 8/16 bit Timer s Serial Comm. PWM Outputs
Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length Base-Line 8 - bit architecture, 12-bit Instruction Word Length
PIC10FXXX 0.375 - 0.75 16 - 24 6 - 8 4 - 8 0 - 2 8 0 - 1 1 x 8 - -
PIC12FXXX 0.75 - 1.5 25 - 38 8 4 - 8 0 - 3 8 0 - 1 1 x 8 - -
PIC16FXXX 0.75 - 3 25 - 134 14 - 44 20 0 - 3 8 0 - 2 1 x 8 - -
PIC16HVXXX 1.5 25 18 - 20 20 - - - 1 x 8 - -
Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length Mid-Range 8 - bit architecture, 14-bit Instruction World Length
PIC12FXXX 1.75 - 3.5 64 - 128 8 20 0 - 4 10 1 1 - 2 x 8 1 x 16 - 0 - 1
PIC12HVXXX 1.75 64 8 20 0 - 4 10 1 1 - 2 x 8 1 x 16 - 0 - 1
PIC16FXXX 1.75 - 14 64 - 368 14 - 64 20 0 - 13 8 or 10 0 - 2 1 - 2 x 8 1 x 16 USART I2C SPI 0 - 3
PIC16HVXXX 1.75 - 3.5 64 - 128 14 - 20 20 0 - 12 10 2 2 x 8 1 x 16 USART I2C SPI -
9
Family ROM Kbytes RAM bytes Pins Clock Freq. MHz A/D Inputs Resolution of A/D Converter Compar- ators 8/16 bit Timers Serial Comm. PWM Outputs Others
High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length High-End 8 - bit architecture, 16-bit Instruction Word Length
PIC18FXXX 4 - 128 256 - 3936 18 - 80 32 - 48 4 - 16 10 or 12 0 - 3 0 - 2 x 8 2 - 3 x 16 USB2.0 CAN2.0 USART I2C SPI 0 - 5 -
PIC18FXXJXX 8 - 128 1024 - 3936 28 - 100 40 - 48 10 - 16 10 2 0 - 2 x 8 2 - 3 x 16 USB2.0 USART Ethernet I2C SPI 2 - 5 -
PIC18FXXKXX 8 - 64 768 - 3936 28 - 44 64 10 - 13 10 2 1 x 8 3 x 16 USART I2C SPI 2 -
All PIC microcontrollers use harvard
architecture, which means that their program
memory is connected to CPU via more than 8 lines.
Depending on the bus width, there are 12-, 14-
and 16-bit microcontrollers. The table above
shows the main features of these three categories
10
PIN0UT
11
PIN0UT
12
(No Transcript)
13
(No Transcript)
14
Register
A register or a memory cell is an electronic
circuit which can memorize the state of one byte.
15
(No Transcript)
16
OPTION_REG Register
STATUS Register
INTCON Register
17
Memory Unit
  • Memory is part of the microcontroller used for
    data storage. The easiest way to explain it is to
    compare it with a filing cabinet with many
    drawers. Suppose, the drawers are clearly marked
    so that it is easy to access any of them. It is
    easy enough to find out the contents of the
    drawer by reading the label on the front of the
    drawer.
  • Each memory address corresponds to one memory
    location. The content of any location becomes
    known by its addressing. Memory can either be
    written to or read from. There are several types
    of memory within the microcontroller.

18
PCL and PCLATH Registers
19
Input/Output Ports
  • In order to make the microcontroller useful, it
    has to be connected to additional electronics,
    i.e. peripherals.
  • Each microcontroller has one or more registers
    (called a port) connected to the
    microcontroller pins.
  • Why input/output? Because you can change the
    pins function as you wish

20
I/O Ports
Fig. 3-1 I/O Ports
21
Fig. 3-2 Port A and TRISA Register
Fig. 3-3 Port B and TRISB Register
22
Oscillator
23
Clock / instruction cycle
  • Clock is microcontroller's main starter, and is
    obtained from an external component called an
    "oscillator".
  • Clock from the oscillator enters a
    microcontroller via OSC1 pin where internal
    circuit of a microcontroller divides the clock
    into four even clocks Q1, Q2, Q3, and Q4 which do
    not overlap.
  • These four clocks make up one instruction cycle
    (also called machine cycle) during which one
    instruction is executed.

24
STATUS Register
Fig. 2-1 STATUS Register IRP - Bit selects
register bank. It is used for indirect
addressing. RP1,RP0 - Bits select register bank.
They are used for direct addressing.
RP1 RP0 Active Bank
0 0 Bank0
0 1 Bank1
1 0 Bank2
1 1 Bank3
TO - Time-out bit PD - Power-down bit Z - Zero
bit DC - Digit carry/borrow C - Carry/Borrow bit
25
OPTION_REG Register
STATUS Register
INTCON Register
PCL and PCLATH Registers
26
Timers/Counters
FIG. 2- How does a timer operate?
FIG. 1-Timers/Counters
FIG. 3- Using prescaler in timer operating
27
Interrupts
  • Interrupts are a mechanism of a microcontroller
    which enables it to respond to some events at the
    moment they occur, regardless of what
    microcontroller is doing at the time.
  • This is a very important part, because it
    provides connection between a microcontroller and
    environment which surrounds it.
  • Generally, each interrupt changes the program
    flow, interrupts it and after executing an
    interrupt subprogram (interrupt routine) it
    continues from that same point on.
  • Control register of an interrupt is called INTCON
    and can be accessed regardless of the bank
    selected. Its role is to allow or disallowed
    interrupts, and in case they are not allowed, it
    registers single interrupt requests through its
    own bits.

28
One of the possible sources of interrupt and how
it affects the main program
29
INTCON Register
30
PIC16F84 interrupt sources
1. Termination of writing data to EEPROM2. TMR0
interrupt caused by timer overflow3. Interrupt
during alteration on RB4, RB5, RB6 and RB7 pins
of port B.4. External interrupt from RB0/INT pin
of microcontroller External interrupt on
RB0/INT pin of microcontroller Interrupt during a
TMR0 counter overflow Interrupt upon a change on
pins 4, 5, 6 and 7 of port B Interrupt upon
finishing write-subroutine to EEPROM Interrupt
initialization
31
The following example shows a typical way of
handling interrupts. PIC16F84 has got a single
location for storing the address of an interrupt
subroutine. This means that first we need to
detect which interrupt is at hand (if more than
one interrupt source is available), and then we
can execute that part of a program which refers
to
32
Instruction Set
  • Introduction
  • We have already mentioned that
    microcontroller is not like any other integrated
    circuit. When they come out of production most
    integrated circuits are ready to be built into
    devices which is not the case with
    microcontrollers. In order to "make"
    microcontroller perform a task, we have to tell
    it exactly what to do, or in other words we must
    write the program microcontroller will execute.
    We will describe in this chapter instructions
    which make up the assembler, or lower-level
    program language for PIC microcontrollers.
  • Instruction Set in PIC16Cxx
    Microcontroller Family
  • Complete set which includes 35
    instructions is given in the following table. A
    reason for such a small number of instructions
    lies primarily in the fact that we are talking
    about a RISC microcontroller whose instructions
    are well optimized considering the speed of work,
    architectural simplicity and code compactness.
    The only drawback is that programmer is expected
    to master "uncomfortable" technique of using a
    reduced set of 35 instructions

33
Instruction Set TABLE
34
Programming a Microcontroller
ELEMENTS OF ASSEMBLY LANGUAGE
35
EXAMPLE OF HOW TO WRITE A PROGRAM
  • The following example illustrates what a simple
    program written in assembly language looks like.

36
MACROS AND SUBROUTINES
bank0 macro Macro bank0
bcf STATUS, RP0 Reset RP0 bit bcf
STATUS, RP1 Reset RP1 bit endm
End of macro bank1 macro
Macro bank1 bsf STATUS, RP0 Set RP0
bit bcf STATUS, RP1 Reset RP1 bit
endm End of macro enableint
macro Global interrupt enable
bsf INTCON,7 Set bit endm
End of macro disableint macro
Global interrupt disable bcf
INTCON,7 Reset bit endm
End of macro
37
PIC16F84 interrupt sources
1. Termination of writing data to EEPROM2. TMR0
interrupt caused by timer overflow3. Interrupt
during alteration on RB4, RB5, RB6 and RB7 pins
of port B.4. External interrupt from RB0/INT pin
of microcontroller External interrupt on
RB0/INT pin of microcontroller Interrupt during a
TMR0 counter overflow Interrupt upon a change on
pins 4, 5, 6 and 7 of port B Interrupt upon
finishing write-subroutine to EEPROM Interrupt
initialization
38
The following example shows a typical way of
handling interrupts. PIC16F84 has got a single
location for storing the address of an interrupt
subroutine. This means that first we need to
detect which interrupt is at hand (if more than
one interrupt source is available), and then we
can execute that part of a program which refers
to
39
C Program Example
//////// Temperature Sensor Using PIC
16F877A//////////// /////////// Author Parmender
Singh /////////// //////////DatedFeburary 21,
2010 /////////////// include lt16F877A.hgt device
ADC10 fuses HS,NOWDT use delay(clock4000000)
use rs232(baud9600,xmitPIN_c6,rcvPIN_C7) incl
ude ltstdio.hgt include ltSTDLIB.hgt int16
value,value1 void main() setup_adc(ADC_CLOCK_INT
ERNAL) setup_port_a(ALL_ANALOG) set_adc_channel(
0) do value read_adc() value1
5.00value100.00/1023.00 printf("f\n\r",(float)
value1) delay_ms(1000) while(TRUE)
Write a Comment
User Comments (0)
About PowerShow.com