Interrupts help

Discussion in 'Programmer's Corner' started by lihle, Nov 12, 2010.

  1. lihle

    Thread Starter Active Member

    Apr 12, 2009
    83
    3
    hi guys i need your help with interrupts first is the idea of how can i use them to suite my code. i am designing a simple automation project using assembly language. what i have done i have tried to read about them but maybe with your help i can understand more.

    what i would like to do is that: i have three inputs to the micro-controller PIC16f877, what i would like is that when there has been an interruption in one of the pins(here using PortB as input) the pic stops and try to see which pin was interrupted then execute according to that effect.

    your help would be appreciated.

    lihle
     
  2. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    lihle likes this.
  3. Tahmid

    Active Member

    Jul 2, 2008
    344
    25
    Hi,
    This is how you should do it.
    First set up the configuration bits. Move to main program. There, set the 4 bits of TRISB that you need to inputs in PORTB. Clear RBIF. Set RBIE in INTCON and set GIE in INTCON. Then wait for interrupt to occur. In ISR, check if RBIF flag is raised. If no, return from interrupt, if yes, check the state of each of the PORTB inputs successively to read their state. Then you can move this to a register and then return from interrupt.

    Hope this helps.
    Tahmid.
     
    lihle likes this.
Loading...