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?
解決済! 解決策の投稿を見る。
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
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