Hi,
I'm trying to enable a HW timer (TIMER1) in my BLE application. I'm using SDK 16, and following the pattern shown in examples/peripherals/timer. However, when I get to nrf_drv_timer_enable(), I get a system reset before exiting this function. Here is the relevant parts of my code -
const nrf_drv_timer_t SYSTEM_HW_TIMER = NRF_DRV_TIMER_INSTANCE(1);
static void _system_hw_timer_callback(nrf_timer_event_t event_type, void* p_context)
{
switch (event_type)
{
case NRF_TIMER_EVENT_COMPARE0:
...
break;
default:
break;
}
}
static void system_timer_tick_init(void)
{
...
nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
uint32_t err_code = nrf_drv_timer_init(&SYSTEM_HW_TIMER,
&timer_cfg,
_system_hw_timer_callback);
APP_ERROR_CHECK(err_code);
uint32_t time_ticks = nrf_drv_timer_ms_to_ticks(&SYSTEM_HW_TIMER,
SYSTEM_TIMER_TICK_TIME_MS);
nrf_drv_timer_extended_compare(&SYSTEM_HW_TIMER,
NRF_TIMER_CC_CHANNEL0,
time_ticks,
NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
true);
nrf_drv_timer_enable(&SYSTEM_HW_TIMER); // This function never completes!!!
}
int main(void)
{
...
// Initialize BLE
...
system_timer_tick_init();
...
}#ifndef NRFX_TIMER_ENABLED #define NRFX_TIMER_ENABLED 1 #endif // <q> NRFX_TIMER0_ENABLED - Enable TIMER0 instance #ifndef NRFX_TIMER0_ENABLED #define NRFX_TIMER0_ENABLED 1 #endif // <q> NRFX_TIMER1_ENABLED - Enable TIMER1 instance #ifndef NRFX_TIMER1_ENABLED #define NRFX_TIMER1_ENABLED 1 #endif