Skip to content

Commit 42f3a1f

Browse files
committed
Configure internal regulators at startup
This commit introduces an implementation of the `subtarget_sdk_init` startup hook (called during `mbed_sdk_init`) 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 (ie: system voltage is lower than LED forward voltage).
1 parent f7ec796 commit 42f3a1f

File tree

1 file changed

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

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 <stdint.h>
20+
21+
#include "subtarget_init.h"
22+
23+
#include "nrf.h"
24+
25+
/**
26+
* Override the subtarget sdk init startup hook (specific to nRF2)
27+
* This will configure the internal regulator to operate at 3.3V
28+
*/
29+
void subtarget_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+
44+

0 commit comments

Comments
 (0)