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

app_timer not constant

Hello, I'm using BLE, RTC and app_timer to blink a led. I blink the led 10 times when I receive an order from BT (by means of NUS), and then by means of RTC.

uint32_t initBlink()
{
	app_timer_create(&m_seq_timer_id,APP_TIMER_MODE_SINGLE_SHOT,timer_seq_event_handler);
	nrf_gpio_cfg_output(25);
	return 1;
}

void timer_seq_event_handler( void* p_context)
{
	nrf_gpio_pin_toggle(25);
	ctrSeqTime ++;
	if(ctrSeqTime >= 10)
	    ctrSeqTime = 0;
    else
	   app_timer_start(m_seq_timer_id, TIMER_VAL_MS, NULL);  
}

void doBlink()
{
    app_timer_start(m_seq_timer_id, TIMER_VAL_MS, NULL);
    ctrSeqTime = 0;
}

void rtc_config(void)
{
	 app_timer_create(&m_alert_timer_id, APP_TIMER_MODE_REPEATED, alert_timer_handler);
	 app_timer_start(m_alert_timer_id,4096,NULL);
     ctrWait=0;
}

static void alert_timer_handler(void * p_context)
{
    ctrWait++;
    if(ctrWait  > 50)
    doBlink();
}

When doBlink is called from BT, the blink is faster than when it is called by alert_timer. I guess it has something to do with the low power, and the processor going faster when receiving BT frames thant when in low power RTC, but I want that the speed be equal in both cases.

Related