void ADC0IntHandler(void) { //clear the adc interrupt ADCComparatorIntClear(ADC0_BASE, 0x01); //Clear interrupt to proceed to data capture IntPendClear(INT_ADC0SS3); ADCComparatorIntDisable(ADC0_BASE, 3); // read ADC IN 0 ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior ADCIntDisable (ADC0_BASE, 3); ADCSequenceUnderflowClear (ADC0_BASE, 3); ADCComparatorReset(ADC0_BASE, 0, true, true); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 3); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); //Use the 3rd Sample sequencer ADCProcessorTrigger(ADC0_BASE, 3); //Ask processor to trigger ADC while(!ADCIntStatus(ADC0_BASE, 3, false)) { } ADCIntClear(ADC0_BASE, 3); ADCSequenceDataGet(ADC0_BASE, 3, ulADC2VMOT);
// re-configure the ADC digital comparator ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_ALWAYS, 0); //Use the 3rd Sample sequencer ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH2 | ADC_CTL_END | ADC_CTL_CMP0); // Configure the comparators ADCComparatorReset(ADC0_BASE, 0, true, true); ADCComparatorIntClear(ADC0_BASE, 0x01); //Clear interrupt to proceed to data capture ADCSequenceEnable(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 3); ADCComparatorConfigure(ADC0_BASE, 0, ADC_COMP_INT_HIGH_HALWAYS); // ADC_COMP_INT_HIGH_ONCE
Tiva tm4c123ah6pm with CCS 5.5
The application is a stepping motor
I use the ADC digital comparator for test the current.
Inside the interrupt routine of the digital comparator, I change the ADC configuration to read IN0 and after I re-configure the ADC digital comparator again.
Everything works fine, but occasionally the ADC digital comparator interrupt freezes and will not trigger any more.
To return to make it all work must be turned off and on.
I checked the status of the various registers and I seem to be correct.
I think I do something wrong in the configuration register, but do not understand what.
Thanks
Stefano