National Instruments PC-TIO-10 User Manual page 47

Timing i/o board for the pc
Table of Contents

Advertisement

Programming
pa_ctrl = base_address + porta_offset + ctrl_offset;
pa_data = base_address + porta_offset + data_offset;
pb_ctrl = base_address + portb_offset + ctrl_offset;
pb_data = base_address + portb_offset + data_offset;
/*
clear any active interrupts by reading Data Registers
outp(pa_ctrl, 0x04);
inp(pa_data);
outp(pb_ctrl, 0x04);
inp(pb_data);
/*
install the interrupt service routine
isr_block.pa_ctrl = pa_ctrl;
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);
outp(pb_ctrl, 0x07);
/*
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
sure to pass a 32-bit structure pointer to the
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
register,
, by two in
bp
.
isr_handler()
PC-TIO-10 User Manual
/*
/*
/*
/*
/*
/*
install_isr()
install_isr()
to
far
near
and
install_isr()
remove_isr()
select Output Register
clear Port A interrupts */
select Output Register
clear Port B interrupts */
*/
/*
initialize isr_block
*/
enable falling-edge interrupts
enable rising-edge interrupts
*/
and
remove_isr()
function, because the main
and decrementing all references to the base page
only. Do not modify
4-14
*/
*/
*/
*/
*/
*/
is presented as follows. Be
© National Instruments Corporation
Chapter 4

Advertisement

Table of Contents
loading

Table of Contents