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

Parents
  • Hi,

    My apologies for the terribly late response. I don't know what happened. Your case must have fallen through the cracks when we moved to our new support portal. 

    I think I know what your problem is. The POWER peripheral in the nRF5 devices has restricted access when the softdevice is enabled. Hence, your code works if you place the code lines before ble_stack_init(), but not if you place them after. You can check this list to see what peripherals are free to use, restricted, or blocked by the softdevice: Hardware peripherals.

    In many cases the Softdevice has its own API that you can use to access restricted peripherals even when the softdevice is enabled: S132 SoftDevice v5.0.0: Functions.

    Best regards

    Martin

Reply
  • Hi,

    My apologies for the terribly late response. I don't know what happened. Your case must have fallen through the cracks when we moved to our new support portal. 

    I think I know what your problem is. The POWER peripheral in the nRF5 devices has restricted access when the softdevice is enabled. Hence, your code works if you place the code lines before ble_stack_init(), but not if you place them after. You can check this list to see what peripherals are free to use, restricted, or blocked by the softdevice: Hardware peripherals.

    In many cases the Softdevice has its own API that you can use to access restricted peripherals even when the softdevice is enabled: S132 SoftDevice v5.0.0: Functions.

    Best regards

    Martin

Children
No Data
Related