Interrupts help

Thread Starter

lihle

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

Tahmid

Joined Jul 2, 2008
343
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.
 
Top