GPIO and peripheral intialization after exiting STOP Mode 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-11 4:25 PM
Hi,
I am using ThreadX and the STM32L4A9 processor. When my application is ready to sleep I call an enter low power function. I followed sample code from ST Cube example which disables the GPIO CLKs and enters STOP Mode 1.
//ENTER Low Power Mode
/* Disable USB Clock */
__HAL_RCC_USB_OTG_FS_CLK_DISABLE(); //We currently don't use the USB clock source
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOI_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
__HAL_RCC_GPIOE_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOG_CLK_DISABLE();
HAL_PWREx_DisableVddIO2();
__HAL_RCC_GPIOD_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOF_CLK_DISABLE();
/* Suspend sys ticks to avoid waking up the mcu on every interrupt */
HAL_SuspendTick();
/* Enter Stop Mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
My device wakes up without issue however it is not able to successfully read from a LPUART attached device. If I comment out the GPIOX CLK enable() and GPIOX CLK disable() calls my code is able to successfully read from the LPUART attached device after wakeup. What is the recommended best practice for GPIO initialization after waking up from sleep? Do I need to reconfigure all pins again?
Exit Low Power Mode
/* Re-Configure System Clock */
HAL_RCC_DeInit();
/* resume sys ticks */
HAL_ResumeTick();
Run_SystemClock_Config();
Run_Peripheral_Config();
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOI_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
HAL_PWREx_EnableVddIO2();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
Solved! Go to Solution.
- Labels:
-
LPUART
-
STM32L4 series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-18 9:15 AM
I found my issue was that HAL_RCC_DeInit() will disable all the interrupts so I had to re-enable my LPUSART interrupt again when exiting low power mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-12 2:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-18 9:14 AM
Thanks for the link @Nikita91 !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-18 9:15 AM
I found my issue was that HAL_RCC_DeInit() will disable all the interrupts so I had to re-enable my LPUSART interrupt again when exiting low power mode.
