Micropy Bab 2

download Micropy Bab 2

of 29

Transcript of Micropy Bab 2

  • 8/6/2019 Micropy Bab 2

    1/29

    7/8/200

    INTRODUCTION OF MICROCONTROLLER

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 1

    INTRODUCTION OF MICROCONTROLLER

    68HC11 MICROCONTROLLER

    ARCHITECTURE OF 68HC11

    INSTRUCTIONS CYCLE

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 2

  • 8/6/2019 Micropy Bab 2

    2/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 3

    Definition of microcontroller : A microcontroller (also MCU or C) is a functional

    computer system-on-a-chip. It contains aprocessor core, memory, and programmableinput/output peripherals(http://en.wikipedia.org/wiki/Microcontroller )

    Microcontrollers include an integrated CPU, memory(a small amount of RAM, program memory, or both)and peripherals capable of input and output.

    (Embedded Systems Dictionary" by Jack Ganssleand Mike Barr, p.173)

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 4

    http://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/System-on-a-chiphttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/System-on-a-chiphttp://en.wikipedia.org/wiki/System-on-a-chiphttp://en.wikipedia.org/wiki/System-on-a-chiphttp://en.wikipedia.org/wiki/System-on-a-chiphttp://en.wikipedia.org/wiki/System-on-a-chiphttp://en.wikipedia.org/wiki/Computer
  • 8/6/2019 Micropy Bab 2

    3/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 5

    Microcontroller - put a limited amount of most commonly used resources inside onechip

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 6

  • 8/6/2019 Micropy Bab 2

    4/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 7

    The first computer system on a chipoptimized for control applications -microcontroller was the Intel 8048released in 1975, with both RAM and ROMon the same chip. This chip went on to befound in over a billion PC keyboards, and

    numerous applications. Most microcontrollers at this time had two

    variants. One had an erasable EEPROMprogram memory, which was significantlymore expensive than the PROM variantwhich was only programmable once.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 8

    http://en.wikipedia.org/wiki/Intel_8048http://en.wikipedia.org/wiki/Intel_8048http://en.wikipedia.org/wiki/Random_access_memoryhttp://en.wikipedia.org/wiki/Intel_8048http://en.wikipedia.org/wiki/Random_access_memoryhttp://en.wikipedia.org/wiki/Read_only_memoryhttp://en.wikipedia.org/wiki/EEPROMhttp://en.wikipedia.org/wiki/EEPROMhttp://en.wikipedia.org/wiki/Programmable_read-only_memoryhttp://en.wikipedia.org/wiki/Programmable_read-only_memoryhttp://en.wikipedia.org/wiki/Programmable_read-only_memoryhttp://en.wikipedia.org/wiki/EEPROMhttp://en.wikipedia.org/wiki/Read_only_memoryhttp://en.wikipedia.org/wiki/Random_access_memoryhttp://en.wikipedia.org/wiki/Intel_8048
  • 8/6/2019 Micropy Bab 2

    5/29

    7/8/200

    In 1993, the introduction ofEEPROMmemory allowed microcontrollers(beginning with the Microchip PIC16x84)tobe electrically erased quickly without anexpensive package as required for EPROM,allowing both rapid prototyping, and InSystem Programming.

    The same year, Atmel introduced the first

    microcontroller using Flash memory. Other companies rapidly followed suit,

    with both memory types.pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 9

    8-Bit Motorola Controllers(6805,68705,68HC11,68HC12) Microchip PIC-www.microchip.com Atmel AVR Hitachi H8 Zilog Z8, Hitachi 64180 (Z80) Texas Instruments TMS370

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 10

    http://en.wikipedia.org/wiki/EEPROMhttp://en.wikipedia.org/wiki/PIC16x84http://en.wikipedia.org/wiki/EPROMhttp://en.wikipedia.org/w/index.php?title=In_System_Programming&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=In_System_Programming&action=edit&redlink=1http://en.wikipedia.org/wiki/Flash_memoryhttp://en.wikipedia.org/wiki/Flash_memoryhttp://en.wikipedia.org/w/index.php?title=In_System_Programming&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=In_System_Programming&action=edit&redlink=1http://en.wikipedia.org/wiki/EPROMhttp://en.wikipedia.org/wiki/PIC16x84http://en.wikipedia.org/wiki/EEPROM
  • 8/6/2019 Micropy Bab 2

    6/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 11

    The integrated circuit from an Intel 8742, an 8-bit microcontroller thatincludes a CPU running at 12 MHz, 128 bytes ofRAM, 2048 bytes ofEPROM, and I/O in the same chip.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 12

    A PIC 18F8720 microcontroller in an 80-pin TQFP package.

    http://en.wikipedia.org/wiki/Integrated_circuithttp://en.wikipedia.org/wiki/Intelhttp://en.wikipedia.org/wiki/CPUhttp://en.wikipedia.org/wiki/RAMhttp://en.wikipedia.org/wiki/EPROMhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/PIC_microcontrollerhttp://en.wikipedia.org/wiki/TQFPhttp://en.wikipedia.org/wiki/TQFPhttp://en.wikipedia.org/wiki/PIC_microcontrollerhttp://en.wikipedia.org/wiki/Input/outputhttp://en.wikipedia.org/wiki/EPROMhttp://en.wikipedia.org/wiki/RAMhttp://en.wikipedia.org/wiki/CPUhttp://en.wikipedia.org/wiki/Intelhttp://en.wikipedia.org/wiki/Integrated_circuit
  • 8/6/2019 Micropy Bab 2

    7/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 13

    MH68HC11-Microcontroller

    Automotive

    Home applications (remote control, TV,telephones, pager, laser printer & etc)

    Motor control (stepper motor)

    Mechatronic

    Medical solution Utility metering

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 14

  • 8/6/2019 Micropy Bab 2

    8/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 15

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 16

  • 8/6/2019 Micropy Bab 2

    9/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 17

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 18

  • 8/6/2019 Micropy Bab 2

    10/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 19

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 20

  • 8/6/2019 Micropy Bab 2

    11/29

    7/8/200

    The 68HC11 (6811 or HC11 for short) is a 8-bit microcontroller (C) family originally fromMotorola, now produced by FreescaleSemiconductor, descended from the Motorola6800 microprocessor.

    It is a CISC microcontroller.

    The 68HC11 devices are more powerful.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 21

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 22

    http://en.wikipedia.org/wiki/Microcontrollerhttp://en.wikipedia.org/wiki/Freescale_Semiconductorhttp://en.wikipedia.org/wiki/Freescale_Semiconductorhttp://en.wikipedia.org/wiki/Motorola_6800http://en.wikipedia.org/wiki/Motorola_6800http://en.wikipedia.org/wiki/Microprocessorhttp://en.wikipedia.org/wiki/Complex_instruction_set_computerhttp://en.wikipedia.org/wiki/Complex_instruction_set_computerhttp://en.wikipedia.org/wiki/Microprocessorhttp://en.wikipedia.org/wiki/Motorola_6800http://en.wikipedia.org/wiki/Motorola_6800http://en.wikipedia.org/wiki/Freescale_Semiconductorhttp://en.wikipedia.org/wiki/Freescale_Semiconductorhttp://en.wikipedia.org/wiki/Freescale_Semiconductorhttp://en.wikipedia.org/wiki/Microcontroller
  • 8/6/2019 Micropy Bab 2

    12/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 23

    8K bytes of ROM

    512 bytes of EEPROM

    256 bytes of RAM (all saved duringstandby)

    An enhanced 16-bit Timer system,including

    A four-stage programmable

    Three Input Capture functions

    Five Output Compare functions

    An 8 bit Pulse Accumulator circuit

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 24

  • 8/6/2019 Micropy Bab 2

    13/29

    7/8/200

    An enhanced NRZ Serial CommunicationsInterface (SCI)

    A Serial Peripheral Interface (SPI)

    An eight-channel, 8-bit Analog-to-DigitalConverter (ADC)

    A real-time interrupt circuit

    A Computer Operating Properly (COP) watchdogsystem

    Availability of the IC in dual in-line or Leaded

    Chip Carrier Packages (DIP or LCCP)

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 25

    An enhanced 6800/6801 instruction set

    8-bit multiplication and 16-bit divisioninstructions

    Bit manipulation instructions

    A WAIT mode

    A STOP mode

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 26

  • 8/6/2019 Micropy Bab 2

    14/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 27

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 28

  • 8/6/2019 Micropy Bab 2

    15/29

    7/8/200

    M68HC11 consists of four (4) basic parts: Central processor unit (CPU) Internal Memory registers I/O subsystem

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 29

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 30

  • 8/6/2019 Micropy Bab 2

    16/29

    7/8/200

    - These parts are connected internally by an internalbus.

    - I/o subsystem allows the MPU to exchangeinformation with the outside world.

    - The I/O subsystem is grouped into units called I/Oports.

    - Each I/O port has I/O lines (usually eight lines) totransfer information between the external devicesand the ports. These lines can be input only,output only, or programmable to be either.

    - Each port also has its own I/O register.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 31

    CPU The CPU consists of three main sections

    Arithmetic Logic Unit (ALU)

    Registers and Accumulators

    Control Unit

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 32

  • 8/6/2019 Micropy Bab 2

    17/29

    7/8/200

    ALU performs arithmetic and logic operations on

    operands.

    The operands are held temporarily inaccumulators/ registers.

    Inputs to the ALU may come from accumulatorsor register , and the results are placed back inaccumulators.

    The type of operation is determined by the

    control unit.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 33

    Registers & accumulator Registers and accumulators are high-speed

    temporary memory locations during CPUoperations.

    They exchange information through one or moreinternal buses.

    Registers are divided into;

    PC IR

    SP

    SR

    AR

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 34

  • 8/6/2019 Micropy Bab 2

    18/29

    7/8/200

    Program Counter,PC At the beginning of a program execution, the PC is

    loaded with the starting address of that program

    it always points to the location of the next instruction

    Instruction Register,IR The IR extracts the operation code (opcode) from an

    instruction.

    The control unit decodes the contents of the IR andgenerates the necessary control signals

    Stack pointer,SP specially reserved area in memory Stacks are used mainly during subroutines or

    interrupt.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 35

    Flag @ Status register,SP status register consists of flag bits and control

    bits

    Flags are set automatically during arithmetic andlogic operations.

    Such flags include N, Z, V, C and so on.

    Address register, AR The PC register sends the pointed to address

    to the AR register

    The AR register then sends this address to theaddress bus to select this address in memory.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 36

  • 8/6/2019 Micropy Bab 2

    19/29

    7/8/200

    Control units The control unit includes the instruction

    decoding, timing, and control circuitry.

    The control unit generates two groups ofsignals:

    Internal control signals for activation of the ALUand the opening and closing of the data pathsbetween registers.

    External control signals concerning the memoryand I/O. These signals are sent either for

    activation of data transfer or as a response to aninterrupt.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 37

    Memory The memory unit stores the program to

    be executed and data that are to beoperated on by the program.

    The memory unit operation iscontrolled by CPU signals (read andwrite).

    When the CPU sends data to thememory, it is called a write program,and

    when the CPU receives data from thememory, it is called a read operation.pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 38

  • 8/6/2019 Micropy Bab 2

    20/29

    7/8/200

    Memory is divided into internal and externalmemory.

    Internal memory usually means memorywithin the chip. Examples of memoryinclude RAM, ROM, PROM, EPROM andEEPROM.

    External memory generally means memoryoutside the chip. This type of memoryincludes the semiconductor type and serialmemory such as magnetic disks, magnetictapes and bubble memory.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 39

    Types of IC memory Memory ICs may be volatile or nonvolatile. Volatile memory loses its data after the power is

    removed (Exp:RAM)

    nonvolatile memory, these ICs store datapermanently even when power is removed from the

    chip (Exp: PROM,EPROM,EEPROM)

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 40

  • 8/6/2019 Micropy Bab 2

    21/29

    7/8/200

    Random access memory, RAM There are two types of RAM;

    Static RAM (SRAM)

    Dynamic RAM (DRAM)

    SRAM uses an integrated flip-flop

    SRAMs are fast, need no refresh circuitry, and areideal for small programs (less than 16K).

    DRAM DRAMs are usually organized for storing a single

    bit for location which is referred to as x1

    organization. A DRAM storage cell consists of one MOSFET and a

    capacitor.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 41

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 42

    SRAM uses an integrated flip-flop

  • 8/6/2019 Micropy Bab 2

    22/29

    7/8/200

    input lines (A0 An). row address strobe (RAS)

    column address strobe (CAS)

    write enable (WE) line indicates whetherthis access is for reading or writing. A logic1 indicates a read operation, while a logic0 indicates a write operation.The advantages of DRAMs over SRAMsinclude their high density, lower powerdissipation, and greater cost-effectivenessin large programs (more than 16K).

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 43

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 44

    Block diagram & pin configuration of DRAM

  • 8/6/2019 Micropy Bab 2

    23/29

    7/8/200

    Read only memory, ROM consists of a MOSFET or a bipolar transistor.

    Types of ROM:

    PROM programmable ROM (one-shotprogrammable)

    EPROM erasable programmable ROM (In anerasing operation, this windows is exposed toultraviolet (UV) light for between 30 to 50 minutes)

    EEPROM Electrically erasable PROMs (EEPROMs)use a floating-gate technology that allows them to

    be erased electrically.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 45

    Memory characteristic Speed Memory speed is defined in terms ofaccess time and cycle time. Access time is

    defined as the time elapsing from the momentwe present a stable address until memoryresponds with stable data. The cycle timedetermines how fast we can access memory.

    Density - Density is defined as the number ofbits per memory chip.

    Power Dissipation - Power Dissipation isspecified in terms of operating power andstandby power. Low standby power represents avery important advantage.

    Cost The price of memory devices affects thecost of the overall memory subsystem.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 46

  • 8/6/2019 Micropy Bab 2

    24/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 47

    Memory characteristic

    Registers ACCUMULATORS (A, B and D) INDEX REGISTERS (X and Y) STACK POINTER (SP) PROGRAM COUNTER (PC) CONDITION CODE REGISTER (CCR)

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 48

  • 8/6/2019 Micropy Bab 2

    25/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 49

    Registers set

    ACCUMULATORS (A, B and D) Accumulator A & B is used for 8-bit arithmetic and

    data manipulation operations.

    Accumulator D is used for 16-bit arithmetic anddata manipulation operations.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 50

  • 8/6/2019 Micropy Bab 2

    26/29

    7/8/200

    INDEX REGISTERS (X and Y) The 16-bit index registers X and Y are used for the

    indexed addressing mode.

    STACK POINTER (SP) The stack is an area of RAM used for temporary storage

    of data.

    PROGRAM COUNTER (PC) The program counter is a 16-bit register that holds the

    address of the next instruction to be executed.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 51

    CONDITION CODE REGISTER (CCR) The CCR contains 8 bits: 5 status bits (called flags),

    2 interrupt mask bits, and a stop disable bit. The 5status flags are as follows: carry/borrow (C),overflow (V), zero (Z), negative (N), and half-carry(H). The two interrupt flags are I and X bits. The Sbit is the stop bit.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 52

  • 8/6/2019 Micropy Bab 2

    27/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 53

    The sequence of steps involved in fetchingand executing an instruction from the memoryis known as an instruction cycle.

    An instruction cycle consists of a few machinecycles.

    Types of machine Read memory

    Write memory Interrupt operation Interrupt acknowledge

    The machine cycle are synchronized by theinternal clock cycles. A machine cycle consistsof three to four clock cycles.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 54

  • 8/6/2019 Micropy Bab 2

    28/29

    7/8/200

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 55

    In machine cycle 1, the CPU reads the first word ofthe instruction using the contents of the ProgramCounter (PC).

    This is accomplished by the end of clock cycle T3.This machine cycle is extended by one additionalclock cycle (T4), to give the CPU a chance to decodethe op-code and the address mode fields of theinstruction.

    At the end of T4, the CPU knows that the instructionincludes one more word and also known what type ofoperation is required.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 56

  • 8/6/2019 Micropy Bab 2

    29/29

    7/8/200

    In machine cycle 2, the CPU readsthe address of the memory.

    In machine cycle 3, knowing theaddress, the CPU fetches theoperand from memory.

    In machine cycle 4, the CPU adds 1to the operand

    In machine cycle 5. the CPU storesthe results back into memory.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 57

    What is microcontroller?

    Explain the basic structure of microcontroller.

    What is the main components inmicroprocessor microcontroller?

    State the different between microprocessor &

    microcontroller. Give a example of microcontroller chip.

    pjb/jke/maisarah/e4160-chapter2: Introduction of microcontroller 58