External device initialization, Interrupt handling – Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual
Page 169

9E. C Languages
II. SOFTWARE GUIDES - 9. Driver488/SUB
II-154
Personal488 User’s Manual, Rev. 3.0
External Device Initialization
Refer to the device manufacturer’s documentation on specific requirements for initializing your
IEEE 488 instrument. In the case of the ADC488, appropriate initialization involves sending it a
Clear
command and placing it into
Remote
mode:
Clear (adc) ;
Remote (adc) ;
For our hypothetical application, we also wish to have the ADC488 generate a service request should it
detect a command error. This involves sending a command string consisting of textual data to the
ADC488:
Output (adc, “M8X”) ;
We may also wish to perform other initialization and configuration. In this case, we set up the
ADC488 (
adc
) in the following configuration:
/* Setup the ADC488
Differential inputs (A0)
Scan group channel 1 (C1)
Compensated ASCII floating-point output format (G0)
Channel 1 range to +/-10V (R3)
One-shot trigger on talk (T6)
*/
The command to perform this configuration combines the above strings and adds the
Execute
(
X
)
command for the ADC488:
Output (adc,”A0C1G0R3T6X”) ;
Interrupt Handling
In case we send out an invalid command, either due to a programming error or an unanticipated
condition in the equipment, Driver488/SUB will automatically notify the interrupt handling function as
established above:
Output (adc,”V13X”) ;
The interrupt handler as established above might consist of a function similar to the following:
void isr (OpaqueP param) {
int
sp,
stadc,
errnum;
char
errtext [64] ;
/* Print parameter passed to isr to screen */
printf (“ In intrrupt handler, param=%d\n”,param) ;
/* Check if the intrrupt was due to a Service Request */
sp=SPoll (ieee) ;
if (sp==0) {
printf (“ No SRQ detected\n”) ;
exit (1) ;
}
/* Check that the Service Request was from the ADC488 */
stadc=SPo;l (adc) ;
if ((stadc&0x40)==0) {
printf (“ Not an ADC488 SRQ.\n”) ;
exit (1) ;
}
/* Interpret the Serial Poll response */
if (stadc&0x01)
printf (“ Triggered\n”) ;
if (stadc&0x02)