​Here is a quick overview of how to get interrupts going in XC8.

You will need to define your interrupt function or handler.

void __interrupt () isr_routine (void)
{
}

The name isr_routine can be anything you want, however __interrupt () is very important it tells XC8 that this function should be assigned to the interrupt jump point.

The interrupt function will need to clear the interrupt flag of the device that caused the interrupt. Failure to do so in code will result in a never ending interrupt.

In your setup – you will need to set the interrupt enable flag of the device you want to cause the interrupt, along with GIE, Global Interrupt Enable.

If you have multiple interrupts enabled. You will need to check the interrupt flags of the devices that are enabled to handle that specific interrupt.

In the next post I will go over with code enabling a timer0 interrupt to replace __delay_ms()

Something You Might Be Intrested In


 

10F32X Rapid Prototype Board

Make The PIC10F322 and other PIC10F Processors Breadboard Friendly for Quick and Easy Prototyping.

{Click to learn more}

PIC10F322 XC8 Interrupts - Overview