Rockwell Automation D17846.2.4 CONTROLNET KT EMULA User Manual
Reference manual
Table of contents
Document Outline
- Reference
- Manual
- Overview of the KTCX Card Environment
- What Your Driver Must Do at Start-up
- How Your Driver Operates the KTCX Card
- Example Code for Polled and Interrupt Messaging
- Defined Statements for the KTCX Card
- Chapter 1
- Chapter 2
- What Your Driver Must Do at Start-up
- What This Chapter Covers
- Using the KTCX Memory-Mapped Hardware
- Initializing the KTCX Card
- 1. Reset the hardware by performing the following ...
- 2. Wait 4 seconds for the operating state to chang...
- 3. Load the following sequence into the dual-port:...
- 4. Release the card by writing a 1 to byte offset ...
- 5. Monitor the offset 0012h (KTCX_alive flag until...
- Usage With Interrupts
- KTCX Card Shutdown
- Restarting the KTCX Card After Shutdown
- Notes:
- What Your Driver Must Do at Start-up
- Chapter 3
- How Your Driver Operates the KTCX Card
- What This Chapter Covers
- General Communication Configurations
- Send and Receive Overview
- General Packet Structure
- Send Mailbox
- Procedure for Sending Data to the KTCX Send Mailbo...
- Send Packet Examples
- 1. The host application builds a Diagnostic Status...
- 2. The host polls the Send Access Request byte (00...
- 3. Host polls the Send Data Valid byte (0081h). If...
- 4. The host places the Diagnostic Status packet in...
- 5. The host zeros the Send Data Valid and Send Acc...
- 6. The KTCX card takes the packet and sets the Sen...
- 7. The KTCX card transmits the packet.
- 8. The KTCX card receives the response packet.
- 9. The KTCX card checks the receive mailbox.
- 10. The KTCX card places the response into the rec...
- 11. The host checks the Receive Access Request and...
- 12. The host resets the Receive Data Valid and Rec...
- 13. The host application acts upon the contents of...
- Send Data Memory Map
- Receive Mailbox
- Procedure for Receiving Data from the KTCX Receive...
- Receive Processes: Polled and Interrupt
- Code Examples for Polled and Interrupt Messaging
- Receive Examples
- Table 3.F Receive Message Example Memory Map
- 1. The KTCX card sets the hardware interrupt.
- 2. The host removes the packet from the receive ma...
- 3. The host writes 00h to byte 0481h to clear the ...
- 4. The host writes 00h to byte 0480h to clear the ...
- 1. The host monitors Receive Access Request and Re...
- 2. The host removes the packet from the receive ma...
- 3. The host writes 00h to byte 0481h to clear the ...
- 4. The host writes 00h to byte 0480h to clear the ...
- Receive Data Memory Map
- Appendix A
- Example Code for Polled and Interrupt Messaging
- int iCard=1; char stack[1024]; //temporary stack f...
- /* The following variables are used as part of emu...
- /* Pointer to the KT dualport */ DP *pDP=MK_FP(0xD...
- /* Pointer to location 0x802 (assert card)*/ char ...
- /* Pointer to location 0x803 (deassert card) */ ch...
- /* Pointer to KT interrupt enable flag. */ char *p...
- /*Send flag polled by main code and set by interru...
- /* Same as send but for receive box.*/ volatile in...
- /* Holds the address of the previous interrupt han...
- /* ID host and status transmission string */ char ...
- /* reset the card */ outportb( H186RESET, 0); outp...
- /* start the card */ outportb( HRESETOFF, 0); outp...
- /* wait a bit for the card to initialize itself */...
- /* Load initialization string into the kt dualport...
- /* monitor heartbeat flag for transition to 2 */ p...
- /* transmit 10 id host and status */ /* make sure ...
- cprintf("Transmit 10 packets of ID Host and Status...
- /* place an id host and stat message into the dual...
- /* release the send box */ pDP->comm.send.shake2 =...
- /* wait for the response message */ while ((pDP->c...
- /* Print the response out */ ptr = pDP->comm.rev.d...
- /* release the receive box */ pDP->comm.rev.shake2...
- /* shutdown KT emulation */ cprintf("Taking KT Emu...
- /* Interrupt driven test */ cprintf("Running emula...
- /* 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 ...
- /* Load the initializing string into the dualport ...
- *pRun = 1; cprintf(" Heartbeat: %2d, Run: %2d, Sto...
- /* monitor heartbeat flag for transition to 2 */ p...
- cprintf("\r\nHeartbeat:%2d,Stop %2d\r",pDP->comm.h...
- /* monitor the send and receive flags that are set...
- /* check if send box is available */ fSendBoxAvail...
- /* check if receive box is available */ fSendBoxAv...
- /* Transmit 10 requests and wait for 10 responses ...
- /* release the send box */ fSendBoxAvailable = FAL...
- /* check if the receive box is available */ if (fR...
- /* release the receive box */ fRecvBoxAvailable = ...
- /* SHUTDOWN the interrupt system */
- /* mask the interrupt */ outport(0x20+1, inport(0X...
- /* turn of the KTC interrupt trigger */ outportb( ...
- /* restore the vector */ setvect(0xD, oldhander); ...
- /* shutdown KT emulation */ cprintf("Taking KT Emu...
- Appendix B
- Defined Statements for the KTCX Card
- int iCard; //Global variable that is assigned prio...
- // 0=0x200, 1=0x220,...., 15=0x3e0
- #define BASE ( ( iCard * 0x20 ) + 0x200 )
- #define SHIFT 0x200
- # define
- HRESETON
- 0x00 * SHIFT + BASE + 3
- // reset SMAC
- # define
- HRESETOFF
- 0x00 * SHIFT + BASE + 2
- // reset SMAC clear
- # define
- HPTON
- 0x02 * SHIFT + BASE + 3
- // prog terminal on
- # define
- HPTOFF
- 0x02 * SHIFT + BASE + 2
- // prog terminal off
- # define
- HIO8
- 0x06 * SHIFT + BASE + 2
- // 8 bit host
- # define
- HIO16
- 0x06 * SHIFT + BASE + 3
- // 16 bit host
- # define
- HFAULTON
- 0x08 * SHIFT + BASE + 3
- // KTC processor reset
- # define
- HFAULTOFF
- 0x08 * SHIFT + BASE + 2
- // KTC processor run mode
- # define
- HIRQCTRL1
- 0x34 * SHIFT + BASE + 3
- // interrupt control reg 1
- # define
- HIRQCTRL2
- 0x38 * SHIFT + BASE + 2
- // interrupt control reg 2
- # define
- IRQ2_HMASK
- 0x04
- # define
- IRQ3_HMASK
- 0x05
- # define
- IRQ5_HMASK
- 0x06
- # define
- IRQ7_HMASK
- 0x07
- # define
- IRQ10_HMASK
- 0x08
- # define
- IRQ11_HMASK
- 0x09
- # define
- IRQ12_HMASK
- 0x0a
- # define
- IRQ15_HMASK
- 0x0b
- --------------------------------------------------...
- File Name: kt.h
- Application: KT Emulator for the KTCX Card.
- Description: Header file for the KT Emulator
- --------------------------------------------------...
- #indef KT_H #define KT_H
- #define KT_VERSION 0x07 // This value goes up at d...
- #indef TRUE #define TRUE 1 #endif #ifndef FALSE #d...
- --------------------------------------------------...
- /*Dual-port STRUCTURES */
- /* These are structures that allow easy access to ...
- /* for each of the different dual-port configurati...
- --------------------------------------------------...
- /* For use during communications ( the first two a...
- typedef struct { signed char shake1; /* First hand...
- typedef struct { signed char shake1; /* First hand...
- typedef struct { signed char unused1[4]; signed ch...
- typedef union { unsigned char byte[sizeof(DP_COMM)...
- #endif
- A,
- C,
- D,
- E,
- G,
- H,
- I,
- K,
- L,
- M,
- N,
- O,
- P,
- R,
- S,
- T,
- U,
- How Your Driver Operates the KTCX Card