XMC4200 ADC App Conversion time

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Yalcin_Haksoz
Level 2
Level 2
First like received 10 replies posted 10 questions asked
As part of my learning I am trying to measure ADC conversion time of XMC4200.
I used the same SysTick code to measure and got considerably longer time if DAVE app is used for the ADC compared to directly accessing to the ADC registers.
The codes I used for both cases are below along with the SysTick setup. I measured 137 SysTick cycles with APP version and 15 SysTick cycles with direct access.

Here are my questions:
1. The time with the app is about 9 times longer. Is this normal or am I doing a silly mistake? If this is true, this makes DAVE ADC app almost useless for some applications.
2. I assume the number I get from the SysTick as "delta" is the number of clock cycles, each 12.5ns at 80MHz. Could anyone confirm this please?
3. With ADC app I measured the same, 137 cycles regardless of 8, 10 or 12 bit conversion. Wouldn't we expect some conversion time difference depending on the conversion resolution?

Any help would be greatly appreciated.
Thank you in advance.
YH


//==============================
//Code for the ADC app:
int main(void)
{
DAVE_Init();

t1 = systick_start(); //This parts calculates the time required for start stop
t2 = systick_stop();
calibTime = t1 - t2; //Time required for SysTick start/stop. Measured 42. This is subtracted from the actual measurement later.

while(1U)
{
t1 = systick_start(); //Measurement starts here.

ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0 );
result = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_Channel _A);

t2 = systick_stop(); //Measurement stops here.

delta = t1 - t2 - calibTime; //This is the total conversion time. 137 clock cycles measured.
}
}
//==============================



//==============================
//Code for direct access to registers:
int main(void)
{
DAVE_Init();

t1 = systick_start(); //This parts calculates the time required for SysTick start stop
t2 = systick_stop();
calibTime = t1 - t2; //Time required for SysTick start/stop. Measured 42. This is subtracted from the actual measurement later.

while(1U)
{
t1 = systick_start(); //Measurement starts here.

VADC->BRSMR |= (uint32_t)VADC_BRSMR_LDEV_Msk;
result = VADC_G0->RES[15];

t2 = systick_stop(); //Measurement stops here.

delta = t1 - t2 - calibTime; //This is the total conversion time. 15 clock cycles measured.
}
}
//==============================


//==============================
SysTick initialization code. Same for both measurements.

__STATIC_INLINE uint32_t systick_start(void)
{
SysTick->LOAD = SysTick_LOAD_RELOAD_Msk - 1;
SysTick->VAL = 0;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
__NOP();
return((uint32_t)SysTick->VAL);
}

__STATIC_INLINE uint32_t systick_stop(void)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
return((uint32_t)SysTick->VAL);
}
//==============================
0 Likes
0 Replies