Using Interrupts with the GX3500 and GX3700/GX3700e FPGA Instruments

Knowledge Base Article # Q200221

Read Prior Article Read Next Article
Summary How to generate interrupts in an FPGA design and interface with these interrupts using the GXFPGA driver
  
Login to rate article
Interrupts are widely used as a means for hardware to handshake and syncronize with software in order to signal the completion of a hardware process or the need for a change in software execution. The Gx3500 and Gx3700 User FPGA boards both support this feature by exposing a dedicated hardware interrupt pin to the FPGA designer, and three API functions in software for interrupt management and set up.

Before getting started with Interrupts follow these steps:
  • Verify that  the GX3500 has the lastest firmware. The Interface FPGA, which contains the core firmware for the device, must be upgraded to version B003 or greater. This can be done by initializing the GX3500 from within the software front panel, clickong on the About Tab, clicking on Upgrade Firmware, and then browsing to the appropriate firmware file (.RPD file extension).
  • Verify that the latest GXFPGA software package has been installed (Version 1.2 or greater).

Software

The user can select to handle a hardware interrupt in one of two ways:
  • Assign a callback function to be invoked (in a new threadd) whenever an interrupt occurs (GxFpgaSetEvent)
  • Block (Wait) until an interrupt occurs or timeout (GxFpgaWaitOnEvent)
The software API functions that interface with the hardware generated interrupt are:

GxFpgaSetEvent

GxFpgaSetEvent(SHORT nHandle, SHORT nEventType, BOOL bEnable, Gt_EventCallback procCallback, PVOID pvUserData, PSHORT pnStatus)

This function is used to enable the capture of interrupt events and set up the callback interrupt handler.
nEventType: The type of event to capture. Currently this value must be set to GT_EVENT_INTERRUPT
bEnable: A boolean flag to enable or disable interrupt generation
procCallBack: A call back function (function pointer) can be passed to the procCallback parameter
pvUserData: A pointer to user data (scalar or structured data) that will be passed to the callback function when an interrupt occurs

Note: The callback function (passed into procCallback) must match the following prototype where GxFpgaCallBack can be any name:
GxFpgaCallBack(SHORT nHandle, SHORT nEventType, PVOID pvUserData)


GxFpgaWaitOnEvent

GxFpgaWaitOnEvent(SHORT nHandle, SHORT nEventType, LONG lTimeout, PSHORT pnStatus)

This function blocks program execution and waits for an interrupt to occur.
nEventType: The type of event to capture. Currently this value must be set to GT_EVENT_INTERRUPT
lTimeout: A timeout value (in terms of mS) to determine how long to wait for an interrupt before continuing the program

GxFpgaDiscardEvents

GxFpgaDiscardEvents(SHORT nHandle, SHORT nEventType, PSHORT pnStatus)

This function discards all pending interrupt requests.
nEventType: The type of event to capture. Currently this value must be set to GT_EVENT_INTERRUPT

Hardware

When creating an FPGA design, use the IRQ pin (as assigned in the pin planner) to generate a hardware interrupt. An interrupt is generated when the IRQ pin is driven from a logic low to a logic high state (Rising Edge).

Example

The GXFPGA driver contains an example that shows how to program the card interrupt. See the The GxFpgaExampleC.cpp and the  GxFpgaExampleIRQx250ms.rpd in the Examples\C folder. In the example an interrupt is generated every 250 mSec.
Article Date 8/12/2011
Keywords Interrupts, FPGA, GX3500, GX3700, GX3700e, GXFPGA, PCI Bus


Login to rate article

1 ratings | 5 out of 5
Read Prior Article Read Next Article