Wireless-Tech 这个用的是自己画的板子,NRF_POWER->MAINREGSTATUS值为0x01。
现在是DCDC设置的是3.0V,供电电池电压VDDH如果是3.6V,VDD则从3.0V掉到2.97V(可以正常OTA),如果电池电压是2.68V,软复位时VDD从2.68V掉到1.56V(不能正常进OTA)。
代码如下:
void gpio_output_voltage_setup(uint32_t ulVout)
{
if ((nrf_power_mainregstatus_get() == NRF_POWER_MAINREGSTATUS_HIGH)
&& ((NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) != (ulVout << UICR_REGOUT0_VOUT_Pos)))
{
uint32_t aTemp[1024];
memcpy(aTemp, NRF_UICR, 4096);
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
}
NRF_NVMC->ERASEUICR = NVMC_ERASEUICR_ERASEUICR_Erase << NVMC_ERASEUICR_ERASEUICR_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
}
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
}
NRF_UICR_Type tTemp;
memcpy(&tTemp, aTemp, sizeof(NRF_UICR_Type));
tTemp.REGOUT0 = (tTemp.REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) | (ulVout << UICR_REGOUT0_VOUT_Pos);
if (tTemp.NRFFW[0] != BOOTLOADER_START_ADDRESS || tTemp.NRFFW[1] != BOOTLOADER_END_ADDRESS)
{
tTemp.NRFFW[0] = BOOTLOADER_START_ADDRESS;
tTemp.NRFFW[1] = BOOTLOADER_END_ADDRESS;
}
memcpy(NRF_UICR, &tTemp, sizeof(NRF_UICR_Type));
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
}
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
{
}
// System reset is needed to update UICR registers.
NVIC_SystemReset();
}
}
...
gpio_output_voltage_setup(UICR_REGOUT0_VOUT_3V0);