Hello,
I'm working in a bootloader based on the one included with SDK15. I want to add a timer that fires every 50 ms to keep track of time. The purpose of this timer is to generate unblocking delays for some tasks that have to do with interfacing another bootloader in a STM32. However, when I add this timer, the bootloader keeps working but the other timers don't work anymore.
I have added another timer to blink an LED while a DFU is in process.
This is the code I added to nrf_bootloader_dfu_timers.c.
Initialization of timers:
/**@brief Initialization of app_timer. Function ensures that initialization happens only once. */ static void timer_init(void) { if (!m_app_timer_initialized) { if (!nrf_clock_lf_is_running()) { nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART); // Wait for the clock to be ready. while (!nrf_clock_lf_is_running()) {;} } uint32_t err_code = app_timer_init(); APP_ERROR_CHECK(err_code); // Start a single shot timer that will reset the DFU on timeout. err_code = app_timer_create(&m_dfu_inactivity_timer, APP_TIMER_MODE_SINGLE_SHOT, timeout_handler); ASSERT(err_code == NRF_SUCCESS); err_code = app_timer_create(&m_wdt_feed_timer, APP_TIMER_MODE_REPEATED, timeout_handler); ASSERT(err_code == NRF_SUCCESS); err_code = app_timer_create(&m_led_blink_timer, APP_TIMER_MODE_REPEATED, timeout_handler); ASSERT(err_code == NRF_SUCCESS); err_code = app_timer_create(&m_boot_clock_timer, APP_TIMER_MODE_REPEATED, timeout_handler); ASSERT(err_code == NRF_SUCCESS); m_app_timer_initialized = true; } }
Timer start:
void nrf_bootloader_dfu_inactivity_timer_restart(uint32_t timeout_ms, nrf_bootloader_dfu_timeout_callback_t callback) { timer_start(m_dfu_inactivity_timer, timeout_ms, callback); } void nrf_bootloader_wdt_feed_timer_start(uint32_t timeout_ms, nrf_bootloader_dfu_timeout_callback_t callback) { timer_start(m_wdt_feed_timer, timeout_ms, callback); } void nrf_bootloader_led_blink_timer_start(uint32_t timeout_ms, nrf_bootloader_dfu_timeout_callback_t callback) { timer_start(m_led_blink_timer, timeout_ms, callback); } void nrf_bootloader_boot_clock_timer_start(uint32_t timeout_ms, nrf_bootloader_dfu_timeout_callback_t callback) { timer_start(m_boot_clock_timer, timeout_ms, callback); }
I have noticed that the whole thing works depending on the firing frequency of the timers. Maybe it has something to do with the timer FIFO getting full? I don't get any errors, the bootloader still advertises and performs DFUs normally. It's just the timers that aren't working.
For example this doesn't work when the timeout of the LED blink timer is 800 ms and the clock timer is 50 ms. It does however work with 800 ms and 200 ms. If I want to blink the LED faster it also doesn't work (i.e. 200 ms and 200 ms). Where could this be failing?
Thanks for your help!