nRF51 SDK
|
Modules | |
main.c | |
Power profiling sample application main file. | |
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.
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.
Instruction on how to set up the nRF51822 Development Kit hardware: nRFgo Motherboard Setup (nRF6310).
LED assignments:
Buttons assignments: