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
I am always looking for opportunities to put my technical skills to work.
I am always looking to connect with like minded people.
Want to connect? – Drop me a message