nrf_drv_timer_init NRFX_ERROR_INVALID_STATE

Hi, 

I have a weird problem. My application starts two timers, one after another. Like this:

		uint32_t err_code;

    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
		timer_cfg.frequency = NRF_TIMER_FREQ_31250Hz;
		timer_cfg.bit_width = NRF_TIMER_BIT_WIDTH_32;
		timer_cfg.mode = NRF_TIMER_MODE_TIMER;
	
    err_code = nrf_drv_timer_init(&TRIAC_TIMER, &timer_cfg, TRIAC_TIMER_event_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_timer_init(&LED_TIMER, &timer_cfg, LED_TIMER_event_handler);
    APP_ERROR_CHECK(err_code);

Normally it just works - no errors, nothing. However, after a DFU OTA upgrade (using NRF Tools), the application raises the NRFX_ERROR_INVALID_STATE error in the second nrf_drv_timer_init call. Theoretically it should be no problem, it's just already initialized, but when I just comment out the APP_ERROR_CHECK, the timer doesn't work. I use it for handling led blinking and the leds just don't blink. 

The weird part is - when I power down my device and power it back up, it works. The NRFX_ERROR_INVALID_STATE error is gone. Everthign is fine. 

I have no idea as why this would happen. Can you please help me understand?

PS: I ues the buttonless DFU bootloader. Maybe there is some sort of conflict, just after the ROM update. I just want my app to be up and running after the update. I don't want to power cycle it :/

Please advise.

Related