Development for STM32L053R8 on NUCLEO-L053R8 board.
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.
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;
}
}
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?
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();
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.