PRU ADC inaccuracy

I am trying to read analog voltage using PRU. It is possible to read from PRU and send data using pru_rpmsg_send and receive in linux side code and print the value. Problem is, the voltage is not accurate enough. ( These are the set of values I get when I give a constant 1.8V of supply - 1.771, 1.8, 1.5565, 1.64, 1.5569, 1.8, 1.6875, 1.8, 1.5516). Is there a way to fix it?

The ADC is not that inaccurate so this sounds more likely to be a bug in your code.

Note BTW that it’s not safe to have both PRU and Linux use the ADC at the same time nor should PRU mess with PRCM behind the kernel’s back so if you want PRU to use the ADC you should disable the linux kernel driver for it while telling the kernel to keep the ADC enabled at all times. Here’s a DT overlay that does this:

/dts-v1/; /plugin/;
&tscadc {
    status = "disabled";    // disable the kernel driver
    ti,no-idle;             // force-enable the peripheral
};
1 Like

Does that mean one cannot use PRU to control 3 ADC channels and use the arm side to control 2 different ADC channels directly at the same time?

Correct, either PRU owns the ADC or the kernel does. The solution would be for PRU to just pass the extra channels directly to userspace in some fashion.