Chapter 4
Programming
©
National Instruments Corporation
4-7
Digital I/O
Chapter 7 of the DAQ-STC Technical Reference Manual describes the DIO
module of the DAQ-STC and illustrates an example (C language) in
Windowed mode to toggle the DIO lines. Example 1 verifies that the
Windowed addressing scheme works. Example 2 illustrates digital I/O.
Example 1
This example illustrates the use of Windowed registers by toggling the
digital lines.
First configure all the digital lines as outputs. Write 0x0 through 0xFF
to the DIO output register and make sure the digital lines toggle.
(This example is also presented in Chapter 7 of the DAQ-STC Technical
Reference Manual.)
1.
Set up the PCI board resources. Use the function
Setup_Mite
provided on the Companion Disk.
2.
Configure all the digital lines as outputs.
DIO_Control_Register = 0xFF;
3.
Output the digital patterns.
for (i=0;i<=255;i++)
{
DIO_Output_Register = i;
}
Example 2
This example shows how to perform digital I/O.
Configure digital lines 0, 2, 4, and 6 as outputs and the remaining lines as
inputs. Wrap back the output lines to the input lines. Write patterns 0b0000
and 0b1111 to the output lines. Read back the input pins to verify the data.
Also check some intermediate patterns.
1.
Set up the PCI board resources. Use the function
Setup_Mite
provided on the Companion Disk.
2.
Configure lines 0, 2, 4, and 6 as outputs and 1, 3, 5, and 7 as inputs.
DIO_Control_Register = 0x55;
3.
Write the digital pattern.
DIO_Output_Register = 0x00;