Interrupts help

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

  1. lihle

    Thread Starter Active Member

    Apr 12, 2009
    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.

  2. Markd77

    Senior Member

    Sep 7, 2009
    lihle likes this.
  3. Tahmid

    Active Member

    Jul 2, 2008
    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.
    lihle likes this.