SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP); } 在执行最后一句代码前,系统由于调用了__WFI 或 __WFE,已经进入了停止模式,因此,这句清除SLEEPDEEP 位并不会执行。而当内核重新被唤醒时,才会清除SLEEPDEEP位,方便使用。 SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR
/* Set SLEEPDEEP bit of Cortex System Control Register */ SCB->SCR|=SCB_SCR_SLEEPDEEP; /* This option is used to ensure that store operations are completed */ #if defined ( __CC_ARM ) __force_stores(); #endif /* Request Wait For Interrupt */ __WFI();// } 1. 2. 3. 4. ...
事件。 3. 系统控制寄存器 (SCB_SCR) 主要关注的位是SLEEPDEEP和SLEEPONEXIT两位。 SLEEPDEEP(位2 ) 控制处理器是否使用睡眠或者深度睡眠来使用低功耗模式 0: 睡眠模式 1: 深度睡眠模式(停机、待机) SLEEPONEXIT( 位1) 配置在从处理程序模式(Handler mode)返回到线程模式(Thread mode)时启用退出即休眠(Sleep-...
SCB->SCR |= SCB_SCR_SLEEPDEEP;// 设置 PDDS 位(进入深度睡眠时进入待机模式)PWR->CR |= PWR...
{/* Clear Wake-up flag */PWR- >CR |= PWR_CR_CWUF;/* Select STANDBY mode */PWR- >CR |= PWR_CR_PDDS;/* Set SLEEPDEEP bit of Cortex System Control Register */SCB- >SCR |= SCB_SCR_SLEEPDEEP;/* This option is used to ensure that store operations are completed */#if defined...
} SCB_TypeDef; /* System Control Block Structure */ 它们对应ARM手册中的名称为 CPUID = CPUID Base Register ICSR = Interrupt Control State Register VTOR = Vector Table Offset Register AIRCR = Application Interrupt/Reset Control Register SCR = System Control Register ...
SCB_SCR的第二位 2、使能电源时钟,设置WK_UP引脚作为唤醒源 因为要配置电源控制寄存器,所以必须先使能电源时钟。然后再设置PWR_CSR的EWUP位,使能WK_UP用于将CPU从待机模式唤醒。 3、设置 PDDS PDDS位,执行 WFI 指令,进入待机模式。 通过PWR_CR 设置 PDDS 位,使得 CPU 进入深度睡眠时待机模式,最后执行 WFI指...
*/voidPWR_EnterSTANDBYMode(void){/* Clear Wake-up flag */PWR->CR |= PWR_CR_CWUF;/* Select STANDBY mode */PWR->CR |= PWR_CR_PDDS;/* Set SLEEPDEEP bit of Cortex System Control Register */SCB->SCR |= SCB_SCR_SLEEPDEEP;/* This option is used to ensure that store operations ...
返回方式:通过设置内核SCB寄存器的Sleep-on-exit位,可以选择系统被唤醒执行完中断服务程序后进入主线程模式后是否立即进入睡眠模式。 从睡眠中唤醒: WFI唤醒或sleep-on-exit: 一般来说,使能的异常可以唤醒内核。对于一些系统,在唤醒后执行中断处理程序前需要先执行重新恢复的任务,则首先需要屏蔽所有中断(PRIMASK=1),中...
} SCB_TypeDef; /* System Control Block Structure */ 它们对应ARM手册中的名称为 CPUID = CPUID Base Register ICSR = Interrupt Control State Register VTOR = Vector Table Offset Register AIRCR = Application Interrupt/Reset Control Register SCR = System Control Register ...