在线时间10 小时
UID425363
注册时间2013-4-7
NXP金币0
该用户从未签到
注册会员

- 积分
- 146
- 最后登录
- 1970-1-1
|
发表于 2015-8-10 23:35:25
|
显示全部楼层
请看如下标准的写法:
void enter_vlps(void)
{
volatile unsigned int dummyread;
/* The PMPROT register may have already been written by init code
If so then this next write is not done since
PMPROT is write once after RESET
allows the MCU to enter the VLPR, VLPW, and VLPS modes.
If AVLP is already writen to 0
Stop is entered instead of VLPS*/
SMC_PMPROT = SMC_PMPROT_AVLP_MASK;
/* Set the STOPM field to 0b010 for VLPS mode */
SMC_PMCTRL &= ~SMC_PMCTRL_STOPM_MASK;
SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x2);
/*wait for write to complete to SMC before stopping core */
dummyread = SMC_PMCTRL;
dummyread++;
/* Now execute the stop instruction to go into VLPS */
#ifdef CMSIS
/* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;
__wfi();
#else
stop();
#endif
}
另外进入VLPS前关掉clock monitor
void clockMonitor(unsigned char state)
{
if(state)
MCG_C6 |= MCG_C6_CME0_MASK;
else
MCG_C6 &= ~MCG_C6_CME0_MASK;
} |
|