Skip to content

Commit baf7d6b

Browse files
committed
Configure internal regulators at startup.
This commit introduces an implementation of the `mbed_sdk_init` startup hook that configures the internal regulators of the nRF52840. The configuration sets up the internal regulator to output 3.3V. If this is not done, the default system voltage may be too low for the on-board indicator LEDs to conduct. This configuration code also enables the internal DC/DC converter to lower power consumption.
1 parent 742a6be commit baf7d6b

File tree

1 file changed

+48
-0
lines changed
  • targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/TARGET_MCU_NRF52840/TARGET_EP_ATLAS

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2021 ARM Limited
3+
* Copyright (c) 2021 Embedded Planet, Inc.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "mbed_boot.h"
20+
21+
#include "nrf.h"
22+
23+
/**
24+
* Override the mbed sdk init startup hook
25+
* This will configure the internal regulator to operate at 3.3V
26+
* It also configures the nRF to use the on-board DC/DC for
27+
* lower power consumption
28+
*/
29+
void mbed_sdk_init(void) {
30+
31+
if (NRF_UICR->REGOUT0 != UICR_REGOUT0_VOUT_3V3)
32+
{
33+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
34+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
35+
NRF_UICR->REGOUT0 = UICR_REGOUT0_VOUT_3V3;
36+
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
37+
while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
38+
39+
// Trigger a soft reset so that the settings take effect
40+
NVIC_SystemReset();
41+
}
42+
43+
/* Set to use DC/DC */
44+
NRF_POWER->DCDCEN = 1;
45+
46+
}
47+
48+

0 commit comments

Comments
 (0)