Hard fault on the timer interrupt with Softdevice project included

I am using nRF SDK 16,0 and ble_app_template for pca10040 with Softdevice 132.

The example works fine, on my DK board but I need to utilize timers for my application.

Since TIMER0 is reserved for SoftDevice, I tried to initialize TIMER1,2,3 or 4 using the following implementation:

static nrf_drv_timer_t timer = \
{ \
    .p_reg = NRFX_CONCAT_2(NRF_TIMER, 1), \
    .instance_id = 1, \
    .cc_channel_count = NRF_TIMER_CC_CHANNEL_COUNT(1), \

static void ims_us_timer_init(void)
    ret_code_t err_code;
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    err_code = nrf_drv_timer_init(&us_timer, &timer_cfg, timer_handler);

    nrf_drv_timer_compare(&us_timer, (nrf_timer_cc_channel_t)0,
    200 * 1000UL, true);

However, if this code sticks to HardFault handler after enabling the timer. It doesn't crash only if, in nrf_drv_timer_compare function, the last parameter is set to false (disabled interrupt).

In any case, the callback (timer_handler) is not executed at all.

This code works well in the project that doesn't contain the SoftDevice.

Is there anything wrong I am doing or some constraints or collision between SoftDevice and Timers ?

No Data
  • Hi

    Susheel is gone for the remainder of this week, so I've been tasked to manage this case for now. As you can see in the link in the previous reply, priority levels 0, 1, and 4 are all used by the SoftDevice, so if you are using any of these priorities for your timer(s) that is bound to cause trouble. Did you set all the timers in your project to other priorities than these values or just the one?

    Best regards,