I am new to using interrupts and have never even attempted to work with them before. I have explored many examples on the net, but I have not been able to come across anything that gives a good explanation just yet. I think I am beginning to understand the vector table and how to call and assign them, but I was wondering if anyone knew any good references or had some good advice for starting off with them. I am working with codewarrior and I am trying to programs interrupts for a MK 4x4 keypad combined with the MC9S12DG128 uC. Thank you so much for anything you may be able to contribute!
Here's what you must knwo about interrupt.
Interrupt are synchronous event triggered by peripheral or core. When an event occur, the code execution is stopped and interrupt rouine is served. Exiting from interrupt, the previous execution context is restore, and code execution is resumed.
Interrupt are controled by 2 flag ( 1 enable xxIE , and 1 event triggered xxIF) At core level there is a global interrupt enable flag use to mask all interrupts
To do so you must :
* Declare a interrupt service routine: It shall be mapped in a non banked area and decaler as an interrupt to inform the compiler to add conctext save / resore code ( interrupt prolog and epilog)
#pragma CODE_SEG __NEAR_SEG NON_BANKED
__interrupt void __near vDIna_iSeqAcquisition_Isr(void)
* Within the routine, you must acknwoledge the interrupt flag ( if not you'll loop inside the interrupt routine)
* At init you must enable your peripheral interrupt soucre and clear the interrupt triggered flag.
* You must alos configure the interrupt controller to register the address of the interrupt routine
* At the end you must enable global interrupt and start your peripheral.
You should download code example for your micro and make a code reading to see an impementation example.