cancel
Showing results for 
Search instead for 
Did you mean: 

Issue: Auto wakeup of stm32f746 Disco. board from standby mode without any external trigger.

SGupt.7
Associate II

Hello all,

I am trying to implement standby mode in stm32f7 board. The issue that I am facing is that the MCU wakes up automatically from standby mode even when I do not trigger the external wakeup pin.

Below is my code from CubeIDE. Any help will be appreciated.

In the pin configuration,I have configured 2 pins for USART, 1 pin for on-board led and 1 system wakeup pin.

int main(void)
 
{
 
 /* USER CODE BEGIN 1 */
 
 
 
 /* USER CODE END 1 */
 
 
 
 /* MCU Configuration--------------------------------------------------------*/
 
 
 
 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 
 HAL_Init();
 
 
 
 /* USER CODE BEGIN Init */
 
 
 
 /* USER CODE END Init */
 
 
 
 /* Configure the system clock */
 
 SystemClock_Config();
 
 
 
 /* USER CODE BEGIN SysInit */
 
 
 
 /* USER CODE END SysInit */
 
 
 
 /* Initialize all configured peripherals */
 
 MX_GPIO_Init();
 
 MX_USART1_UART_Init();
 
 /* USER CODE BEGIN 2 */
 
 
 
 // Enable Power clock
 
 __HAL_RCC_PWR_CLK_ENABLE();
 
 
 
 // Check and handle if system was resumed from standby mode
 
 if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB) != RESET) {
 
 
 
 // Clear the SB flag
 
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU|PWR_FLAG_SB);
 
 
 
 // display wakeup string
 
 sprintf(tx_buffer, "MCU wakes up from STANDBY mode...\n\r");
 
 HAL_UART_Transmit(&huart1, tx_buffer, sizeof(tx_buffer), HAL_MAX_DELAY);
 
 HAL_Delay(200);
 
 
 
 // toggle led
 
 for(int i=0; i<20; i++) {
 
 HAL_GPIO_TogglePin(user_led_GPIO_Port, user_led_Pin);
 
 HAL_Delay(200);
 
 }
 
 
 
 for(int j=0; j<100; j++) {
 
 tx_buffer[j] = 0;
 
 }
 
 
 
 // disable wakeup pin
 
 HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN6);
 
 HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN_FLAG6);
 
 }
 
 
 
 /* USER CODE END 2 */
 
 
 
 /* Infinite loop */
 
 /* USER CODE BEGIN WHILE */
 
 while (1)
 
 {
 
  /* USER CODE END WHILE */
 
 
 
  /* USER CODE BEGIN 3 */
 
 
 
 // LED on
 
 HAL_GPIO_WritePin(user_led_GPIO_Port, user_led_Pin, 1);
 
 
 
 // display string
 
 sprintf(tx_buffer, "MCU in RUN mode...\n\r");
 
 HAL_UART_Transmit(&huart1, tx_buffer, sizeof(tx_buffer), HAL_MAX_DELAY);
 
 HAL_Delay(500);
 
 
 
 // display string
 
 sprintf(tx_buffer, "MCU entering standby mode in 5 seconds...\n\r");
 
 HAL_UART_Transmit(&huart1, tx_buffer, sizeof(tx_buffer), HAL_MAX_DELAY);
 
 
 
 // LED off
 
 HAL_GPIO_WritePin(user_led_GPIO_Port, user_led_Pin, 0);
 
 
 
 // Clear tx buffer
 
 for(int i=0; i<100; i++) {
 
 tx_buffer[i] = 0;
 
 }
 
 
 
 // 5 seconds delay
 
 HAL_Delay(5000);
 
 
 
 // Enter the standby mode
 
 
 
 // Clear the wakeup flag
 
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
 
 
 
 // Enable wakeup pin
 
 HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN6);
 
 
 
 // final string before entry to standby mode
 
 sprintf(tx_buffer, "STANDBY mode ON...\n\r");
 
 HAL_UART_Transmit(&huart1, tx_buffer, sizeof(tx_buffer), HAL_MAX_DELAY);
 
 HAL_Delay(200);
 
 
 
 // standby mode function call
 
 HAL_PWR_EnterSTANDBYMode();
 
 }
 
 /* USER CODE END 3 */
 
}

2 REPLIES 2
MM..1
Chief II

Read example for wakeup by RTC.

And place code to code snip

HAL_PWR_EnterSTANDBYMode();

Thank you very much for the reply.

I have been trying the same with RTC wakeup too but I still face a similar issue.

If you could share a tested link/thread that I can refer to, then it would be really helpful.

Thanks again.