Programming
Chapter 4
PC-TIO-10 User Manual
4-14
© National Instruments Corporation
pa_ctrl = base_a porta_ ctrl_offset;
pa_data = base_a porta_ data_offset;
pb_ctrl = base_a portb_ ctrl_offset;
pb_data = base_a portb_ data_offset;
/* clear any active interrupts by reading Data Registers */
outp(pa_ctrl, 0x04); /* select Output Register */
inp(pa_data); /* clear Port A interrupts */
outp(pb_ctrl, 0x04); /* select Output Register */
inp(pb_data); /* clear Port B interrupts */
/* install the interrupt service routine */
isr_block.pa_ctrl = pa_ctrl; /* initialize isr_block */
isr_block.pa_data = pa_data;
isr_block.pb_ctrl = pb_ctrl;
isr_block.pb_data = pb_data;
isr_block.done = 0;
install_isr(irq_channel, &isr_block);
/* configure Ports A and B for interrupts */
outp(pa_ctrl, 0x05); /* enable falling-edge interrupts */
outp(pb_ctrl, 0x07); /* enable rising-edge interrupts */
/* wait for the process to be completed */
while (!isr_block.done)
/* call_foreground_code() */ ;
/* disable interrupts and remove the interrupt service routine */
outp(pa_ctrl, 0x04);
inp(pa_data);
outp(pb_ctrl, 0x04);
inp(pb_data);
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()
.
Summary of Contents for PC-TIO-10
Page 57: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 2 National Instruments Corporation ...
Page 58: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 3 PC TIO 10 User Manual ...
Page 59: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 4 National Instruments Corporation ...
Page 60: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 5 PC TIO 10 User Manual ...
Page 61: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 6 National Instruments Corporation ...
Page 62: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 7 PC TIO 10 User Manual ...
Page 63: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 8 National Instruments Corporation ...
Page 64: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 9 PC TIO 10 User Manual ...
Page 65: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 10 National Instruments Corporation ...
Page 66: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 11 PC TIO 10 User Manual ...
Page 67: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 12 National Instruments Corporation ...
Page 68: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 13 PC TIO 10 User Manual ...
Page 69: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 14 National Instruments Corporation ...
Page 70: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 15 PC TIO 10 User Manual ...
Page 71: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 16 National Instruments Corporation ...
Page 72: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 17 PC TIO 10 User Manual ...
Page 73: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 18 National Instruments Corporation ...
Page 74: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 19 PC TIO 10 User Manual ...
Page 75: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 20 National Instruments Corporation ...
Page 76: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 21 PC TIO 10 User Manual ...
Page 77: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 22 National Instruments Corporation ...
Page 78: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 23 PC TIO 10 User Manual ...
Page 79: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 24 National Instruments Corporation ...
Page 80: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 25 PC TIO 10 User Manual ...
Page 81: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 26 National Instruments Corporation ...
Page 82: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 27 PC TIO 10 User Manual ...
Page 83: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 28 National Instruments Corporation ...
Page 84: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 29 PC TIO 10 User Manual ...
Page 85: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 30 National Instruments Corporation ...
Page 86: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 31 PC TIO 10 User Manual ...
Page 87: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 32 National Instruments Corporation ...
Page 88: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 33 PC TIO 10 User Manual ...
Page 89: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 34 National Instruments Corporation ...
Page 90: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 35 PC TIO 10 User Manual ...
Page 91: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 36 National Instruments Corporation ...
Page 92: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 37 PC TIO 10 User Manual ...
Page 93: ...AMD Am9513A Data Sheet Appendix C PC TIO 10 User Manual C 38 National Instruments Corporation ...
Page 94: ...Appendix C AMD Am9513A Data Sheet National Instruments Corporation C 39 PC TIO 10 User Manual ...