ADC_ETC results register not immediately ready in Done interrupt?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC_ETC results register not immediately ready in Done interrupt?

Jump to solution
885 Views
jackking
Senior Contributor I

I am testing the ADC and ADC_ETC (see my other threads).

During this testing I am seeing intermittently that the trigger result register isn't available immediately in the done interrupt.

In my test code, I am setting a variable to store the current result value in the done interrupt, but it is sometimes getting the previous value.  If I put a (1mS) delay in before setting the variable, it always gets the correct value from the result register.

Here is my example interrupt code that is not behaving as expected.

void ADC_ETC_IRQ0_IRQHandler(void)
{
     g_AdcConversionDoneFlag = true;
     g_AdcConversionValue = ADC_ETC_GetADCConversionValue(ADC_ETC, 0U, 0U); /* Get trigger0 chain0 result. */
     ADC_ETC_ClearInterruptStatusFlags(ADC_ETC, kADC_ETC_Trg0TriggerSource, kADC_ETC_Done0StatusFlagMask);
}

It seems that the result register is supposed to be updated *before* the interrupt fires?

Tags (1)
1 Solution
731 Views
jamesbone
NXP TechSupport
NXP TechSupport

In your code, you first need to read the value of the ADC Result register, and then you need to clear the flag of the ADC to get next measurement.  This means that you get into the Interrupt once the Flag gets set,  read the data and clear the flag.

Have a nice day

View solution in original post

1 Reply
732 Views
jamesbone
NXP TechSupport
NXP TechSupport

In your code, you first need to read the value of the ADC Result register, and then you need to clear the flag of the ADC to get next measurement.  This means that you get into the Interrupt once the Flag gets set,  read the data and clear the flag.

Have a nice day