
ECAN1000 User’s Manual
24
BDM-610020026 rev B
The following C example shows what the shell of your ISR should be like:
/*-------------------------------------------------------------------------------
| Function:
new_IRQ_handler
| Inputs:
Nothing
| Returns:
Nothing
- Sets the interrupt flag for the EVENT.
|-------------------------------------------------------------------------------*/
void interrupt far new_IRQ_handler(void)
{
IRQ_flag = 1;
// Indicate to main process interrupt has oc-
curred
{
// Your program code should be here
}
// Read interrupt status registers
// Clear interrupt on ECAN1000HR
outp(0x20, 0x20);
/* Acknowledge the interrupt controller. */
}
Saving the Startup Interrupt Mask Register (IMR) and interrupt vector
The next step after writing the ISR is to save the “start up”-state of the in-
terrupt mask register and the original interrupt vector you are using. The
IMR is located in address
21h
. The interrupt vector you will be using is lo-
cated in the interrupt vector table which is an array of pointers (ad-
dresses) and it is locate din the first 1024 bytes of the memory (Segment
0 offset 0). You can read this value directly, but it is better practice to use
DOS function 35h (get interrupt vector) to do this. Most C compilers have
a special function available for doing this. The vectors for the hardware
interrupts on the XT-bus are vectors 8-15, where IRQ0 uses vector 8 and
IRQ7 uses vector 15. Thus if your ECAN1000HR is using IRQ5 it corre-
sponds to vector number 13.
Before you install your ISR, temporarily mask out the IRQ you will be us-
ing. This prevents the IRQ from requesting an interrupt while you are in-
stalling and initializing your ISR. To mask the IRQ, read the current IMR
at I/O port 21h, and set the bit that corresponds to the IRQ. The IMR is
arranged so that bit 0 is for IRQ0 and bit 7 is for IRQ7. See the para-
graph entitled
Interrupt Mask Register (IMR
) earlier in this discussion for
help in determining your IRQ's bit. After setting the bit, write the new
value to I/O port 21h.