This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

accuracy of application timer with schedular on nRF52

I use the application timer with a schedular on the nRF52 with SoftDevice S132 1.0.0.3 alpha and SDK v0.9.2.

The application timer is running in repeated mode and should have a timeout of 1 ms.

Defines:

#define APP_TIMER_PRESCALER             0                            
#define APP_TIMER_MAX_TIMERS            (3 + BSP_APP_TIMERS_NUMBER)  
#define APP_TIMER_OP_QUEUE_SIZE         4    

Initialize of the timer:

// Initialize timer module, making it use the scheduler
APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, true);

err_code = app_timer_create(&m_data_timer_id, APP_TIMER_MODE_REPEATED, timer_data_timeout_handler);
APP_ERROR_CHECK(err_code);

The timer is started with this code:

err_code = app_timer_start(m_data_timer_id, APP_TIMER_TICKS(1, APP_TIMER_PRESCALER), NULL);
APP_ERROR_CHECK(err_code);

Every time the timout handler is called a GPIO PIN is toggeled..

// Timeout handler for the repeated timer
static void timer_data_timeout_handler(void * p_context)
{
	nrf_drv_gpiote_out_set(PIN_OUT);
	nrf_drv_gpiote_out_clear(PIN_OUT);
	ms_counter++;
	
}

When I measure the time between the peaks with a osciloscope the time between each peak is between 1 ms and 6 ms and not as expacted always 1 ms.

Have you any idea which causes that timeout handler is not called excatly every millisecond?

Parents Reply Children
No Data
Related