16.5 Wait for Analog Input Circuit to Settle

After writing to either the channel register, Base+2, the input range register, Base+3, or the polarity register at page 2 base+13, you need to allow time for the analog input circuit to settle before starting an A/D conversion. The board has a built-in 10µs timer to assist with the wait period. Monitor the WAIT bit at Base+3, bit 5. When the bit value is 1, the circuit is actively settling on the input signal. When the value is 0, the board is ready to perform A/D conversions. The below code will work but does not account for possible hardware problems which could cause the program to freeze. A better approach is to enable a timeout by using a loop that will exit after a fixed number of tests.

while (inp(base+3) & 0x20); // wait for ADWAIT to go low, base+3 bit 5

Last updated