HP (Hewlett-Packard) E1459A Network Router User Manual


 
Using the HP E1459A Module 37
Example 3:
Edge Interrupt
This example repeatedly polls the Port 0 Port Summary Edge Detection
Register to determine when an edge event occurs. When an event occurs, the
program reads the values of the Positive and Negative Edge Registers and
returns the values. The values returned are in the range of -32768 to +32767.
Although this program does not decode this returned value to determine
individual bit/channel values, a "0" in any bit position indicates an edge
event was not
detected for the corresponding channel; a "1" in any bit
position indicates an edge event was detected for the corresponding channel.
/* Edge Interrupt Example
This program sets both positive and negative edge detection,
queries the Port Summary Edge Detection Register in a loop
until an event occurs. The program then read the PEDGE and NEDGE
registers and returns the current value.
Created in Microsoft Visual C++ */
#include <visa.h>
#include <stdio.h>
#include <stdlib.h>
#define INSTR_ADDR "GPIB0::9::3::INSTR"
/* HP E1459A logical address */
int main()
{
ViStatus errStatus;
/* status from VISA call */
ViSession viRM;
/* Resource Mgr. session */
ViSession E1459;
/* session for HP E1459A */
int val, event;
/*
Open a default Resource Manager
*/
errStatus = viOpenDefaultRM (&viRM);
if (VI_SUCCESS > errStatus){
printf("ERROR: viOpen() returned 0x%x\n",errStatus);
return errStatus;}
/*
Open the Instrument Session
*/
errStatus = viOpen (viRM, INSTR_ADDR,VI_NULL,VI_NULL, &E1459);
if (VI_SUCCESS > errStatus){
printf("ERROR: viOpen() returned 0x%x\n",errStatus);
return errStatus;}
/*
Unmask the negative edge events for Port 0
*/
errStatus = viPrintf (E1459, "EVEN:PORT0:NEDG:ENAB 0xFFFF\n");
if (VI_SUCCESS > errStatus){
printf("ERROR: viPrintf() returned 0x%x\n",errStatus);
return errStatus;}
/*
Unmask the positive edge events for Port 0
*/
errStatus = viPrintf (E1459, "EVEN:PORT0:PEDG:ENAB 0xFFFF\n");
if (VI_SUCCESS > errStatus){
printf("ERROR: viPrintf() returned 0x%x\n",errStatus);
return errStatus;}
/*
Set Port 0 debounce time to 1.13 mS
*/
errStatus = viPrintf (E1459, "INP0:DEB:TIM 1E-3\n");