This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

S140 initialisation errors on nRF52840 if RTC2 interrupt enabled

I'm testing a custom application with the following configuration:

  • Custom app based on the ble_app_pwr_profiling SDK example.
  • Using SDK 13.1
  • S140 SoftDevice s140_nrf52840_5.0.0-2.alpha_softdevice.hex
  • PCA10056 development board, nRF52840

I've modified the example to configure RTC2 capture compare registers to generate PPI events to control GPIO and TWI events by using the nrf_drv_rtc_xxx functions from the driver library.

If interrupts are enabled on RTC2 (as they will be by default if using nrf_drv_rct_init function) then the expanded SOFTDEVICE_HANDLER_INIT macro call fails with error code 4097 (NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION).

If I configure RTC2 using driver functions but add a call to nrf_drv_common_irq_disable(rtc2.irq) after initialisation then the SoftDevice starts as expected.

Why does the S140 SoftDevice fail to start if RTC2 interrupts are enabled?

Is the RTC2 peripheral used by the S140 SoftDevice?

  • This behaviour is a result of not correctly initialising the RTC2 interrupt priority. The S140 SoftDevice does not have a dependency on RTC2.

    For the nRF52 S140 SoftDevice, interrupt priorities 0, 1, 4 and 5 are reserved for use by the SoftDevice. The SoftDevice expects that no other peripheral uses these reserved interrupt priorities and validates this on startup, even for peripherals which it doesn't use such as RTC2. If there are any enabled interrupts with a reserved priority configured, the NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION error will be returned.

    Assuming the correct values have been set in sdk_config.h, the following snippet will correctly initialise an RTC component.

    nrf_drv_rtc_config_t rtc_config = NRF_DRV_RTC_DEFAULT_CONFIG;
    err_code = nrf_drv_rtc_init(&rtc, &rtc_config, rtc_handler);
    
Related