National Instruments PC-DIO-96 Switch User Manual


 
Chapter 4 Register-Level Programming
© National Instruments Corporation 4-23 PC-DIO-96 User Manual
if (use_ctr1) {
outp(ctr1, ((unsigned char) (ctr1_data & 0x00ff)));
/* Send the least significant byte of the
counter data for counter 1 */
outp(ctr1, ((unsigned char) ((ctr1_data & 0xff00) >> 8)));
/* Send the most significant byte of the
counter data for counter 1 */
}
outp(ctr0, ((unsigned char) (ctr0_data & 0x00ff)));
/* Send the least significant byte of the
counter data for counter 0 */
outp(ctr0, ((unsigned char) ((ctr0_data & 0xff00) >> 8)));
/* Send the most significant byte of the
counter data for counter 0 */
/* As soon as the last byte is written to counter 0, the counter begins
counting, and the PC-DIO-96 starts to interrupt the host computer. At this
point, you can run other code.... */
/* call_foreground_code(...); */
/* When you are ready to exit your program, you should deactivate the counters
and interrupts as shown below. */
if (use_ctr1) outp(cnfg,0x70); /* Turn off counter 1 */
outp(cnfg,0x30); /* Turn off counter 0 */
outp(ireg2,0x00); /* Disable PC-DIO-96 interrupts */
/* After you have deactivated interrupts, you must remove your interrupt
service routine before exiting your program--do this now. */
/* remove_isr(); */
}
Sample code for the functions install_isr() and remove_isr() is presented as follows. Be
sure to pass a 32-bit structure pointer to the
install_isr() function, because the main
program's data will probably be stored in a different memory segment than the one where the
interrupt functions are located. In addition, if you call the installation function from a language
besides C, make sure the parameters are passed in the proper order. C pushes parameters on the
stack from right to left, but most other languages, most notably Pascal, push parameters from left
to right. Finally, be sure to make the calls to the functions using 32-bit addresses, because all of
the code assumes data is offset with respect to a 32-bit return address. The code can be modified
to use 16-bit addresses by changing
far to near and decrementing all references to the base page
register,
bp , by two in install_isr() and remove_isr() only. Do not modify
isr_handler().
; assemble this file with the following command:
; masm /MX filename;
; /MX preserves case sensitivity
;
;
; function prototypes:
;
; void install_isr(int level, isr_block_type far * isr_block);
;
; on input, level indicates the interrupt level that is to be modified