Mini PCIe ADC
Users Guide
Document: CTIM-00149
Revision: 0.02
Page 15 of 22
Connect Tech Inc. 800-426-8979 | 519-836-1291
Date: 2018-10-25
Example B – ADC Operation with different input range
In this example we will set:
-
ADC0 to take a readings from CH0 with an input voltage range of +/-10.24V
-
ADC1 to take a readings from CH0 with an input voltage range of +10.24V
printf(
"ADC0&1: enabling chan0 and setting input range\n"
);
control_config = 0x80;
CTIFPGAWrWord(pbrd, BarIndex, ADC0+CONTROL_CONFIG, control_config);
CTIFPGAWrWord(pbrd, BarIndex, ADC1+CONTROL_CONFIG, control_config);
input_range = 0x0;
CTIFPGAWrDword(pbrd, BarIndex, ADC0+INPUT_RANGE_SELECT, input_range);
input_range = 0x0;
for
(ch=0;ch<8;ch++)
{
input_range|= (0x5 << (3*ch));
}
CTIFPGAWrDword(pbrd, BarIndex, ADC1+INPUT_RANGE_SELECT, input_range);
printf(
"\nReading ADC Voltages...\n"
);
i=0;
CTIFPGARdWord(pbrd, BarIndex, ADC0+CH0_LAST(i*2), &testreg);
ADC0votlage = testreg * (20.48/0x10000) - 0x8000 * (20.48/0x10000);
printf(
"ADC0 Ch%d, Address %x, CODE=%04x Voltage=%08f\n"
, i, ADC0+CH0_LAST(i*2),testreg, ADC0votlage);
i=0;
CTIFPGARdWord(pbrd, BarIndex, ADC1+CH0_LAST(i*2), &testreg);
ADC1votlage = testreg * (20.48/0x10000);
printf(
"ADC1 Ch%d, Address %x, CODE=%04x Voltage=%08f\n"
, i, ADC1+CH0_LAST(i*2),testreg, ADC1votlage);