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

Errors writing RESETREAS after softdevice is enabled

I get an app error SOFTDEVICE: INVALID MEMORY ACCES if I try to write/clear RESETREAS after the softdevice has been enabled.

Why is this happening?

You can reproduce it by using

  • nRF52840-Preview-DK board
  • ble_app_att_mtu_throughput_pca10056_s140 example program from SDK 14.2.0
  • SES version 3.30 

In main() I put these 3 lines of code before the call to ble_stack_init().  They read RESETREAS, clear it and read it again.  That works.  See screencap1.png

   uint32_t rr_before = NRF_POWER->RESETREAS;

   NRF_POWER->RESETREAS = 0xFFFFFFFF;

   uint32_t rr_after = NRF_POWER->RESETREAS;

If I move the 3 lines of code AFTER the call to ble_stack_init() then I get an app error.

  • screencap2.png shows the source code and halting on the app error
  • screencap3.png shows that app_error_fault_handler() has been called
  • screencap4.png shows the console with the SOFTDEVICE: INVALID MEMORY ACCES error

Tracing into ble_stack_init() and using the same 3 lines of code I was able to tell that the specific call that causes the app error is ble_stack_init() -> nrf_sdh_enable_request() -> sd_softdevice_enable().  So if I put the 3 lines of code before sd_softdevice_enable() then they work, if I put them after then I get the app error.

screencap4.png

screencap3.png

screencap1.png

screencap2.png

Related