I have enabled the analog inputs on a Beaglebone Black by adding BB-ADC to optargs in uEnv.txt:
optargs=capemgr.disable_partno=BB-BONELT-HDMI capemgr.enable_partno=BB-SPIDEV0,BB-SPIDEV1,BB-UART1,BB-ADC
The basic analog input works, if I do a:
cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
it returns a value which is proportional to the applied voltage.
However the value is not always up-to-date. If I change the input voltage, I can read the old input voltage several times before I can read the correct value. The strange part is that I am obviously not just reading a stored value, because the LSB can change on subsequent reads, until I finally read the correct value:
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
489
The applied voltage is now halved (from ~200mV to ~100mV). I wait for about 1 second between each read:
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
489
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
488
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
489
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
489
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
489
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
488
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
489
jsa@bb00:~$ cat /sys/bus/iio/devices/iio:device0/in_voltage3_raw
243
Finally I read the correct value. What is going on? Can I force an update (sample)?