Hello,
I’m using the following code to read from an ADC in iMX7D.
int ADC_read()
{
int fadc;
int value;
char buffer[5];
fadc = open("/sys/bus/iio/devices/iio:device0/in_voltage0_raw", O_RDONLY);
if (fadc == -1)
return(-1);
if (read(fadc, buffer, 4) == -1)
return(-1);
close(fadc);
buffer[4] = '\0';
value = atoi(buffer);
return(value);
}
By measuring the time needed to complete this read function, it takes about 115 µs, (which means the sampling rate would be about 9 khz). In the documentation of Colibri iMX7 it is stated that the sampling rate can be up to 1Mhz.
How can I reduce the current delay? is there a better ready function from Toradex to read from ADCs?
Best regards,
Majd