subroutine & interrupts.pptx

Upload: shruthi-reddy

Post on 14-Apr-2018

256 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 Subroutine & Interrupts.pptx

    1/20

    Subroutine & Interrupts

  • 7/30/2019 Subroutine & Interrupts.pptx

    2/20

    Sequence of a subroutine

  • 7/30/2019 Subroutine & Interrupts.pptx

    3/20

    Note:

    Stack should remain undisturbed Registers in main pgm & subroutine

    should not get mixed up

    Goto instruction to be used wisely, itshouldnt interfere with subroutine pgm

    Call (subroutine entry address-11+2address bits)

    Return

  • 7/30/2019 Subroutine & Interrupts.pptx

    4/20

    Sequence of a nested subroutine

  • 7/30/2019 Subroutine & Interrupts.pptx

    5/20

    Note:

    Stack should remain undisturbed

    Storage & Retrieval of address from stack takesplace one after the other

    8 level stack-LIFO

    In a sequence, 8 return addresses can be storedin stack

    Goto instruction to be used wisely, it shouldntinterfere with subroutine pgm

    Call (subroutine entry address-11+2 address bits)

    Return

  • 7/30/2019 Subroutine & Interrupts.pptx

    6/20

    Special task to be done on prioritybasis

    Examples Monitoring AC supply & emergency back

    up

    Measuring temperature & pressureduring a particular time slot

    Alarm setting

    Interrupts

  • 7/30/2019 Subroutine & Interrupts.pptx

    7/20

    Interrupts

    Main pgm execution

    Interrupt signals generated from differentsources

    When interrupted, Special task execution

    Special task completion Resume main pgm

  • 7/30/2019 Subroutine & Interrupts.pptx

    8/20

    Difference between Subroutine &Interrupts

    Subroutine Interrupt

    Subroutine call occurs at specific& pre-determined location in themain pgm

    Interrupt call can occur withoutany prior notice at any point ofthe main pgm

    Software initiated Hardware initiated

    Structured routine set ofinstructions

    Emergency condition-saving thestatus of registers required

  • 7/30/2019 Subroutine & Interrupts.pptx

    9/20

    Interrupts-Procedure

  • 7/30/2019 Subroutine & Interrupts.pptx

    10/20

    Interrupt enabling

    PIR Interrupt requestPIE Interrupt mask register

    GIE Global Interrupt Enable

  • 7/30/2019 Subroutine & Interrupts.pptx

    11/20

    Bank0

    Bank1

  • 7/30/2019 Subroutine & Interrupts.pptx

    12/20

    Interrupt timing diagram

  • 7/30/2019 Subroutine & Interrupts.pptx

    13/20

    Single interrupt

    IRQ

    IE

    GIE

    Dummy cycles

    ISR-starts @ ox04

    Interrupt status saving

    Bank switching

    Common scratchpad area

    Return from Interrupt

    RETFIE

    GIE enabled

    Interrupt response time

    3 to 4 instruction cycles execution of active instruction, save return address, vector to ox04location

    3 to 5instruction cycles save mc status

  • 7/30/2019 Subroutine & Interrupts.pptx

    14/20

    0x04h

    Interruptfrom SourceA

    Y

    N

    Serviceroutine A

    Serviceroutine B

    PROGRAM:

    004H:BTFSCPIR, A

    GOTOSRA

    ISR FORBRETFIE

    SRA: ISR FOR ARETFIE

  • 7/30/2019 Subroutine & Interrupts.pptx

    15/20

    Ports

  • 7/30/2019 Subroutine & Interrupts.pptx

    16/20

    Port B Circuit

  • 7/30/2019 Subroutine & Interrupts.pptx

    17/20

    Port-Output operation-Write

    F0-Phase beforeport pin is

    configured

    F1-Configuringinto output mode

    F2-Data writteninto port

  • 7/30/2019 Subroutine & Interrupts.pptx

    18/20

    Port-Input operation- Read

    F0-Phase beforeport pin is

    configured

    F1-Configuringinto input mode

    F2-Data readfrom port

  • 7/30/2019 Subroutine & Interrupts.pptx

    19/20

    Pull up

    Input mode

    Stray signals destroy ic

    Resistance connected from pin to supply PMOS transistor kept in active state

    forms pull up

    L2-1 nand RBPU-0 => PMOS gate 0state

  • 7/30/2019 Subroutine & Interrupts.pptx

    20/20

    Every port has port register

    In Output mode-data written to port

    register Ports A,B,C,D,E-can be configured as

    input or output pins