cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO and peripheral intialization after exiting STOP Mode 1

MD'Si.1
Associate III

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();

 

1 ACCEPTED SOLUTION

Accepted Solutions
MD'Si.1
Associate III

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.

View solution in original post

3 REPLIES 3

Thanks for the link @Nikita91 ! 

MD'Si.1
Associate III

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.