Due to the U.S. Thanksgiving holiday, please expect delayed responses during the week of 11/22.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC081C021: How to program the high, low , Alert of the DAC, read the DAC result

Part Number: ADC081C021
Other Parts Discussed in Thread: AM3357


I'm very new with linux development env and has some questions hope you can help me out.

my linux env uses TI AM3357 and kernel 4.14.96 of linux (Linaro), with ADC081C021 for battery monitor. 


the KernelConfig has the follow:



# Analog to digital converters



the Device tree has

- tps: tps@2d {
- reg = <0x2d>;
+ tampbatt: adc081c@54 {
+ compatible = "ti,adc081c";
+ reg = <0x54>;

-&tscadc {
+&gpio2 {
+  pinctrl-names = "default";
+  pinctrl-0 = <&gpio2_pins>;
   status = "okay";
-  tsc {
-          ti,wires = <4>;
-          ti,x-plate-resistance = <200>;
-          ti,coordinate-readouts = <5>;
-          ti,wire-config = <0x00 0x11 0x22 0x33>;
-          ti,charge-delay = <0x400>;
-  };
-  adc {
-          ti,adc-channels = <4 5 6 7>;
-  };


I see the iio:device0 listed under /sys/bus/iio/devices

when I change to iio:device0, it changed to /sys/devices/platform/ocp/44e0b000.i2c/i2c-0/0-0054/iio:device0

Q:  what this path mean? I'm kind of guess the 0-0054 is from tampbatt: adc081c@54 in the devicetree but don't know what the others are

I guess the below adc is comment out(am I correct?) in devicetree. So it is default one channel as I only see in_voltage_raw. 
- adc { - ti,adc-channels = <4 5 6 7>; - };

Q: if I want more channel , I just change the - to + to enable channel 4, 5,6,7. Otherwise it default to one channel only, right?

When I do a ls -al command, I see the below:

/sys/devices/platform/ocp/44e0b000.i2c/i2c-0/0-0054/iio:device0 # ls
buffer in_voltage_scale scan_elements
current_timestamp_clock name subsystem
dev of_node trigger
in_voltage_raw power uevent

Q: Why do I see in_voltage_raw instead in in_voltage0_raw.  There is no 0(zero) append to voltage. Is this normal?

When I do # cat in_voltage_raw, it returns 0. 

my app code to read the DAC as follows. The result is zero as I don't have the battery installed yet.

    int output_fd;
    char adcName[] = "/sys/bus/iio/devices/iio\:device0/in_voltage_raw"; 
    output_fd = open(adcName, O_RDWR);
    if (output_fd < 0) {
        LOG( LL_INFO, "failed to open ADC \n");
        int * exit;
    while (1)
        /* read ADC voltage */
        int readResult = read(output_fd, payload, BUF_SIZE);
        LOG( LL_INFO, "ADC output is %s readResult = %d \n",payload, readResult);


Q: Is my code above is the right way the user space code should read the DAC conversion value? If I want to program the ADC081C021 with High/Low and Alert Limit, how do I do that. Is there an example I can reference?

I have read through these links http://software-dl.ti.com/processor-sdk-linux/esd/docs/latest/linux/Foundational_Components/Kernel/Kernel_Drivers/ADC.html 

but don't see how to program the ADC081C021 with High/Low and Alert Limit in User Space code (my C code).

Very appreciate any help.


  • Hello Tom,

    Unfortunately, your questions are more related to Linux software, for that I would suggest looking to the Linux community for help. We do not develop or support Linux software development , even if it is used with our devices.

    This device is an I2C device, thus you will only be controlling two lines.

    For your future debugging I would suggest using an oscilloscope probing the digital communications to double check that the digital lines are doing what you expect them to do.



  • Thanks Cynthia for the reply. I will look for help in other resources as you suggest.