Appendix D Register-Level Programming
PC-DIO-96/PnP User Manual
D-28
©
National Instruments Corporation
/* Now write out the counter load values for the selected counters. */
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/PnP 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/PnP 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
Содержание PC-DIO-96/PnP
Страница 46: ......
Страница 47: ......
Страница 48: ......
Страница 49: ......
Страница 50: ......
Страница 51: ......
Страница 52: ......
Страница 53: ......
Страница 54: ......
Страница 55: ......
Страница 56: ......
Страница 57: ......
Страница 58: ......
Страница 59: ......
Страница 60: ......
Страница 61: ......
Страница 63: ......
Страница 64: ......
Страница 65: ......
Страница 66: ......
Страница 67: ......
Страница 68: ......
Страница 69: ......
Страница 70: ......
Страница 71: ......
Страница 72: ......
Страница 73: ......