Skip to main content
Visitor II
April 12, 2024
Question

STM32U585 PWR_WKUP from STOP Mode

  • April 12, 2024
  • 1 reply
  • 2202 views

Hello,

I am using the STM32U585 along with two sensors in a project and I need some help. I want to run my MCU in stop 3 mode primarily and have one of the sensors generate an interrupt on the PWR_WKUP pin of the MCU to return to normal mode and start polling data from the other sensor. I am not very experienced in programming and I'm finding it hard to find the functions needed in the IDE or information in the reference manual to do what I want. Any help would be greatly appreciated.

Thanks.

    This topic has been closed for replies.

    1 reply

    ST Employee
    April 18, 2024
    Hello,
     
    there is one of the simplest way how to do it.
    At first generate default code by STM32CubeMX for your IDE
    and use there in infinite loop the code below. There 
    MCU enters into STOP3 mode and stay there until rising
    edge on PA0 pin occurs and then MCU wake up and executes 
    your code. After your code will be executed MCU enters
    back into STOP3 mode.
     
     
    /* Infinite loop */
      /* USER CODE BEGIN WHILE */
      while (1)
      {   
      /* Enable Power Control clock */
      __HAL_RCC_PWR_CLK_ENABLE();
     
      /* Clear all flags from all Wake up pins */
      __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF);
     
      /* Enable Wake up pin 1 (PA0) with rising edge detection */
      HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_HIGH);
     
      /* Enter into STOP3 mode and stay there
       * until rising edge on PA0 is detected */
      HAL_PWREx_EnterSTOP3Mode(PWR_STOPENTRY_WFI);
     
      /* Rising edge on PA0 was detected MCU wakes up */
     
     
      /* Time to start polling data from the other sensor
       * ...
       * ... YOUR CODE
       * ...
       * */
     
     
      /* After the end of polling data from other sensor enter back
       * into STOP3 mode in the beginning of while cycle */
     
        /* USER CODE END WHILE */
     
        /* USER CODE BEGIN 3 */
      }
      /* USER CODE END 3 */

     

    Visitor II
    April 18, 2024

    Thank you for your response I will give this solution a try!