Hi,
What are the options to measure the execution time of code snippets? I used app_timer_cnt_get() now and is giving 50 ticks for 1ms. Is there any way I can measure lesser time?
Hi,
What are the options to measure the execution time of code snippets? I used app_timer_cnt_get() now and is giving 50 ticks for 1ms. Is there any way I can measure lesser time?
Hi,
The Application timer use the LFCLK, try using the Timer peripheral instead. It uses the HFCLK.
Best regards
Jared
The cycle counter works really well for short measurements:
uint32_t start;
uint32_t stop;
uint32_t elapsed;
// enable DWT
CoreDebug->DEMCR |= 0x01000000;
// Reset cycle counter
DWT->CYCCNT = 0;
// enable cycle counter
DWT->CTRL |= 0x1;
start = DWT->CYCCNT;
nrf_delay_ms(1000);
stop = DWT->CYCCNT;
elapsed = stop-start;
NRF_LOG_INFO("cycles for nrf_delay_ms(1000) = %u", elapsed);
// <info> app: cycles for nrf_delay_ms(1000) = 64018002