Hi there,
Although I haven’t tried it but know of Hardware that has this enabled for a (EWEElink door sensor with CR battery). It breaks down like this.
The nRF52840 can operate at different logic levels because its GPIO voltage levels are tied to the VDD supply voltage. You can configure the GPIO voltage level dynamically by adjusting VDD and, in some cases, by using the programmable power supply output (VDDH).
nRF52840 GPIO Logic Levels Overview
- Default GPIO Logic Level (VDD Mode)
- The GPIO logic level is directly tied to the VDD supply voltage.
- Example: If VDD = 3.3V, GPIO high logic (
1
) is 3.3V. - If VDD = 1.8V, GPIO high logic (
1
) is 1.8V. - This allows the nRF52840 to be compatible with different voltage domains (1.8V, 3.0V, 3.3V).
- High Voltage Mode (VDDH Mode)
- The nRF52840 has a high-voltage regulator that allows it to run from a higher supply voltage (up to 5.5V).
- This is controlled using the REGOUT0 register.
- It allows you to configure VDD to 1.8V, 2.1V, 2.4V, or 3.0V.
- Programmable Output Voltage
- When powered from VDDH (e.g., 5V input), you can configure the REGOUT0 register to select a lower regulated VDD output.
- This affects the GPIO logic level accordingly.
How to Configure GPIO Logic Levels on nRF52840
1. Set VDD Voltage (Hardware)
- Direct Connection: If you power the nRF52840 at 3.3V, GPIO high logic (
1
) will also be 3.3V. - Low-Power Mode: If powered at 1.8V, GPIO outputs are at 1.8V.
2. Configure REGOUT0 for VDDH Mode (Software)
If you’re using VDDH (e.g., powered from USB 5V), you can configure REGOUT0 to select a different logic level.
#include <nrfx.h>
void configure_voltage_output() {
if (NRF_UICR->REGOUT0 == 0xFFFFFFFF) { // Check if default value (unset)
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen; // Enable writing to UICR
while (NRF_NVMC->READY == NVMC_READY_READY_Busy);
NRF_UICR->REGOUT0 = UICR_REGOUT0_VOUT_3V0; // Set VDD to 3.0V
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren; // Disable writing to UICR
NVIC_SystemReset(); // Reset for changes to take effect
}
}
Voltage Options (REGOUT0)
UICR_REGOUT0_VOUT_1V8
→ 1.8VUICR_REGOUT0_VOUT_2V1
→ 2.1VUICR_REGOUT0_VOUT_2V4
→ 2.4VUICR_REGOUT0_VOUT_3V0
→ 3.0V
Important Notes:
* You must reset the chip after writing to REGOUT0 for changes to apply.
- This only works when powered from VDDH (e.g., USB 5V).
When Would You Use This?
- Interfacing with Different Voltage Logic
- If connecting to a 1.8V sensor, set
VDD = 1.8V
to match logic levels. - If connecting to a 3.3V peripheral, set
VDD = 3.3V
.
- Low-Power Optimization
- Lowering
VDD
to 1.8V reduces power consumption.
- Using USB Power (5V)
- If running from USB (5V, VDDH mode), you can set
VDD = 3.0V
usingREGOUT0
.
Summary
GPIO voltage levels depend on VDD (1.8V to 3.3V).
Using VDDH (5V) allows programmable voltage output (REGOUT0).
To change voltage in software, configure REGOUT0 and reset the device.
HTH
GL PJ