Select Page

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

You will need to define your interrupt function or handler in your code.

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()


Have a technology project in mind? Let’s talk!

I am currently available for hire

Need a custom technology solution for your business? Please send me an email (jamie@jamiestarling.com) to discuss your project needs.

I can help you get started on the road of building a simple and well-tested working solution, together, with your team.