ADC_ETC results register not immediately ready in Done interrupt?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

ADC_ETC results register not immediately ready in Done interrupt?

跳至解决方案
929 次查看
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?

标记 (1)
1 解答
775 次查看
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

在原帖中查看解决方案

1 回复
776 次查看
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