Siemens MC55 User Manual Page 28

  • Download
  • Add to my manuals
  • Print
  • Page
    / 31
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 27
Page 28 of 31
arranged so that bit 0 is for IRQ0 and bit 7 is for IRQ7. See the paragraph 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.
With the startup IMR saved and the interrupts temporarily disabled, you can assign the interrupt
vector to point to your ISR. Again you can overwrite the appropriate entry in the vector table with
a direct memory write, but this is not recommended. Instead use the DOS function 25h (Set
Interrupt Vector) or, if your compiler provides it, the library routine for setting up interrupt vectors.
Remember that interrupt vector 8 corresponds to IRQ0, vector 9 for IRQ1 etc.
If you need to program the source of your interrupts, do that next. For example, if you are using
transmitted or received messages as an interrupt source program it to do that. Finally, clear the
mask bit for your IRQ in the IMR. This will enable your IRQ.
Common Interrupt mistakes
Remember hardware interrupts are from 8-15, XT IRQ's are numbered 0-7. Do not forget to clear
the IRQ mask bit in the IMR Forgetting to send the EOI command after ISR code. Disables further
interrupts.
Example on Interrupt vector table setup in C-code:
void far _interrupt new_IRQ1_handler(void ); /* ISR function */
#define IRQ1_VECTOR 3 /* Name for IRQ */
void (interrupt far *old_IRQ1_dispatcher)
(es,ds,di,si,bp,sp,bx,dx,cx,ax,ip,cs,flags); /* Variable to store old IRQ_Vector */
void far _interrupt new_IRQ1_handler(void );
/*----------------------------------------------------------------------
| Function: init_irq_handlers
| Purpose: Set the pointers in the interrupt table to point to
| our functions i.e. setup for ISR's.
|----------------------------------------------------------------------*/
void init_irq_handlers(void)
{
_disable();
old_IRQ1_handler = _dos_getvect(IRQ1_VECTOR + 8);
_dos_setvect(IRQ1_VECTOR + 8, new_IRQ1_handler);
Gi_old_mask = inp(0x21);
outp(0x21,Gi_old_mask & ~(1 << IRQ1_VECTOR));
_enable();
}
|/*----------------------------------------------------------------------
| Function: restore, do this before exiting program
| Purpose: Restore the interrupt vector table.
|----------------------------------------------------------------------*/
void restore(void)
{
/* Restore the old vectors */
_disable();
_dos_setvect(IRQ1_VECTOR + 8, old_IRQ1_handler);
outp(0x21,Gi_old_mask);
_enable();
}
Page view 27
1 2 ... 23 24 25 26 27 28 29 30 31

Comments to this Manuals

No comments