芯片配置如下:
使能能够唤醒的事件:
void LowPwrCfg(void)
{
WFE_DeInit();
WFE_WakeUpSourceEventCmd(WFE_Source_RTC_CSS_EV,ENABLE);
WFE_WakeUpSourceEventCmd(WFE_Source_USART1_EV,ENABLE);
WFE_WakeUpSourceEventCmd(WFE_Source_USART2_EV,ENABLE);
}
配置rtc时钟,每10ms唤醒一次。
void SetAutoWakup(void)
{
if(SUCCESS == RTC_WakeUpCmd(DISABLE))
{
RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div2);//32768hz,2分频
RTC_SetWakeUpCounter(164);//10ms 时间基数
RTC_WakeUpCmd(ENABLE);
RTC_ITConfig(RTC_IT_WUT,ENABLE);
}
}
main上调用wfe(初始化之类实际程序有,这里被我删掉了)
void main(void)
{
while(1)
{
wfe();
}
}
问题1:当我调用了wfe()后debug肿停止函数运行,指针居然没有停止在wfe()上,证明程序没有进入低功耗。进入低功耗的话很大一部分时间程序指针都停止在低功耗语句上得。
问题2:当我初始化调用了上面配置的LowPwrCfg()函数后,rtc,跟uart都不能进入中断,但是从编译器看中断标志位已经置位。当将这个函数屏蔽后,可以正常通讯以及进入rtc中断。
芯片资料描述:
7.5 Wait for event (WFE) mode
Wait for event mode is entered from Run mode by executing a WFE instruction.
Interrupt requests during this mode are served normally, depending on the value of the I0
and I1 bits in the CPU_CC register.
Peripheral events can be generated by the timers, serial interfaces, DMA controller,
comparators and I/O ports. These are enabled by the WFE_CRx registers.
When a peripheral event is enabled, the corresponding interrupts are not served and you
have to clear the corresponding flag status.
There are two ways to wake up the CPU from WFE mode:
• Interrupts: when an interrupt occurs, the CPU wakes up from WFE mode and serves
the interrupt. After processing the interrupt, the processor goes back to WFE mode.
• Wakeup events: when a wakeup event occurs, the CPU wakes up and resumes
processing. As the processing resumes directly after the WFE instruction, there is no
context save/restore activity (this saves time and power consumption).
Further power consumption reduction may be achieved using this mode together with
execution from RAM. In some very low power applications, when the main software routine
is short and has a low execution time, this routine can be moved to RAM and executed from
RAM. As the Flash program memory is not used at wakeup, the power consumption is then
reduced during run time.
At any time, another routine (stored in the Flash program memory) can be executed by
software by simply calling/jumping to this routine.
其中这句令我很费解:
When a peripheral event is enabled, the corresponding interrupts are not served and you
have to clear the corresponding flag status.
看哪位大神知道原因,求告知,谢谢! |