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.

MSPM0G3507-Q1: ADC Reading Varies with DAC Value in Comparator-Triggered Setup

Part Number: MSPM0G3507-Q1
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi everyone,

I'm working with the MSPM0L3507 and I've encountered an issue where the ADC reading varies depending on the DAC value set at the input of a comparator, even though the DAC value remains constant at each acquisition. This suggests some kind of interaction or interference between the DAC, comparator, and ADC subsystems.

Setup Details:

    The ADC is triggered by an event from the comparator.

    The DAC is configured to output a voltage that serves as one of the comparator inputs, defining a threshold.

    The reference voltage for both DAC and ADC is set to the internal reference: VREF+ = 2.5 V; VREF− = GND.

Could the comparator-triggered ADC conversion be affected by the DAC value used in the comparator? Are there any best practices for this kind of setup?

These are pics of my setup:

Any insights or suggestions would be greatly appreciated!

Thanks in advance!

Daniel

  • Has anyone worked with comparator-triggered ADC on MSPM0? I'm looking for a practical example using:

    Conversion mode: Single
    Trigger source: Event (via comparator)
    Any code snippets or project references would be greatly appreciated!

  • Hi Daniel,

    Just one thing need to confirm, since you mention that there will be some kind of interaction or interference, how big is it? In other word, how big error is there between the normal ADC acquisition and the acquisition using the comparator trigger method of yours?

    Best Regards,
    Peter

  • Dear Peter,

    Thank you for your reply. We did not performed a normal ADC acquisition because of the limitations of the ADC itself. Probably, it could be done with the window comparator ADC, but we did not tried it. However, we expect some fast pulses (500 ns duration) with specific heights that are not being registered properly. We should set up the ADC and the trigger to be fast enough and avoid delays. Please find below some excerpts from our code. Let us know if you see any areas for improvement.


    This is the ADC IRQ handler:
    void ADC_SENSOR_INST_IRQHandler(void)
    {
    if (DL_ADC12_getPendingInterrupt(ADC_SENSOR_INST) == DL_ADC12_IIDX_MEM0_RESULT_LOADED) {
    gADCResult = DL_ADC12_getMemResult(ADC_SENSOR_INST, DL_ADC12_MEM_IDX_0);
    gCheckADC = true;
    }
    }

    This is the loop we use to process the ADC events:

    while(1)
    {
    while(!gCheckADC){ // Wait for the ADC event
    __WFE();
    }

    if (gCheckADC) {
    // Disable ADC
    DL_ADC12_disableConversions(ADC_SENSOR_INST);

    // our logic goes here!

    gCheckADC = false;
    // Enable ADC again
    DL_ADC12_enableConversions(ADC_SENSOR_INST);
    }
    }

    Before each acquisition, we may need to change the Comparator's DAC value. I would like to know if this is the best approach:

    // Step 1: Disconnect the publishing channel to avoid premature triggers.
    DL_COMP_setPublisherChanID(COMP_INST, 0);
    // Step 2: Temporarily disable event
    DL_COMP_disableEvent(COMP_INST, DL_COMP_EVENT_OUTPUT_EDGE);
    // Step 3: Update the comparator's internal DAC value
    DL_COMP_setDACCode0(COMP_INST, dacComp);
    // Step 4: Reconnect the publishing channel
    DL_COMP_setPublisherChanID(COMP_INST, COMP_0_INST_PUB_CH);
    // Step 5: Re-enable event
    DL_COMP_enableEvent(COMP_INST, DL_COMP_EVENT_OUTPUT_EDGE);
    // Stage 6: Enable the comparator
    DL_COMP_enable(COMP_INST);

    This is the sysconfig for the ADC

    And this is the Comp:

    Specifically:

    1 - Could we use a higher clock for the ADC?

    2 - Is there another approach for faster pulse processing?

  • Let me check it and reply to you later.

    Best Regards,
    Peter

  • Dear Peter, 

    Should we also disable the comparator in this void:

    void ADC_SENSOR_INST_IRQHandler(void)
    {
    if (DL_ADC12_getPendingInterrupt(ADC_SENSOR_INST) == DL_ADC12_IIDX_MEM0_RESULT_LOADED) {
    gADCResult = DL_ADC12_getMemResult(ADC_SENSOR_INST, DL_ADC12_MEM_IDX_0);
    gCheckADC = true;

    //Put a command to disable the comparator here?
    }
    }

    And then enable again when gCheckADC is false?