Interrupt in PIC16F877A

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;
char num[10];
void interrupt()
{
TRISC=0x00;
PORTC=0xFF;
INTCON.F1 = 0; /* clear the int flag */
}

void main ( )
{
count=0;
TRISB = 0xFF; /* set up port b */
PORTB = 0x03; /* turn off all and any LED’s on port b */
INTCON.f7=0x01;
OPTION_REG.F6 = 1; /* interrupt on rising edge */
INTCON.f5=0x01;
while(1);
}

————————————————————————————

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.

Try it!

Madan

Advertisements

2 thoughts on “Interrupt in PIC16F877A

  1. I want to have the complete list of interrupts present in PIC16F877A.
    I know there are 15 interrupts in PIC16F877A.
    I just want to know what are those interrupts?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s