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 Project or Idea!?

I am Available for Freelance Projects

My skills are always primed and ready for new opportunities to be put to work, and I am ever on the lookout to connect with individuals who share a similar mindset.

If you’re intrigued and wish to collaborate, connect, or simply indulge in a stimulating conversation, don’t hesitate! Drop me an email and let’s begin our journey. I eagerly anticipate our interaction!

Pin It on Pinterest

Share This