打印
[STM8]

stm8L的低功耗WFE问题

[复制链接]
3427|7
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yuson102|  楼主 | 2016-1-20 00:12 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
芯片配置如下:
使能能够唤醒的事件:
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.
看哪位大神知道原因,求告知,谢谢!
沙发
airwill| | 2016-1-20 08:03 | 只看该作者
嗯, 这句话有点奇怪, 或许 the corresponding interrupts 转做唤醒事件, 就不传递给中断系统了.

使用特权

评论回复
板凳
yuson102|  楼主 | 2016-1-20 11:54 | 只看该作者
airwill 发表于 2016-1-20 08:03
嗯, 这句话有点奇怪, 或许 the corresponding interrupts 转做唤醒事件, 就不传递给中断系统了. ...

我也觉得问题应该在这When a peripheral event is enabled, the corresponding interrupts are not served and youhave to clear the corresponding flag status.(我理解为:当外围事件被使能用于触发退出低功耗,对应的中断就不再提供,你必须要清除对应的标志位)。问题是:1、在wfe情况有中断事件不是进入中断服务函数里处理事件吗,不能进入中断怎么处理事件呢?2、清除对应标志位是指哪个标志位,中断标志位吗?费解!!

使用特权

评论回复
地板
yuson102|  楼主 | 2016-1-26 15:17 | 只看该作者
居然没人知道?

使用特权

评论回复
5
Soraka| | 2016-1-27 20:29 | 只看该作者
清除对应寄存器产生的标志位

使用特权

评论回复
6
Micachl| | 2016-1-29 10:18 | 只看该作者
是不是说中断产生了,如果你不清除标志位,就不会再产生中断

使用特权

评论回复
7
orangebanana| | 2016-1-29 15:06 | 只看该作者
中断的话,进去必须清除标志位,否则下次就来不了中断了

使用特权

评论回复
8
wahahaheihei| | 2016-1-30 10:15 | 只看该作者
1、在wfe情况有中断事件不是进入中断服务函数里处理事件吗,不能进入中断怎么处理事件呢?2、清除对应标志位是指哪个标志位,中断标志位吗?费解!!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

20

帖子

1

粉丝