nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Flash Write Example

The Flash Write Example erases a page in flash and then reads a pattern from pins 0-7 (Buttons), writes it to flash if a new pattern is detected, reads it back and writes it to pins 8-15 (LEDs). Each time a new pattern is detected, the address in flash is incremented. It uses the hardware delivered in the nRF51822 Development Kit.

The application starts with setting pins 0-7 as input (Buttons) and pins 8-15 as output (LEDs). The flash start address is set to the last page in flash, and the page is erased. The main loop first reads the button pattern and writes the value to flash. After the write to flash, the same flash address is read and set to the LEDs. Note that by erasing flash, each bit is set to logic one, so by pressing a button, the corresponding LED will be turned off.

The source code and project file can be found in the <InstallFolder>\Nordic\nrf51822\Board\nrf6310\flashwrite_example folder.

Setup

Instructions on how to set up the nRFgo Motherboard: nRFgo Motherboard Setup (nRF6310).

LED assignments:

  • LED 0-7 is used to show the value read from flash.

Button assignment:

  • Button 0-7 is used to write a new value to flash.

Testing

The Flash Write Example Application can be tested as follows:

  1. Compile and program the application.
  2. Press any buttons and the corresponding LEDs should be turned off.