Shutdown kt emulation */ cprintf("taking kt emu, Example code for interrupt messaging, Interrupt driven test */ cprintf("running emula – Rockwell Automation D17846.2.4 CONTROLNET KT EMULA User Manual

Page 33: Hold the card in reset while the interrupt syst, Set the card up to interrupt on irq5 */ outport, Setup the interrupt vector */ oldhandler = getv, Unmask the interrupt */ outport(0x20+1, inport, Inumints=0, Release the ktc. this will activate the card, There should be at least one interrupt at this

Advertising
background image

1784-6.2.4 - September 1997

Example Code for Polled and Interrupt Messaging

A-3

/* shutdown KT emulation */
cprintf("Taking KT Emulation Mode offline (shutdown emulation)\r\n");
pDP->comm.online

=0xff

pDP->comm.shutdown_trig=0x01;
cprintf("Waiting for KT stopped flag to go to 0xFF......\r");
while (!kbhit() && (pDP->comm.shutdown_stat != -1))
{
}
cprintf("KT has been shutdown \r");
*pReset = 1;
pDp->comm.heartbeat = 4;
PDp->comm.shutdown_trig = 0

Example Code for
Interrupt Messaging

The following example code shows how to run interrupt messaging
over the dual-port.

/* Interrupt driven test */
cprintf("Running emulation under interrupts\r\n");

/* Hold the card in reset while the interrupt system is being setup */
outportb( H186RESET,0 );
outportb( HRESETON,0 );

/* Set the card up to interrupt on IRQ5 */
outportb (HIRQCTRL1,0);
outportb (HIRQCTRL2,IRQ5_HMASK);

/* setup the interrupt vector */
oldhandler = getvect(0xD);
setvect(0xD, KTCIRQHandler);

/* unmask the interrupt */
outport(0x20+1, inport(0x20+1) & ~0x20);

iNumInts=0;

/* release the KTC. This will activate the card */
i = *(int *) MK_FP(0xd000, 0x3ffc);
outportb( HRESETOFF, 0);
outportb( H186RUN, 0xff );

/* There should be at least one interrupt at this time */
delay (4000);

/* Load the initializing string into the dualport */
cprintf("\r\nStarting up emulation mode...wait 1/2 second\r\n");
pDP->comm.unused1[0]=0xC3;
pDP->comm.unused1[1]=0x00;
pDP->comm.unused1[2]=0x00;
pDP->comm.unused1[3]=0x00;
pDP->comm.online

=0x00;

pDP->comm.nodeaddr=0x08;
pDP->comm.shutdown_trig=0x00;

*pRun = 1;
cprintf(" Heartbeat: %2d, Run: %2d, Stop: %2d\r", pDP->comm.heartbeat, *pRun, *pReset);
delay(500)

/* monitor heartbeat flag for transition to 2 */
pHBPrev = pDP->comm.heartbeat;
while ((!kbhit()) && (pDP->comm.heartbeat !=2))
{

if (pHBPrev != pDP->comm.heartbeat)
{

cprintf("\r\nHeartbeat:%2d,Stop %2d\r",pDP->comm.heartbeat,*pRun,*pReset); pHBPrev =

pDP->comm.heartbeat;

}

}
cprintf("\r\n---->%5d"iNumInts);

/* monitor the send and receive flags that are set by the interrupts */
/*
turn on the KT interrupts */
*pIntMode = 0x01 |/*on transmit interrupts*/

0x02;

/*on receive interrupts*/

/* check if send box is available */
fSendBoxAvailable=(((pDP->comm.send.shake1==1) && (pDPcomm.rev.shake2 ==1)) - TRUE :FALSE);

/* check if receive box is available */
fSendBoxAvailable=(((pDP->comm.rev.shake1 ==1) && (pDP-comm.rev.shake2==1)) - TRUE :FALSE);

Advertising