nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Power Profiling Application

Modules

 main.c
 Power profiling sample application main file.
 

Detailed Description

This application is designed to be used to measure the current consumption of the nRF51822, loaded with S110 SoftDevice, during advertisement and data transmission. The user can change some of the parameters (listed below) of this application, and measure current consumption.

This application also demonstrates the use of Vendor Specific (128 bit) UUIDs.

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

This application has two modes of working.

1. Connectable mode:

In this mode, the application advertises in connectable mode. It sets itself up with a service and a characteristic with 'Notify' property. This characteristic has a CCCD associated with it.

Once the master enables notification of this characteristic (writes 0x0001 to this CCCD), the application starts sending notifications of this characteristic for a time interval equal to the value of APP_CFG_CHAR_NOTIF_TIMEOUT. The application will attempt to send one notification per connection interval, but this is not guaranteed. There is a possibility that in one connection interval there are no notifications but in the next one there are two notifications. This depends on when exactly the repeating application timer expires. But the total number of notifications sent by the application will be close to (APP_CFG_CHAR_NOTIF_TIMEOUT / (APP_CFG_CONNECTION_INTERVAL)). After sending these notifications, the application puts the chip in 'System Off' mode.

2. Non-connectable mode:

In this mode, the application advertises the given length of data (APP_CFG_ADV_DATA_LEN) for a given duration of time (APP_CFG_NON_CONN_ADV_TIMEOUT) in non-connectable mode, and then puts the chip in System Off mode.

Note
In both the above modes, the device name does not show up in the advertisement packet as per design. The advertisement packet only has 'Flags' and 'Manufacturer specific data' fields. This is done to make the least possible size of an advertisement packet as 8 bytes.

Power Management

The application demonstrates the use of two different power saving modes, namely CPU Sleep and System-Off mode. All sample applications delivered with the SDK use these two modes.

Low Power Mode:

The application uses the nrf_wait_for_app_event() function to enter CPU sleep mode. This will place the chip in 'Low Power' mode. The chip will wake up from this mode on application interrupts. Typically any application should call nrf_wait_for_app_event() in an infinite loop in main. It will return when an application interrupt has occurred, thereby allowing the main thread to process it if needed.

System OFF Mode:

This is the deepest power saving mode the system can enter. In this mode all core functionality is powered down, and most peripherals are therefore non-functional or non-responsive. The only mechanisms that are functional and responsive in this mode are the reset mechanism and the wake-up mechanism. This sample application starts up, configures wakeup buttons and enters this mode. On button presses, the application wakes up and goes into either 'Connectable mode' or 'Non-connectable mode' based on which button is pressed.

For more information on both of the above modes, see nrf_wait_for_app_event() and the nRF51 Series User Specification (Section: POWER - Power control).

Compiler Optimization:

This example is optimized for reduced power consumption. Therefore the default optimization level for this example application is 'Level 3', (-O3) and 'Optimize for Time', (-Otime). If the Keil debugger is needed for debugging purposes, then the optimization level should be changed to 'Level 0', (-O0) and 'Optimize for Time' should be removed in order to ease the use of the debugger.

Setup

Instruction on how to set up the nRF51822 Development Kit hardware: nRFgo Motherboard Setup (nRF6310).

LED assignments:

Buttons assignments:

Testing

  1. Compile and program the application.
  2. Start Master Control Panel on the PC.
  3. Click 'File->Options'. Verify that the connection interval value displayed in the 'Options' window is the same as APP_CFG_CONNECTION_INTERVAL.
  4. Close the Options window and click 'Start discovery' Master Control Panel main window.
  5. Push Button 0 on the nRFgo board. Observe the application is advertising in connectable mode.
  6. Connect to the device from Master Control Panel, click 'Service discovery' and then click 'Enable Services'.
  7. Observe notifications of the characteristic being received by the master.
  8. After APP_CFG_CHAR_NOTIF_TIMEOUT the Master control panel will lose connection with the chip because it would have entered System Off mode.
  9. Verify the size of the characteristic value received in all the notifications was equal to APP_CFG_CHAR_LEN.
  10. Click 'Back' button in the Master control panel, right click in the 'Discovered Devices' section in Master Control Panel and click 'Clear list' to clear the list of devices.
  11. Verify that the device is not advertising.
  12. Push Button 1 on the nRFgo board. Observe the application is advertising in non-connectable mode (the Adv. type field should be Non-Connectable)
  13. Verify that the number of bytes in the Manufacturer Specific Data in Adv. data is APP_CFG_ADV_DATA_LEN - 5
  14. After APP_CFG_NON_CONN_ADV_TIMEOUT, clear the list of 'Discovered Devices'. Verify that the device is not advertising.