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.

UCD3138A64: Requesting help using EADC in SAR mode

Part Number: UCD3138A64

I thought I had posted this last night, but I do not see it in the forum.  My apologies if this is a duplicate.

I am trying to operate EADC1 in SAR mode, but the EADCVALUE register is always 0.

I am operating DPWM0 at 200KHz to trigger the EADC sampling.

EADCCTRL.bit.EADC_MODE = 2
EADCCTRL.bit.AFE_GAIN = 0
EADCCTRL.bit.SCFE_GAIN_FILTER_SEL = 1
EADCCTRL.bit.SCFE_CLK_DIV_2 = 1
EADCCTRL.bit.SCFE_ENA = 1
EADCCTRL.bit.EADC_ENA = 1

I also set SARCTRL.bit.SAR_RESOLUTION = 3 to get 1 millivolt resolution.
All other fields of SARCNTL are left at reset value.

Do I need to modify any of the other fields of SARCNTL?
Do I need to modify any other register.

I searched online for sample code, but found none.  Does anyone know of sample code?

Thank you.

  • Hello,

    The below registers need be programmed, for example:

    FeCtrl1Regs.SARCTRL.bit.EADC_WINDOW_1 = 0x4D;
    FeCtrl1Regs.SARCTRL.bit.EADC_WINDOW_2 = 0x2D;
    FeCtrl1Regs.SARCTRL.bit.SAR_RANGE = 16; //0x20;
    FeCtrl1Regs.SARCTRL.bit.SAR_RESOLUTION = 1;

    Regards,

  • I appreciate the response.

    I added your register settngs exactly to the code, but it did not solve my issue;  I am still getting all zeros in the EADCVALUE register.

    I must be missing something subtle, but necessary.
    Besides the EADCCNTL and the SARCNTL registers is there any thing else needed.
    (As I mentioned in my first message, DPWM0 is operating at 200KHz.)

    Thank you.

  • Hello,

    The expert is out of office. Will come to you when he's back.

    Best Regards,

    Xuemei

  • Hello,

    1. Please make sure the same front end is used;

    2. Please check if the EADC is triggered by DPWM. such as

    LoopMuxRegs.SAMPTRIGCTRL.bit.FE2_TRIG_DPWM1_EN = 1;  //Enables Sample Trigger from DPWM 1 to Front End Control 2

    Regards,

    Sean

  • I am using Front End 1, so LoopMuxRegs.SAMPTRIGCTRL.bit.FE1_TRIG_DPWM0_EN = 1

    I made some changes and I am finally getting some values in ABS_VALUE.
    The last change which produced results in ABS_VALUE was changing SAMP_TRIG_SCALE from 1 to 15.
    As I mentioned earlier, I am sample triggering off of DPWM0 at 200KHz.

    Is it possible that the SAR takes longer than 5 microseconds to run?
    If so, how fast can it be run?

    The counts in ABS_VALUE are consistently low even as I change the DC test voltage to various levels during testing.

    Is it possible that the the SAR is not completing and I am reading an intermediate result from ABS_VALUE?
    Is there a flag which indicates SAR calculation is done?

    Thanks for the help,

    -Craig

  • what value is used in the below register?

    Dpwm1Regs.DPWMSAMPTRIG1.all

    SAR has short time than 5us to finish conversion.

    I haven't seen SAR is not completed as long as EAD is triggered.

  • Sorry for the delay.  I am having CCS problems.

    I am not using DPWM1
    I should be triggering off of DPWM0.

    Dpwm0Regs.DPWMSAMPTRIG1.all = 1664.

    I borrowed the code, but I believe the intent was to trigger near the falling edge of DPWM0A; DPM0A pulse width may be very short at this moment.

    At this moment, it should not matter where the trigger occurs because the EADC is connected to the output of a current sensor which is being fed a constant current.

  • Please use smaller Dpwm0Regs.DPWMSAMPTRIG1.all , such as 50.

  • Thank you for the suggestion.  I am working remote today.  I will be in the lab Mnday morning and will try it then.

  • I am getting results, but they are still reading low.

    I need to check with the hardware designer about scaling resistors in the analog circuit.

    I appreciate all the help.  I may try a method other than SAR to get calculate the analog signal value.

    I'm going to leave this thread open for a few days in case there is a follow-up.

    Thank you again.

  • You are welcome! Please come back when you get more update. I can close it temporarily.