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.

AM3352: ADC detection ability

Part Number: AM3352

We use 7 ADC channels  in our platform, and the sample rate of channel 0 need for every 15 microseconds. The channel 0 sample period need 3.5 milliseconds (231 sample). (Total sample counts is 66 for 1 millisecond).

Other channels (channel 1 to channel 6) for every 50 milliseconds to get one sample.

How could we implement these by one-shot mode or continuous mode?

When we use one-shot mode, it seen need about 100 microseconds to get one sample value. Do any suggestion to speed up the detection?

The one-shot mode we use the follow code.

fd = open("/sys/bus/iio/devices/iio:device0/in_voltage0_raw", O_RDONLY);

read(fd,tmp,4);

lseek(fd,0,SEEK_SET);

  • When we use continuous mode, channel 0 can't get the correct value.
    The dts setting as folllow.
    adc {
    ti,adc-channels = <0 1 2 3 4 5 6>;
    ti,chan-step-opendelay = <0x1E>;
    ti,chan-step-sampledelay = <0x1>;
    ti,chan-step-avg = <0>;
    };
    If we open one channel, we could get the correct value.
    adc {
    ti,adc-channels = <0>;
    ti,chan-step-opendelay = <0x1E>;
    ti,chan-step-sampledelay = <0x1>;
    ti,chan-step-avg = <0>;
    };
    But we already use 7 channel, how could we implement it?
  • Hello Yuliang,

    If you have timing requirements, you should use continuous mode and then set your delays as discussed in the AM3352 TRM "Touchscreen Controller" chapter. (the timing settings are controlled at a low level by STEPCONFIG and STEPDELAY registers). The "Operational Modes" section in particular discusses timing.

    What version of Linux are you using?

    What do you mean by "get the correct value"?

    Regards,
    Nick
  • Linux are "Linux (none) 4.9.59 #6 PREEMPT Thu Oct 18 13:55:51 CST 2018 armv7l GNU/Linux"

    The correct value mean that we could get the ADC value at the specified time slot. For example, every 15 microseconds to get the ADC value.

  • Hello Yuliang,

    I am sorry for such a long wait. It does not look like you can use the linux drivers to get custom sample rates for different ADC channels. I am verifying that with another engineer.

    You definitely want continuous mode. There are two ways I can think of for you to currently get custom sample rates.

    1) Manually set the ADC registers as described in the TRM chapter. Note that the minimum time for a STEP to be completed is 15 ADC clock samples (0.625 us). I am not sure that you could get the right ratios for your program using this method, but it might cut down on the total samples you need to take. (e.g., setting all delays to the same and doing STEP1=Chan0, STEP2=Chan1, STEP3=Chan0, STEP4=Chan2, ..., STEP11=Chan0, STEP12=Chan6 gives a Chan0 sample rate of 2x the time for a STEP to complete, and Chan1-Chan6 a sample rate of 12x the time for a STEP to complete)

    2) Oversample your channels, and have software remove the samples that are not needed.

    Regards,
    Nick
  • Hello Yuliang,

    I just confirmed that the Linux driver does not support custom sample rates for different ADC channels. You will have to directly set the ADC registers if you do not want to sample everything at the same rate. You could also make custom changes to tiadc_step_config() to setup steps in the way you want.

    Regards,
    Nick