I set it to 1 second here, why does it get stuck every time it reaches one second when I set the timer.
#include "bsp_timer.h"
#include "bsp_debug_log.h"
#include "nrfx_timer.h"
void bsp_timer_callback(nrf_timer_event_t event_type, void * p_context)
{
if(event_type == NRF_TIMER_EVENT_COMPARE0)
{
char * p_msg = p_context;
BSP_DEBUG_LOG("Timer finished. Context passed to the handler: >%s<\n", p_msg);
}
}
char bsp_timer_init()
{
#if defined(__ZEPHYR__)
IRQ_CONNECT(NRFX_IRQ_NUMBER_GET(NRF_TIMER_INST_GET(10)), IRQ_PRIO_LOWEST,
NRFX_TIMER_INST_HANDLER_GET(10), 0, 0);
#endif
const nrfx_timer_t timer_instance = NRFX_TIMER_INSTANCE(10);
nrfx_timer_config_t timer_config = NRFX_TIMER_DEFAULT_CONFIG(1000000);
timer_config.bit_width = NRF_TIMER_BIT_WIDTH_16;
timer_config.p_context = "Some context";
nrfx_err_t err;
err = nrfx_timer_init(&timer_instance, &timer_config, bsp_timer_callback);
BSP_ASSERT_LOG_RET(err, "bsp_timer_init");
uint32_t desired_ticks = nrfx_timer_ms_to_ticks(&timer_instance, 1000);
// NRFX_LOG_INFO("Time to wait: %lu ms", 1000);
nrfx_timer_extended_compare(&timer_instance, NRF_TIMER_CC_CHANNEL0, desired_ticks,
NRF_TIMER_SHORT_COMPARE0_STOP_MASK, true);
nrfx_timer_clear(&timer_instance);
nrfx_timer_enable(&timer_instance);
return BSP_ERROR_CODE;
}