This article demonstrates the use of sleep modes EM3 and EM4 in a Bluetooth Beacon Application. The use case addressed in the attached example code is that of a Bluetooth Beaconing device which operates in deep sleep mode EM3 or EM4. When the user interrupts the operation via a Button press, the device advertises for 10 seconds and goes back to sleep.
For more information about using Energy Modes with Bluetooth Stack, please refer this article.
Testing the example
The attached example works with any board which has Button 1 mapped to pin PF7.
Flash the attached example code on an EFR. The instructions to create the example are attached within the folder.
Set the WSTK in AEM mode using the 3-way switch.
In Simplicity Studio, open Energy Profiler
On the top left under Quick Access -> Start Energy Capture
Press Reset on the WSTK
Refer the graph generated for the energy consumption.
Press PB1; the device will advertise an iBeacon Packet for 10 seconds. During this time, the user will notice a jump in power consumption.
The device falls back to deep sleep after 10 seconds.
Be aware that if the device goes EM4 very soon after reset, it may be hard to get attached to the target using debugger and you can easily lock yourself out. The attached program has a 10 sec delay at boot to avoid this situation.
Unlike EM4, the other sleep modes cannot be entered by executing the command. If deep sleep flags are enabled, the device by default tends to go to the lowest allowed mode till EM3 where lower mode is lower energy consumption. The only thing which remains is to unblock the use of EM3. To end EM3 blocking call.
SLEEP_SleepBlockEnd(sleepEM3);
In the example code attached, use 3 and 4 in this define statement to switch between EM3 and EM4 respectively.
#define ENERGY_MODE 3
The average current consumption in EM3 deep sleep mode is 2.34 uA.
Energy profiles graph for EM3 mode
The average current consumption in EM4 deep sleep mode is 240 nA.
If you use LFXO or LFRCO on your board, you have to unlatch CMU registers if you entered EM4 (even if you didn't retain them in EM4), otherwise board won't start after EM4 Reset (only PORST will help).
I did it like this (put it right after LFXO init):
if (RMU_ResetCauseGet() & RMU_RSTCAUSE_EM4RST) {
EMU->CMD = EMU_CMD_EM4UNLATCH;
}
It seems like a right thing to do. Read more about it in EFR32xg13 Reference Manual, section 12.3.2.1.1 LFRCO and LFXO.
[Deprecated] KBA_BT_0919: Using EM3 or EM4 energy mode in a Bluetooth beacon app
Note: This KBA has been marked as deprecated. A more updated KBA can be found here: Using EM3/EM4 in a Beacon App
Using EM3/EM4 in a beacon app.
This article demonstrates the use of sleep modes EM3 and EM4 in a Bluetooth Beacon Application. The use case addressed in the attached example code is that of a Bluetooth Beaconing device which operates in deep sleep mode EM3 or EM4. When the user interrupts the operation via a Button press, the device advertises for 10 seconds and goes back to sleep.
For more information about using Energy Modes with Bluetooth Stack, please refer this article.
Testing the example
Some useful commands
To initialise a device for EM4
Define a wake-up pin to exit from EM4. This command is used to enable wake-up using GPIO pin in an active low state.
To enter EM4
Unlike EM4, the other sleep modes cannot be entered by executing the command. If deep sleep flags are enabled, the device by default tends to go to the lowest allowed mode till EM3 where lower mode is lower energy consumption. The only thing which remains is to unblock the use of EM3. To end EM3 blocking call.
In the example code attached, use 3 and 4 in this define statement to switch between EM3 and EM4 respectively.
The average current consumption in EM3 deep sleep mode is 2.34 uA.
The average current consumption in EM4 deep sleep mode is 240 nA.
If you use LFXO or LFRCO on your board, you have to unlatch CMU registers if you entered EM4 (even if you didn't retain them in EM4), otherwise board won't start after EM4 Reset (only PORST will help).
I did it like this (put it right after LFXO init):
It seems like a right thing to do. Read more about it in EFR32xg13 Reference Manual, section 12.3.2.1.1 LFRCO and LFXO.