1.1 KiB
Executable File
1.1 KiB
Executable File
Intro to Embedded Systems Lecture Notes: February 7th, 2023
Using Interrupts
#define INTERRUPT_PINS 0x03
int main(void)
{
P4IE |= INTERRUPT_PINS; // Local interrupt enable
P4IFG |= INTERRUPT_PINS;
P4IES |= INTERRUPT_PINS;
_enable_interrupts(); // Global interrupt enable
__bis_SR_register(GIE);
while (true)
{
...
}
return 0;
}
// Port 4 interrupt service routine
void __attribute__ ((interrupt(PORT4_VECTOR))) Port_4 (void)
{
...
}
Interrupt Servicing Summary
- Interrupt Pending
- Complete Current Instruction
- Clear SR
- Retrieve starting address of ISR & put address in PC
- Execute ISR
- Pop SR and PC from stack
- Continue to main program
Multiple Interrupts
Three Types:
- Reset Interrupt
- Maskable Interrupt
- ADC, port, timer, e_USCI
- User-asserted event
- Non-Maskable Interrupt
- Fault, error detection
- Oscillator fault
- Flash key violation
Priority of Interrupts
- Timers
- e_USCI
- ADC
- Port