| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

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

You can find the source code and the project file of the example in the following folder: `<InstallFolder>\examples\peripheral\ram_retention`

Button assignments:

- Button 1: 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. Perform "pin reset" e.g. by pressing RESET button
3. When the board is turned on or reset, LED1 is turned on for a second, and then all LEDs are turned off.
4. Press button 1 to wake up system.
5. The test will run the number of times defined by MAX_TEST_ITERATIONS.
6. If all tests are successful, LED2 is turned on. If a test fails, all LEDs are turned on.