This is a monitor program for BLE NRF51822 chip. You can check memory, register and system information.

Dependencies:   BLE_API mbed nRF51822 nRF51_Vdd

Please refer follows.
/users/kenjiArai/code/debug_tools/
/users/kenjiArai/notebook/ble--tytaiyo-yuden-module-for-mbed/

Revision:
4:36ad7c7d0400
Child:
5:8c37a47ac34c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debug_tools/debugging_nRF51.h	Sun Feb 14 21:55:30 2016 +0000
@@ -0,0 +1,159 @@
+/*
+ * mbed Application program
+ *
+ *  Copyright (c) 2016 Kenji Arai / JH1PJL
+ *  http://www.page.sannet.ne.jp/kenjia/index.html
+ *  http://mbed.org/users/kenjiArai/
+ *      Created:  Feburary   1st, 2016
+ *      Revised:  Feburary  15th, 2016
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+ * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+    //---------------------------------------------------------------------------------
+    //  Something new and try new functions
+    //---------------------------------------------------------------------------------
+#define NRF_RTC2_BASE                   0x40024000UL
+#define NRF_RTC2                        ((NRF_RTC_Type            *) NRF_RTC2_BASE)
+    
+case '1' :
+    step_by_step('1');
+    sd_power_system_off();
+    step_by_step('2');
+    NRF_RTC2->PRESCALER = 0; /* for no pre-scaling. */
+    NRF_RTC2->TASKS_START = 1;
+    n = NRF_RTC2->COUNTER;
+    wait(0.1);
+    if ( n == NRF_RTC2->COUNTER){
+        PRINTF("RTC2 is not running\r\n");
+    } else {
+        PRINTF("RTC2 is running & counter = %d\r\n", n);
+    }
+                step_by_step('3');
+    n = NRF_RTC2->COUNTER;
+    wait(0.1);
+    if ( n == NRF_RTC2->COUNTER){
+        PRINTF("RTC2 is not running\r\n");
+    } else {
+        PRINTF("RTC2 is running & counter = %d\r\n", n);
+    }
+                step_by_step('4');
+    n = NRF_RTC0->COUNTER;
+    wait(0.1);
+    if ( n == NRF_RTC0->COUNTER){
+        PRINTF("RTC0 is not running\r\n");
+    } else {
+        PRINTF("RTC0 is running & counter = %d\r\n", n);
+    }
+    n = NRF_RTC1->COUNTER;
+    wait(0.1);
+    if ( n == NRF_RTC1->COUNTER){
+        PRINTF("RTC1 is not running\r\n");
+        NRF_RTC1->PRESCALER = 0; /* for no pre-scaling. */
+        NRF_RTC1->TASKS_START = 1;
+        wait(0.5);
+        n = NRF_RTC1->COUNTER;
+        wait(0.1);
+        if ( n == NRF_RTC1->COUNTER){
+            PRINTF("RTC1 is not running\r\n");
+        } else {
+            PRINTF("RTC1 is running & counter = %d\r\n", n);
+        }
+    } else {
+        PRINTF("RTC1 is running & counter = %d\r\n", n);
+    }                
+    step_by_step('2');                
+    NRF_POWER->SYSTEMOFF = 1;         
+    #if 0
+    NRF_CLOCK->TASKS_HFCLKSTOP = 0xffffffff;
+    NRF_CLOCK->TASKS_LFCLKSTOP = 0xffffffff;
+    step_by_step('1');
+    sd_power_system_off();
+    //*(uint32_t *)0x40004ffc = 0;
+    //shutdown();
+    //softdevice_handler_sd_disable();
+    PRINTF("POWER=0x%x",NRF_RADIO->POWER);
+    put_rn();
+    if (NRF_RADIO->POWER){
+        PRINTF("Radio power is still enabled");
+    } else {
+        PRINTF("Radio power is disabled");
+    }
+    put_rn();
+    step_by_step('2');
+    NRF_CLOCK->TASKS_HFCLKSTOP = 1;
+    step_by_step('1');
+    NRF_RADIO->POWER = 0;
+    //NRF_POWER->SYSTEMOFF = 1;
+    //sd_power_system_off();
+    NRF_SPI0->POWER =0;
+    NRF_SPI1->POWER =0;
+    NRF_TWI0->POWER =0;
+    NRF_TWI1->POWER =0;
+    step_by_step('4');
+    NRF_GPIO->DIR = 0xffff; // all ports set output mode
+    NRF_GPIO->OUTCLR = 0;   // all ports are low level
+    //step_by_step('x');
+    //NRF_UART0->ENABLE = 0;  // Disable UART
+    step_by_step('2');
+    NRF_SPI0->ENABLE =0;
+    NRF_SPI1->ENABLE =0;
+    NRF_TWI0->ENABLE =0;
+    NRF_TWI1->ENABLE =0;
+    step_by_step('3');
+    NRF_POWER->RAMON = 0;
+    NRF_POWER->RAMONB = 0;
+    step_by_step('5');
+    sd_power_system_off();
+    //step_by_step('6');
+    NRF_POWER->SYSTEMOFF = 1;
+    NRF_POWER->INTENCLR = 0;
+    #endif
+    while(true){
+       sleep();
+    }
+    //break;
+case '2' :
+    step_by_step('a');              
+    // Internal 32kHz RC
+    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos;           
+    // Start the 32 kHz clock, and wait for the start up to complete
+    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
+    NRF_CLOCK->TASKS_LFCLKSTART = 1;
+    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
+    // Configure the RTC to run at 2 second intervals, and make sure COMPARE0 generates an interrupt (this will be the wakeup source)
+    NRF_RTC1->PRESCALER = 3277;
+    NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
+    NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk;
+    NRF_RTC1->CC[0] = 2*10;
+    NRF_RTC1->TASKS_START = 1;
+    //NVIC_EnableIRQ(RTC1_IRQn);
+    // Configure the RAM retention parameters
+    NRF_POWER->RAMON = POWER_RAMON_ONRAM0_RAM0On   << POWER_RAMON_ONRAM0_Pos
+                     | POWER_RAMON_ONRAM1_RAM1Off  << POWER_RAMON_ONRAM1_Pos
+                     | POWER_RAMON_OFFRAM0_RAM0Off << POWER_RAMON_OFFRAM0_Pos
+                     | POWER_RAMON_OFFRAM1_RAM1Off << POWER_RAMON_OFFRAM1_Pos;
+    while(1) {
+        __WFI();
+        //NRF_RTC1->TASKS_STOP = 1;
+    }
+    //break;
+    #if 0
+case '3' :
+    step_by_step('x');
+    p_out = 1;
+    step_by_step('y');
+    p_out = 0;
+    step_by_step('z');
+    for (uint8_t n =100; n > 0; n--){
+        p_out = 1;
+        wait(0.1);
+        p_out = 0;
+        wait(0.1);
+    }
+    break;
+    #endif