Interupt: Well that literally means stopping you from doing something? well yes that’s precisely what an interrup signal does.When a processor keeps working on some program,You may execue a small emergency chunk of program in case you get a signal form a specified source to a pin.
This can be done by polling But will involve a lotof your processor time.Thus you dont spnd time looking for the signal all the time, instead you set that pin for an interrupt option. So your procesor will keep processing any other program without looking for the signal,But once there is a signal your program will be automatically redirected to a funcation called “INTERRUPT”.
In PIC16F877A the most basic interrupt in on Pin RB0.
The following program will make the interrupt program to execute once there is a pulse at pin RB0. The interrupt at raising edge or falling edge is configurable using software approach.
unsigned short count,read;
INTCON.F1 = 0; /* clear the int flag */
void main ( )
TRISB = 0xFF; /* set up port b */
PORTB = 0x03; /* turn off all and any LED’s on port b */
OPTION_REG.F6 = 1; /* interrupt on rising edge */
NOTE: Any program here might have a problem with “X” dou to formatting on wordpress. they all are capital X.
The above program will make all pins of PORTC high once there is interrupt signal from some sensor (say) . Once the interrupt is executed ,the procesor will continue what it was working on prior to the interrupt.
Hey now this should be tried.Its fun and a very usefull tool.