MCU为MKL16Z128,在VLPR模式下电流为6mA,使用LPM.c中的Enter_Vlpr()
在VLPR模式下电流为6mA,求助那儿出问题了?
u32 enter_vlpr(void)
{
S32 i;
U32 return_value;
if ((SMC_PMSTAT & SMC_PMSTAT_PMSTAT_MASK)== 4)
{
return_value = 0x14;
}
/* The PMPROT register may have already been written by init code
If so then this next write is not done.
PMPROT is write once after RESET
this write-once bit allows the MCU to enter the
very low power modes: VLPR, VLPW, and VLPS
*/
SMC_PMPROT = SMC_PMPROT_AVLP_MASK;
/* Set the (for MC1)LPLLSM or (for MC2)STOPM field
to 0b010 for VLPS mode -
and RUNM bits to 0b010 for VLPR mode
*/
SMC_PMCTRL &= ~SMC_PMCTRL_RUNM_MASK;
SMC_PMCTRL |= SMC_PMCTRL_RUNM(0x2);
/* Wait for VLPS regulator mode to be confirmed */
for (i = 0 ; i < 10000 ; i++)
{
/*
check that the value of REGONS bit is not 0
once it is a zero we can stop checking
*/
if ((PMC_REGSC & PMC_REGSC_REGONS_MASK) ==0x04)
{
/* 0 Regulator is in stop regulation or in transition
to/from it
1 MCU is in Run regulation mode
*/
}
else break;
}
if ((PMC_REGSC & PMC_REGSC_REGONS_MASK) ==0x04)
{
return_value = 0x24;
}
/* SMC_PMSTAT register only exist in Mode Controller 2 MCU versions */
if ((SMC_PMSTAT & SMC_PMSTAT_PMSTAT_MASK) == 4)
{
return_value = SMC_PMSTAT;
}
return (return_value);
} |