Indicador de falha de energia em NRF24LE1 (Parte 4/14)

Power failure indicator on NRF24LE1 (Part 4/14)

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.

Protótipo de interface NRF24LE1 e EEPROM

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

• Bit 3:0 – not used
Comparador de falha de energia (POF).
To use the POF comparator we have to enable it by writing 1 in the 7th bit of the POFCON register. After enabling the comparator, we have to choose our desired threshold level from different threshold levels and write bit6:5 accordingly. After we have enabled POF and set the desired threshold level, we can check the power failure warning indicated by bit4 of POFCON.
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

Check out the code to understand how to program this feature. The code has been commented for clearer understanding.
Indicador de falha de energia em NRF24LE1
Another great feature that comes with NRF is Brown Out Reset. This feature puts the microcontroller into a reset state whenever the VDD drops below the BOR threshold level. The BOR threshold level is 1.7V. The MCU starts working again whenever the VDD goes above 1.77V.
The module seems to be an amazing module with so many features. We are really enjoying our work on the module. Let us know what you do using the module and share your project with us in the comments below.

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

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.