在手册360页有提到选择位的寄存器位置。
然后查看头文件,找到DCDC关键字。
/*---------------------------------------------------------------------------------------------------------*/
/* PLCTL constant definitions. (Write-Protection Register) */
/*---------------------------------------------------------------------------------------------------------*/
#define SYS_PLCTL_PLSEL_PL0 (0x0UL<<SYS_PLCTL_PLSEL_Pos) /*!< Set power level to power level 0 */
#define SYS_PLCTL_PLSEL_PL1 (0x1UL<<SYS_PLCTL_PLSEL_Pos) /*!< Set power level to power level 1 */
#define SYS_PLCTL_MVRS_LDO (0x0UL<<SYS_PLCTL_MVRS_Pos) /*!< Set main voltage regulator type to LDO */
#define SYS_PLCTL_MVRS_DCDC (0x1UL<<SYS_PLCTL_MVRS_Pos) /*!< Set main voltage regulator type to DCDC */
然后找对应的.c
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] Set Main Voltage Regulator Type
* @param[in] u32PowerRegulator is main voltage regulator type. Including :
* - \ref SYS_PLCTL_MVRS_LDO
* - \ref SYS_PLCTL_MVRS_DCDC
* @retval 0 main voltage regulator type setting is not finished
* @retval 1 main voltage regulator type setting is finished
* [url=home.php?mod=space&uid=1543424]@Details[/url] This function set main voltage regulator type.
* The main voltage regulator type setting to DCDC cannot finished if the inductor is not detected.
* The register write-protection function should be disabled before using this function.
*/
uint32_t SYS_SetPowerRegulator(uint32_t u32PowerRegulator)
{
int32_t i32TimeOutCnt = 400;
uint32_t u32Ret = 1U;
uint32_t u32PowerRegStatus;
/* Get main voltage regulator type status */
u32PowerRegStatus = SYS->PLSTS & SYS_PLSTS_CURMVR_Msk;
/* Set main voltage regulator type */
if((u32PowerRegulator == SYS_PLCTL_MVRS_DCDC) && (u32PowerRegStatus == SYS_PLSTS_CURMVR_LDO))
{
/* Set main voltage regulator type to DCDC if status is LDO */
SYS->PLCTL |= SYS_PLCTL_MVRS_Msk;
/* Wait induction detection and main voltage regulator type change ready */
while((SYS->PLSTS & SYS_PLSTS_CURMVR_Msk) != SYS_PLSTS_CURMVR_DCDC)
{
if(i32TimeOutCnt-- <= 0)
{
u32Ret = 0U; /* Main voltage regulator type change time-out */
break;
}
}
}
else if(u32PowerRegulator == SYS_PLCTL_MVRS_LDO)
{
/* Set main voltage regulator type to LDO if status is DCDC */
SYS->PLCTL &= (~SYS_PLCTL_MVRS_Msk);
/* Wait main voltage regulator type change ready */
while((SYS->PLSTS & SYS_PLSTS_CURMVR_Msk) != SYS_PLSTS_CURMVR_LDO)
{
if(i32TimeOutCnt-- <= 0)
{
u32Ret = 0U; /* Main voltage regulator type change time-out */
break;
}
}
}
/* Clear main voltage regulator type change error flag */
if(SYS->PLSTS & SYS_PLSTS_MVRCERR_Msk)
{
SYS->PLSTS = SYS_PLSTS_MVRCERR_Msk;
u32Ret = 0U;
}
return u32Ret;
}
|