Power failure indicator on NRF24LE1
Nowadays most of our devices are portable and run on batteries. We often don't know when the battery is about to discharge. Many systems have the battery voltage display to indicate the battery voltage, but what if we don't have the display in our system. In this case, using a small LED to indicate low battery is very helpful for users to know about the battery status.
In this article, we will discuss a very important feature of NR24LE1 that enables power failure indicator.
Fig. 1: Power failure indicator prototype based on NRF24LE1
The NRF module comes with a built-in comparator known as Power Failure Comparator (POF). This comparator provides the MCU (Microcontroller Unit) with an early warning of power failure. The comparator compares VDD (supply voltage) and threshold voltage. It issues a warning when the VDD voltage drops below a threshold level. We know that the threshold level is a voltage level that can be defined by the user as needed. There are four threshold levels offered by the NRF module: 2.1, 2.3, 2.4, and 2.5V.
The register through which we can access the functionality is the POFCON (Power Failure Control) register. It is an 8-bit register. The functions of various bits of the registry are given below:
• Bit 7 – enables/disables POF comparator. 0: disable, 1: enable
• Bit 6:5 – set limit level. 00: 2.1V, 01: 2.3V, 10: 2.5V, 11: 2.7V
• Bit 4 – warning. 0: VDD above limit, 1: VDD below limit
FUNCTION | INPUT PARAMETER | EXIT | DESCRIPTION |
---|---|---|---|
hal_pof_enable | 0/1 | – | To enable POF
0: Disable 1: Enable |
hal_pof_set_threshold | HAL_POF_THRESHOLD_2_1V
HAL_POF_THRESHOLD_2_3V HAL_POF_THRESHOLD_2_5V HAL_POF_THRESHOLD_2_7V |
– | To set the threshold level:
2.1V, 2.3V, 2.5V or 2.7V |
hal_pof_warning | – | 0/1 | To check the POF warning
0 – No warning 1 – Warning |
Project source code
###
#include"reg24le1.h" // I/O header file for NRF24LE1 // main function void main { POFCON = 0xe0; // POF enable with threshold at 2.7V P0DIR = 0; // set PORT0 as output P0 = 1; // Port 0 high // infinite loop while(1) { if(POFCON & 0x10) // check for warning P00 = 0; // make Pin 0 of Port 0 low } } ###
Circuit diagrams
Circuit diagram-power failure indicator based on NRF24LE1 |
Project video