HAL_RCC_OscConfig花费的时间太长(大约170μS),从STOP唤醒时我需要它小于50μS [英] HAL_RCC_OscConfig takes too long (appx 170 μS), I need it to be <50 μS when waking from STOP

查看:769
本文介绍了HAL_RCC_OscConfig花费的时间太长(大约170μS),从STOP唤醒时我需要它小于50μS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在NUCLEO-L053R8板上开发STM32L053R8.

Development for STM32L053R8 on NUCLEO-L053R8 board.

我们有一个系统,该系统每隔200μS左右从睡眠中唤醒",执行少量工作,然后返回睡眠状态(停止模式). 理想情况下,我希望在50μS以下的时间内从STOP唤醒. HAL_RCC_OscConfig()函数大约需要170μS,这使这项工作毫无意义.

We have a system which "wakes" from sleep every 200 μS or so, does a small amount of work then goes back to sleep (Stop mode). Ideally I'd like to wake from STOP in under 50 μS. The HAL_RCC_OscConfig() function takes around 170 μS which renders this effort pointless.

从我的看到,大部分时间都花在了PLL配置上,尤其是在重新启用PLL之后(约98μS)的while循环(等待直到PLL准备就绪").

From what I can see the majority of time is spent with the PLL Configuration, in particular the while loop ("Wait till PLL is ready") which follows the re-enablement of the PLL (about 98 μS).

/* Configure the main PLL clock source, multiplication and division factors. */
__HAL_RCC_PLL_CONFIG(RCC_OscInitStruct->PLL.PLLSource,
                     RCC_OscInitStruct->PLL.PLLMUL,
                     RCC_OscInitStruct->PLL.PLLDIV);
/* Enable the main PLL. */
__HAL_RCC_PLL_ENABLE();

/* Get timeout */
tickstart = HAL_GetTick();

/* Wait till PLL is ready */  
while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == RESET)
{
  if((HAL_GetTick() - tickstart ) > RCC_PLL_TIMEOUT_VALUE)
  {
    return HAL_TIMEOUT;
  }      
}  

是否有任何方法可以从STOP模式唤醒并在50μS内回到全速HSI? 从STOP唤醒时,最有效的时钟设置方法是什么?

Are there any ways to wake from STOP mode and get back to full speed HSI in under 50 μS? What is the most efficient method to set the clocks when waking from STOP?

当前,我使用PWR_STOP示例中规定的方法,如下所示:

Currently I use the method prescribed in the PWR_STOP example which is as follows:

/* Enter Stop Mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

/* Stop interrupt that woke us up */
int ret = HAL_LPTIM_TimeOut_Stop_IT(&LptimHandle);
SystemDisableWakeupCounter();

/* Configures system clock after wake-up from STOP: enable HSI, PLL and select
PLL as system clock source (HSI and PLL are disabled automatically in STOP mode) */
SystemClockConfig_STOP();

SystemClockConfig_STOP()的调用依次调用SystemClock_Config(),该时钟配置时钟并在HAL_RCC_OscConfig(&RCC_OscInitStruct)中包括此较长的延迟.

The call to SystemClockConfig_STOP() in turn calls SystemClock_Config() which configures the clocks and includes this long delay in HAL_RCC_OscConfig(&RCC_OscInitStruct).

在此先感谢您提供的任何帮助.

Many thanks in advance for any assistance offered.

推荐答案

我现在不知道您的PLL源是什么,但是建议使用HSI16.全部来自

I do not know what is your PLL source right now, but HSI16 is recommended. All from the reference manual.

HSI16时钟信号由内部16 MHz RC产生 振荡器.它可以直接用作系统时钟或PLL输入.

The HSI16 clock signal is generated from an internal 16 MHz RC oscillator. It can be used directly as a system clock or as PLL input.

从Stop低功耗唤醒后可以使用HSI16时钟 模式,与使用MSI进行唤醒相比,这可以确保更短的唤醒时间 时钟.

The HSI16 clock can be used after wake-up from the Stop low-power mode, this ensure a smaller wake-up time than a wake-up using MSI clock.


如果可以允许更高的功耗,请不要禁用内部稳压器.这是一个折衷方案:更快的唤醒和更高的消耗,或者更慢的唤醒同时节省更多的能量,确定哪个更重要.


If you can allow the slightly higher consumption, do not disable the internal regulator. It is a compromise: faster wake-up with higher consumption or slower while saving more energy, decide which is the more important.

通过发出中断或唤醒事件退出停止"模式时, 选择MSI或HSI16 RC振荡器作为系统时钟,具体取决于 RCC_CFGR寄存器中的STOPWUCK位.

When exiting Stop mode by issuing an interrupt or a wakeup event, the MSI or HSI16 RC oscillator is selected as system clock depending the bit STOPWUCK in the RCC_CFGR register.

当稳压器 在低功耗模式下运行,会导致额外的启动延迟 从停止模式中唤醒时.通过保持内部调节器为开 在停止模式下,尽管启动时间较长,但消耗量更大 减少了.

When the voltage regulator operates in low-power mode, an additional startup delay is incurred when waking up from Stop mode. By keeping the internal regulator ON during Stop mode, the consumption is higher although the startup time is reduced.


现在,我认为必须使用PLL,但是除了上面提到的那样,恐怕您在启动时间上做得并不多. PLL需要一定的时间才能锁定输入参考时钟频率.但是首先必须使输入频率稳定(这就是为什么建议使用HSI16的原因).


Now I suppose using the PLL is a must, but then I am afraid apart from the above mentioned you cannot do really much about the startup time. The PLL needs a certain time to lock onto the input reference clock frequency. But first the input frequency must become stable (that's why it is recommended to use the HSI16).

您可以使用中断来代替阻塞等待(while循环).

Instead of the blocking wait (while loop) you can use an interrupt.

如果在RCC_CIER寄存器中启用了PLL,则在PLL准备好时会产生一个中断 (请参阅第7.3.5节).

An interrupt can be generated when the PLL is ready if enabled in the RCC_CIER register (see Section 7.3.5).

在PLL锁定期间,您可以在16 MHz上执行一些任务,并且在接收到中断时即可启动需要全速运行的任务(ISR中的时钟配置完成).

And while the PLL is locking you can do some tasks on 16 MHz, and the tasks requiring the full-speed can be started when the interrupt is received (finish clock configuration in the ISR).

这篇关于HAL_RCC_OscConfig花费的时间太长(大约170μS),从STOP唤醒时我需要它小于50μS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆