Interrupts are events that stops the microcontroller from going further into the program and executes code that handles the interrupt. Afterwards, it returns to the next line of code that it was previously running.
- Configure the apropriate interrupt registers to enable it.
- Program the microcontroller to handle the interrupt and execute code (toggle LED).
Interrupts are useful for handling time-sensitive events that the microcontroller needs to deal with. This can be anywhere between incoming data, sensor input and ect.
While going through this lab, I had trouble finding the specific section for my microcontroller’s interrupt vector register. I had to dig through the linker file to see what the section was labeled for the GPIO P1.3 which is what my button was wired to.
&P1IES: Interrupt edge selector, 0 = rising edge, 1 = falling edge
&P1IE: Interrupt enable
&P1IFG: Interrupt flag register (Clear this when &P1IES is set because it may change this flag)
GIE: Global interrupt enable in the SR. Enables whether interrupts are handled or not.
Interrupt Service Routine (ISR) - Code that is executed when an interrupt occurs. Needs to be fast and short, needs to end with RETI instruction.