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

In S110 SoftDevice, NRF_POWER->SYSTEMOFF is written. Why?

Hello.

I'm now writing a software based on nrf51_sdk_v6_1_0/nrf51822/Board/nrf6310/s110/ble_app_hrs. The SoftDevice I'm using is s110_nrf51822_7.1.0_softdevice.hex. Why I use the version is that the target device is IC revision 2. Exactly speaking, it is nRF51822 QFAAG20 (0x0057).

When I run the code, it is working for a while (just advertising without connection). However after a few minutes later, the software crashes by HardFault. When I checked the stack area, I noticed that the RAM Block 0 and 1 looked all filled with zero. I suspected that NRF_POWER->RAMON had a wrong value but it was 0x00000003. It looked fine. However, I also noticed that the memory area would be preserved when I reset the target. Finally I noticed that writing 1 to NRF_POWER->SYSTEMOFF caused a similar phenomenon.

So I had a watchpoint on the NRF_POWER->SYSTEMOFF (0x40000500) and reran the code. By the watchpoint, I found that a code in the SoftDevice was writing 1 to the SYSTEMOFF register. It is the following code.

0x00011328: ldr r1, [pc, #424]  ; 0x114d4
0x0001132a: movs r0, #1
0x0001132c: str r0, [r1, #0]

I also confirmed that the code was called in the IRQ #11 context (RTC0_IRQ).

I guess that there is an intention that SoftDevice triggers the SYSTEMOFF, but I don't imagine the reason.

FYI, I suspected that heap or stack area was flooded but it looked okay.

Could you please let me know when and why SoftDevice triggers the SYSTEMOFF? (Do we still have a way to access RAM even though SYSTEMOFF == 1?)

Best Regards,

Atsushi

Parents
  • The SYSTEMOFF will be triggered at that point in the SoftDevice if you call sd_power_system_off(). This happens at line 709 in the app you are using, in the on_ble_evt handler:

    case BLE_GAP_EVT_TIMEOUT:
            if (p_ble_evt->evt.gap_evt.params.timeout.src == BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT)
            {
                nrf_gpio_pin_clear(ADVERTISING_LED_PIN_NO);
    
                // Go to system-off mode (this function will not return; wakeup will cause a reset).
                err_code = sd_power_system_off();
                APP_ERROR_CHECK(err_code);
            }
            break;
    

    Is this what you are seeing? The purpose for this example is to enable advertisements for some time after startup, then shut down and wait for a keypress if no connection is established within the time limits.

  • I could resolve the problem. Thanks, Ulrich! I found the following sections in the "nRF51 Series Reference Manual Version 3.0." In the section "14.1 Functional description", we see

    • When the correct level is detected on any such configured pin, the sense mechanism will set the DETECT signal high.
    • POWER: uses the DETECT signal to exit from System OFF

    and in the section "12.1.5 System OFF mode", we see

    • The system can be woken up from System OFF mode either from the DETECT signal (when active) generated by the GPIO peripheral

    I understood the specification. Thanks and Regards, Atsushi

Reply
  • I could resolve the problem. Thanks, Ulrich! I found the following sections in the "nRF51 Series Reference Manual Version 3.0." In the section "14.1 Functional description", we see

    • When the correct level is detected on any such configured pin, the sense mechanism will set the DETECT signal high.
    • POWER: uses the DETECT signal to exit from System OFF

    and in the section "12.1.5 System OFF mode", we see

    • The system can be woken up from System OFF mode either from the DETECT signal (when active) generated by the GPIO peripheral

    I understood the specification. Thanks and Regards, Atsushi

Children
No Data
Related