A very simple function which reads conversion result of ADC is called in the highest priority ISR every 20us.The function is showed below:
void get_motor_curr(int16_t *motor_curr)
{
uint16_t result = 0;
result = ADC_ETC_GetADCConversionValue(ADC_ETC_PERIPHERAL,ADC_ETC_TC_0_TG,0);
result &= 0x0FFF;
motor_curr[0] = (int16_t)(result * 4.3 + 0.5) >> 1;
}
Set one gpio high before calling above function and clear the gpio after return from it,then measure the time elapsed using oscilloscope.

Picture above shows that the consumed time varies a lot,indeed,it can vary from 0.3us to more than 1us.
The function just reads conversion result of ADC,it won't wait for anything,also it is called in the highest priority ISR.I can't image any situation that CPU will consume little or more time than another .
The ISR runs from extern SDRAM,and SEMC works at 132MHz.CPU clock is 528MHz.MCU is MIMXRT1052.
This problem really bother me a lot.If anyone has any idea about this problem,please let me know.
Thanks in advance!