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.

ADC and Comparator on the same signal, TM4C129x

As I want to capture samples and make use of the digital comparator on the same signal pin, it seems that the sequencer priority locks one part from the other.

I use ADC_TRIGGER_ALWAYS to capture all samples (@1MHz).

The ADC is captured into Sequencer 0 and the comparator signal into sequencer 3.

Any ideas how to fix this problem ?

My test code is:

vInitADCtest2(void)
    {

        SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
        SysCtlDelay(10);

        GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3);

        /*
        // ******************************************************************************
        // Initialization of ADC1 Module for Acquisition of the excitation Signal on PK3
        //         Settings:
        //        1 Msps ^= 16MHz ADC clock
        //
        // Set up the Clock at | (VCO/15)/2 = (480/30) = 16MHz | which equals 1Msp/s
        */
        ADCClockConfigSet(ADC0_BASE, ADC_CLOCK_SRC_PLL | ADC_CLOCK_RATE_FULL, 30);

        ADCSequenceDisable(ADC0_BASE, ADC_SEQ);
        ADCSequenceConfigure(ADC0_BASE, ADC_SEQ, ADC_TRIGGER_ALWAYS, 0);
        ADCSequenceStepConfigure(ADC0_BASE, ADC_SEQ, 3, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END);
        ADCIntEnableEx(ADC0_BASE, ADC_INT_DMA_SS0);
        ADCSequenceEnable(ADC0_BASE, ADC_SEQ);



           //Comparator initialization
        ADCSequenceDisable(ADC0_BASE, COMP_SEQ);
        ADCSequenceStepConfigure(ADC0_BASE, COMP_SEQ, 0, ADC_CTL_CH0 | ADC_CTL_CMP0 | ADC_CTL_END);
        ADCSequenceConfigure(ADC0_BASE, COMP_SEQ, ADC_TRIGGER_ALWAYS, 1);


        ADCComparatorConfigure(ADC0_BASE, 0, ADC_COMP_INT_HIGH_ONCE);
        ADCComparatorRegionSet(ADC0_BASE, 0, 0,TriggerLevel);
        ADCComparatorReset(ADC0_BASE, 0, true, true);
        ADCComparatorIntEnable(ADC0_BASE, COMP_SEQ);
        ADCIntClear(ADC0_BASE, COMP_SEQ);

        ADCSequenceEnable(ADC0_BASE, COMP_SEQ);
        ADCIntEnableEx(ADC0_BASE, ADC_INT_DCON_SS3);
        ADCIntEnable(ADC0_BASE,COMP_SEQ);

    }

  • Hello Peter,

    The sequencer in the ADC have a priority order. However to be able to use the Comparator and the ADC Converter, you would need to use two ADC modules, such that ADC0 Sequencer-0 does the ADC conversion and ADC1 Sequencer-0 does the ADC Digital Comparator.

    While doing so please make sure that the GSYNC is set before you enable the two ADC Sequencers. There may be 2-3 clocks of lag between the conversions

    Regards

    Amit