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.

EK-TM4C123GXL: ADC together with Digital Comparator

Part Number: EK-TM4C123GXL

Help me deal with work of the ADC and the digital comparator.
I want to receive an interrupt from ADC at the end of Sequence and  Digital comparator.
As soon as I turn on the COPM0. ADC does not work.
Thanks.

Andrew

karu2003/Power_Monitor (github.com)

void ADCInit(void)
{
       SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
       GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3 | GPIO_PIN_2);
       SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
       GPIOPinTypeADC(GPIO_PORTD_BASE, GPIO_PIN_3);
       // ADCHardwareOversampleConfigure(ADC0_BASE, 64);
       ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_TIMER, 0);
       // ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0 | ADC_CTL_D);
       // ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH2 | ADC_CTL_D); //ADC_CTL_CMP0
       ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_CH0 | ADC_CTL_D);
       ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_CH2 | ADC_CTL_IE | ADC_CTL_END); //| ADC_CTL_CMP0
       IntEnable(INT_ADC0SS1);
       ADCSequenceEnable(ADC0_BASE, 1);
       ADCIntClear(ADC0_BASE, 1);

       ADCComparatorConfigure(ADC0_BASE, 0, ADC_COMP_TRIG_NONE | ADC_COMP_INT_HIGH_HONCE);
       ADCComparatorRegionSet(ADC0_BASE, 0, 2048, 3000);
       ADCComparatorReset(ADC0_BASE, 0, true, true);
       ADCComparatorIntEnable(ADC0_BASE, 1);
}

void ADC0SS1IntHandler(void)
{
       // TimerDisable(TIMER5_BASE, TIMER_A);
       uint32_t s = ADCComparatorIntStatus(ADC0_BASE);
       if (s)
       {
              ADCComparatorIntClear(ADC0_BASE, 0xffff);
              Test = "Test CCOPM0";
       }
       ADCIntClear(ADC0_BASE, 1);
       uiCount++;
       ADCSequenceDataGet(ADC0_BASE, 1, pui32ADC0Value);
       CosVoltage = (pui32ADC0Value[0] * (2 * Vref / 4096)) - Vref;
       SinVoltage = (pui32ADC0Value[1] * Vref / 4096);
       // Voltage = (*pui32ADC0Value * (2 * Vref / 4096)) - Vref;
       // Voltage = Voltage / denominator;
       // Amps = ((Voltage - ACSoffset) / mVperAmp);
       // TimerEnable(TIMER5_BASE, TIMER_A);
}

  • Hi,

      I think you are hitting the ADC#03 errata. Can you please use the suggested workaround by adding a dummy sequence step? 

  • thanks.
    in this form it worked.

           ADCSequenceStepConfigure(ADC0_BASE10ADC_CTL_CH0 | ADC_CTL_D);
           ADCSequenceStepConfigure(ADC0_BASE11ADC_CTL_CH4);
           ADCSequenceStepConfigure(ADC0_BASE12ADC_CTL_CH5 | ADC_CTL_CMP0);
           ADCSequenceStepConfigure(ADC0_BASE13ADC_CTL_CH4 | ADC_CTL_IE | ADC_CTL_END);