2016-03-28 12:43 AM
Hi,
We're using Nucleo-L4 with X-CUBE-BLE1 Expansion SW with lower mode enabled. The 32L4 HSE XTAL input is driven by external oscillator. We would like to disable the external clock during low power mode of 32L4 and enable when 32L4 comes out of low power mode. Is three a way to do this via a GPIO pin of 32L4 ? if so, any guidance will be appreciated. Thanks. #stm32l4-external-hse-x-cube-ble1 #stm32l4-ble-expansion-lpm-stop2016-04-05 12:05 AM
More specifically, should we disable the external HS lock via GPIO before calling LPM_Enter_Mode or from within this function?
Should we enable the external HS clock from within or outside of function call: :LPM_ExitStopMode()? Thx,2016-04-12 12:06 AM
An update... After some more digging we were able to locate the section which enters STOP mode: HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI).
For the case when it exists STOP mode is not straightforward. The following LPM_EnterStopMode() function hints at the LPM_ExitStopMode() as the logical entry point for a GPIO toggle: void LPM_Enter_Mode(void) { uint32_t uwPRIMASK_Bit; uwPRIMASK_Bit = __get_PRIMASK(); /**< backup PRIMASK bit */ __disable_irq(); /**< Disable all interrupts by setting PRIMASK bit on Cortex*/ if(uwRUN_Req == 0) { if(uwDeepSleep_Req) { /** * Enter Sleep Mode */ HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); } else if (uwPDDS_Req == 0) /* WARNING: This mode is not supported yet by any platform */ { LPM_EnterStandbyMode(); /**< Call user Hook */ /** * Clear Wakeup flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); /** * Enter Standby Mode */ HAL_PWR_EnterSTANDBYMode(); LPM_ExitStandbyMode(); /**< Call user Hook */ } else { /** * Clear Wakeup flag */ __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); /** * Enter Stop Mode */ if(uwLPSDSR_Req) { HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_STOPENTRY_WFI); } else { #ifdef USE_STM32L4XX_NUCLEO HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI); #else HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); #endif } LPM_ExitStopMode(); /**< Call user Hook */ } } __set_PRIMASK(uwPRIMASK_Bit); /**< Restore PRIMASK bit*/ return; } But the code never gets to that function call. Is there another place or fucntional call we're missing?2016-04-25 04:47 AM
Hello,
If the LPM_ExitStopMode() is never called, that means you never enter STOP mode. I do not see any other reason. Once you will be able to enter STOP Mode, LPM_ExitStopMode() is the function where to switch ON your HSE. In the example provided, it is used similarly to switch ON the PLL. In order to switch OFF the HSE, you should add another hook which is missing in the actual delivery. You should implement a LPM_EnterStopMode() in which you should first switch on HSI/MSI before switching of the HSE ( assuming HSE is used as system clock for your CPU) LPM_EnterStopMode() shall be called just before HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI) Regards.