2019-04-30 07:27 AM
Hi,
I am working on "Deep sleep" and "Wake- Up" on STM32L476 MCU. It looks like that MCU is going in to Deep Sleep (STOP2) mode, but I am not able to "wake up" using the GPIO EXTI (GPIO External Interrupts). Following the code snippets, which I am using to put the MCU in deep sleep mode (STOP2) mode, and I am generating the external interrupt on one of the GPIO pin ( note that the interrupt call back "HAL_GPIO_EXTI_Callback" is getting called when the CPU is working normally , before I put into Deep sleep mode)
void put_mcu_deepsleep_mode(void)
{
//Disabling few peripherals to save more power
HAL_UART_DeInit(&huart3);
HAL_UART_DeInit(&huart4);
HAL_UART_DeInit(&huart1);
HAL_UART_DeInit(&huart5);
HAL_SPI_DeInit(&hspi3);
HAL_TIM_Base_DeInit(&htim3);
HAL_TIM_Base_DeInit(&htim5);
HAL_GPIO_WritePin(GPIOC, MPU_EN_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, SUB1_PWR_EN_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOA, LIN_EN_Pin, GPIO_PIN_RESET);
/* Clearing the bit as per the reference manual to enter into STOP2 mode"
CLEAR_BIT(PWR->CR1, PWR_CR1_LPR);
osDelay(1000); /* Put delay before going to shut down */
/* Enter stop2 mode */
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
}
Also note that I have tired following as an alternate option to check if I can wake up the MCU using EXTI on GPIO. But couldn't able to wake up.
void put_mcu_deepsleep_mode(void)
{
HAL_EnableDBGStopMode();
/* Disable WKUP pin */
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN1 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN2 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN3 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN4 );
HAL_PWR_DisableWakeUpPin( PWR_WAKEUP_PIN5 );
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* Enable WKUP pin */
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN2);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN3);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN4);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN5);
__HAL_RCC_WAKEUPSTOP_CLK_CONFIG(RCC_STOP_WAKEUPCLOCK_MSI);
osDelay(1000); /* Put delay before going to shut down */
HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON,PWR_STOPENTRY_WFI);
}
2019-05-17 02:27 AM
Hello,
Are you using an EXTI or wake-up pin as wake-up event ?
Best Regards,
Mohamed Aymen.