Skip to main content
Amb.1739
Visitor II
November 20, 2019
Question

STM32L475 wake up from STOP 2 mode

  • November 20, 2019
  • 1 reply
  • 885 views

HI ,

I am working with low power modes on STM32L475. The device doesn't wake up from STOP2 mode,

I am keeping the x-cubel4 examples as reference

en.stm32cubel4\STM32Cube_FW_L4_V1.14.0\Projects\NUCLEO-L476RG\Examples\PWR\PWR_STOP2_RTC.

My LED doesn't turn on after the time is elapsed, i don't know when my device has woken up, it says target not responding, I am having to erase the flash memory everytime i do this, i believe its going to STOP mode but not waking up, cannot understand whats wrong with below code which i am using.

while(1){

  /* Insert 5 second delay */

    HAL_Delay(5000);

   /* Set all GPIO in analog state to reduce power consumption */

     __HAL_RCC_GPIOA_CLK_ENABLE();

     __HAL_RCC_GPIOB_CLK_ENABLE();

     __HAL_RCC_GPIOC_CLK_ENABLE();

     __HAL_RCC_GPIOD_CLK_ENABLE();

     __HAL_RCC_GPIOE_CLK_ENABLE();

     __HAL_RCC_GPIOF_CLK_ENABLE();

     __HAL_RCC_GPIOG_CLK_ENABLE();

     __HAL_RCC_GPIOH_CLK_ENABLE();

   /* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */

    /* Note: Debug using ST-Link is not possible during the execution of this  */

    /*    example because communication between ST-link and the device    */

    /*    under test is done through UART. All GPIO pins are disabled (set  */

    /*    to analog input mode) including UART I/O pins.      */

    GPIO_InitStructure.Mode = GPIO_MODE_ANALOG;

  GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

  GPIO_InitStructure.Pull = GPIO_NOPULL;

  GPIO_InitStructure.Pin = GPIO_PIN_All;

   HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);

   HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);

   HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);

   HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);

   HAL_GPIO_Init(GPIOE, &GPIO_InitStructure);

   HAL_GPIO_Init(GPIOF, &GPIO_InitStructure);

   HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);

   HAL_GPIO_Init(GPIOH, &GPIO_InitStructure);

  /* Disable GPIOs clock */

   __HAL_RCC_GPIOA_CLK_DISABLE();

   __HAL_RCC_GPIOB_CLK_DISABLE();

   __HAL_RCC_GPIOC_CLK_DISABLE();

   __HAL_RCC_GPIOD_CLK_DISABLE();

   __HAL_RCC_GPIOE_CLK_DISABLE();

   __HAL_RCC_GPIOF_CLK_DISABLE();

   __HAL_RCC_GPIOG_CLK_DISABLE();

   __HAL_RCC_GPIOH_CLK_DISABLE();

    /* Disable all used wakeup source */

     HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);

    HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x0FFFF, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

    printf("Entering stop1 mode....\r\n");

  /* Enter STOP 2 mode */

     HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);

     /* Re-configure the system clock to 80 MHz based on MSI, enable and

      select PLL as system clock source (PLL is disabled in STOP mode) */

     SYSCLKConfig_STOP();

  /* Re-configure and turn on LED1 */

  printf("Exiting stop1 mode....\r\n");

    BSP_LED_Init(LED_GREEN);

    BSP_LED_On(LED_GREEN);

This topic has been closed for replies.

1 reply

Mike_ST
Technical Moderator
November 20, 2019

Timer is set to 33 secs, hope you wait long enough.

Using the L476 example, no problem here. LED is blinking as expected after RTC time out.

I have tested and decreased time to 0xFFF (~2secs) instead of 0xFFFF (~33secs).

Tested on IOT node STM32L475.

AS for SWD connection, pressing reset button give me back control on debug interface.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.