nRF51 SDK - S120 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
RAM Retention Example

The RAM Retention Example shows RAM retention mode usage and verification. It configures the system for RAM retention and then triggers System OFF. Button 1 wakes up the system. The application then checks if the RAM state is conserved by verifying that the value written before going to System OFF is the same.

Note
This example runs in a loop MAX_TEST_ITERATIONS number of times. The loop is generated by a system reset, which is generated after wakeup from System OFF mode. This does not work in the evaluation mode of Keil MDK, because scatter files only work in the fully licensed version. Scatter files are needed for telling the ARM linker whether or not to initialize RAM at System RESET. This example is specifically designed to run without linker scripts. The RAM_MEMORY_TEST_ADDRESS is not used by any variable. Therefore, no linker will try to initialize it at startup.
                             --------------
                            |    RESET     |
                             --------------
                                   |
                             ---------------
                            |   Configure   |
                            |      BSP      |
                             ---------------
                                   |
                         READ GPREGRET Register
                                   |
                         ---------------------
                 NO  <--|  SYSTEM_OFF_RESET?  |--> YES
                 |       ---------------------      |
                 |                                  |
       -------------------------           ---------------------
      |   Write to GPREGRET     |         |   Read loop count/  |
      | test word +  loop_count |<-    ---|   MAX reached?      |--->NO
       -------------------------   |   |   ---------------------     |
                 |                 |   |                 ------------------------               ----------------
       ------------------------    |  YES               |  Verify RAM retention? |-->FAILURE-->|  Loop forever  |
      |  Enable RAM RETENTION  |   |   |                 ------------------------               ----------------
       ------------------------    | STOP                           |                                   ^
                 |                 |                             SUCCESS                                |
       ------------------------    |          -------------         |                                   |
      | WRITE_TEST_BYTE_TO_RAM |    --True---| ++Loop < 6? |<--------                                   |
       ------------------------               -------------                                             |
                 |                                 |                                                    |
        --------------------                     False                                                  |
       | Trigger System OFF |                      |                                                    |
        --------------------                        ----------------------------------------------------

Setup

The name of the example is ram_retention_pca10028. If you are not using the Keil Pack Installer, you can find the source code and project file of the example in the following folder: <InstallFolder>\Nordic\nrf51\examples\peripheral\ram_retention

Button assignments:

  • Buttons are used to wake up the system from System OFF mode.

Testing

Test the RAM Retention Example application by performing the following steps:

  1. Compile and program the application.
  2. When the board is turned on or reset, LED1 is turned on for a second, and then all LEDs are turned off.
  3. By pressing any button, the system wakes up.
  4. The test will run the number of times defined by MAX_TEST_ITERATIONS.
  5. If all tests are successful, LED2 is turned on. If a test fails, all LEDs are turned on.