Allen-Bradley 1784-KTX Reference Manual page 108

Table of Contents

Advertisement

SWInterruptNumber = InterruptNumber + 0x8;
if (SWInterruptNumber > 0xf) SWInterruptNumber += 0x60;
/* Save the old interrupt handler vector, and install the new one */
/* Need to disable interrupts when changing vectors */
disable ();
OldInterruptServiceRoutine = getvect(SWInterruptNumber);
setvect(SWInterruptNumber, InterruptServiceRoutine);
/* Enable the interrupt by setting the appropriate bit in the PICMask to 0 */
PICMask = inportb(PICPortBase+1);
delay(50);
outportb(PICPortBase+1, PICMask & ~(1 << (InterruptNumber % 8)));
delay(50);
enable ();
}
/***************************************************************************
**
**
void InterruptServiceRoutine (void)
**
**
This routine is an example of how a host might want to service
**
interrupts from a KTX.
**
scanner to interrupt on input change-of-state and at the end of each
**
pass through the scan list.
**
can be received at a time, i.e., that because the KTX interrupts are
**
asynchronous to each other there may be more than one interrupt
**
pending.
**
**
INPUTS
**
KTX dualport and hardware status register.
**
**
OUTPUT
**
KTX dualport and hardware status changed
**
***************************************************************************/
void interrupt InterruptServiceRoutine(void)
{
UBYTE
temp;
/*============================================================================
**
**
Verify it was the KTX that caused the interrupt by reading the
**
status register.
**
==============================================================================*/
/**** Bit 0 of status reg == 1 when KTX ****/
/**** is the source of a host interrupt ****/
if (!(dp–>status_reg & 1))
return;
/**** Clear bit 0 of the status reg by ****/
/**** writing to acknowledge register. ****/
dp–>host_ack_of_ktx_int_reg = ACKNOWLEDGE_KTX;
/*============================================================================
**
**
Service the COS interrupt first, since it can happen most often...
**
1) make sure it's enabled
**
2) if so, see if we got a COS interrupt
**
3) if so, acknowledge it and check for COS overrun
**
==============================================================================*/
if (dp–>config_data.enable_cos_detect &&
(dp–>COS_link_address != COS_ACKNOWLEDGE)) {
/* Delay for PIC to settle */
/* Delay for PIC to settle */
/* Re–enable interrupts */
It assumes that the host has enabled the KTX
It assumes that more than one interrupt
Appendix B
Programming Examples
B-29

Advertisement

Table of Contents
loading

This manual is also suitable for:

1784-ktxd1784-kts

Table of Contents