I am using a power profiler to measure the timing of my program and I found something wrong. So I tested with a simple pure timer.
So first I set the timer during to 300ms
#define half_epoch_during APP_TIMER_TICKS(300)
err_code = app_timer_create(&half_epoch_timer, APP_TIMER_MODE_SINGLE_SHOT, half_epoch_timer_handler);
err_code=app_timer_start(half_epoch_timer,half_epoch_during,NULL);
And I did nothing in the callback function
static void half_epoch_timer_handler (void * p_context)
{}
The timing is all right. I measure a periodic change in current every 300ms. Then I add a for loop to simulate calculations in the callback function.
static void half_epoch_timer_handler (void * p_context)
{
int d;
for (int i =0; i<3000000; i++)
{
d = i;
}
}
And now, the timing is wrong. I can measure a current change every 240ms. So my question is why would calculation make the timer shorter?
ps: My board is nRF52840 PDK.