Files
microchip-application-pec93…/Examples/pwr/pwr_sleep_mode

pwr_sleep_mode

This example is used to enter power mode and wake-up system

  • In normal mode, it will toggle I/O to notify user
  • Use Button to enter/leave power-mode function

When measure the electric current, user should remove all external device links

External device e.g. ICE, log message device (UART), LA (Logic Analyzer), ...etc.

  • Sleep/Deepsleep mode

    • Sleep mode

      // at main.c (Use sleep mode)
      #define CONFIG_USE_SLEEP_MODE       1
      
    • Deep-Sleep mode

      // at main.c (Use deep-sleep mode)
      #define CONFIG_USE_SLEEP_MODE       0
      
  • The I/O selection of Button

    // at main.c
    /* Input Key I/O definitions */
    #define CONFIG_GPIO_INPUT_PORTx         GPIOA
    #define CONFIG_GPIO_INPUT_PINx          GPIO_Pin_03
    #define CONFIG_GPIO_INPUT_IRQ           GPIOA_IRQn
    
  • The toggled I/O selection

    // at main.c
    /* Toggle I/O when normal App executing */
    #define CONFIG_IO_TOGGLE_PORTx          GPIOA
    #define CONFIG_IO_TOGGLE_PINx           GPIO_Pin_02
    
  • Wake-up modules selection

    • The I/O wake-up case will provide the minimum current when deep-sleep mode
    • The LpTIM/WDG cases will provide the lower current when deep-sleep mode
    • I/O wake-up

      // at main.c
      /**
       *  The target module to wake-up system
       *  + I/O wake-up case is ultra-low power in DeepSleep mode
       *  + LpTIM/WDG wake-up cases are low power in DeepSleep mode
       */
      #define CONFIG_USE_IO_WAKEUP        1
      #define CONFIG_USE_LPTIN_WAKEUP     0
      #define CONFIG_USE_WDG_WAKEUP       0
      
    • LpTIM wake-up

      // at main.c
      /**
       *  The target module to wake-up system
       *  + I/O wake-up case is ultra-low power in DeepSleep mode
       *  + LpTIM/WDG wake-up cases are low power in DeepSleep mode
       */
      #define CONFIG_USE_IO_WAKEUP        0
      #define CONFIG_USE_LPTIN_WAKEUP     1
      #define CONFIG_USE_WDG_WAKEUP       0
      
    • WDG wake-up

      // at main.c
      /**
       *  The target module to wake-up system
       *  + I/O wake-up case is ultra-low power in DeepSleep mode
       *  + LpTIM/WDG wake-up cases are low power in DeepSleep mode
       */
      #define CONFIG_USE_IO_WAKEUP        0
      #define CONFIG_USE_LPTIN_WAKEUP     0
      #define CONFIG_USE_WDG_WAKEUP       1
      

Log

Use serial port with baudrate 115200, 8bit, no parity check.

  • Sleep mode

    • I/O wake-up

      [2025-11-21 16:54:01.215] Nov 19 2025 16:53:58
      [2025-11-21 16:54:01.215] This is an example of Power-Mode (Sleep) and wake-up with I/O
      [2025-11-21 16:54:01.220]    Button = PA3
      [2025-11-21 16:54:01.224]    Output I/O = PA2
      [2025-11-21 16:54:05.020] -> enter sleep
      [2025-11-21 16:54:05.020]   _Pre_Proc               <--- manually trigger to enter sleep mode
      [2025-11-21 16:54:06.462]    Output I/O = PA2       <--- manually trigger to leave sleep mode
      [2025-11-21 16:54:06.462]   _Post_Proc
      [2025-11-21 16:54:06.464]   @ Entered None ISR      <--- Never enter ISR
      [2025-11-21 16:54:06.464] <- wake-up
      [2025-11-21 16:54:06.466]
      
    • LpTIM wake-up

      Configure 5 sec wake-up with LpTIM

      [2025-11-21 16:47:15.315] Nov 19 2025 16:47:12
      [2025-11-21 16:47:15.315] This is an example of Power-Mode (Sleep) and wake-up with LpTIM
      [2025-11-21 16:47:15.321]    Button = PA3
      [2025-11-21 16:47:15.324]    Output I/O = PA2
      [2025-11-21 16:47:19.546] -> enter sleep
      [2025-11-21 16:47:19.546]   _Pre_Proc               <--- enter sleep mode
      [2025-11-21 16:48:26.635]    Output I/O = PA2       <--- wake-up with LpTIM
      [2025-11-21 16:48:26.635]   _Post_Proc
      [2025-11-21 16:48:26.637]   @ Entered LpTim ISR     <--- enter ISR
      [2025-11-21 16:48:26.637] <- wake-up
      [2025-11-21 16:48:26.639]
      
    • WDG wake-up

      Configure 1 sec wake-up with WatchDog

      [2025-11-21 16:36:30.876] Nov 19 2025 16:35:58
      [2025-11-21 16:36:30.876] This is an example of Power-Mode (Sleep) and wake-up with WatchDog
      [2025-11-21 16:36:30.881]    Button = PA3
      [2025-11-21 16:36:30.881]    Output I/O = PA2
      [2025-11-21 16:36:34.050] -> enter sleep
      [2025-11-21 16:36:34.050]   _Pre_Proc               <--- enter sleep mode
      [2025-11-21 16:36:35.098]    Output I/O = PA2       <--- wake-up with WDG
      [2025-11-21 16:36:35.098]   _Post_Proc
      [2025-11-21 16:36:35.101]   @ Entered None ISR      <--- Never enter ISR
      [2025-11-21 16:36:35.101] <- wake-up
      [2025-11-21 16:36:35.102]
      
  • Deepsleep

    • I/O wake-up

      [2025-11-21 16:44:10.823] Nov 19 2025 16:44:07
      [2025-11-21 16:44:10.823] This is an example of Power-Mode (DeepSleep) and wake-up with I/O
      [2025-11-21 16:44:10.828]    Button = PA3
      [2025-11-21 16:44:10.838]    Output I/O = PA2
      [2025-11-21 16:44:13.727] -> enter deepsleep
      [2025-11-21 16:44:13.727]   _Pre_Proc           <--- manually trigger to enter deepsleep mode
      [2025-11-21 16:44:16.085]    Output I/O = PA2   <--- manually trigger to leave deepsleep mode
      [2025-11-21 16:44:16.085]   _Post_Proc
      [2025-11-21 16:44:16.085]   @ Entered None ISR  <--- Never enter ISR
      [2025-11-21 16:44:16.085] <- wake-up
      [2025-11-21 16:44:16.085]
      
    • LpTIM wake-up

      Configure 5 sec wake-up with LpTIM

      [2025-11-21 16:40:38.170] Nov 19 2025 16:40:34
      [2025-11-21 16:40:38.170] This is an example of Power-Mode (DeepSleep) and wake-up with LpTIM
      [2025-11-21 16:40:38.179]    Button = PA3
      [2025-11-21 16:40:38.179]    Output I/O = PA2
      [2025-11-21 16:40:41.607] -> enter deepsleep
      [2025-11-21 16:40:41.607]   _Pre_Proc               <--- enter deepsleep mode
      [2025-11-21 16:40:46.789]    Output I/O = PA2       <--- wake-up with LpTIM
      [2025-11-21 16:40:46.789]   _Post_Proc
      [2025-11-21 16:40:46.791]   @ Entered LpTim ISR     <--- enter ISR
      [2025-11-21 16:40:46.792] <- wake-up
      [2025-11-21 16:40:46.793]
      
    • WDG wake-up

      Configure 1 sec wake-up with WatchDog

      [2025-11-21 16:38:56.627] Nov 19 2025 16:38:53
      [2025-11-21 16:38:56.627] This is an example of Power-Mode (DeepSleep) and wake-up with WatchDog
      [2025-11-21 16:38:56.635]    Button = PA3
      [2025-11-21 16:38:56.635]    Output I/O = PA2
      [2025-11-21 16:38:59.874] -> enter deepsleep
      [2025-11-21 16:38:59.874]   _Pre_Proc               <--- enter deepsleep mode
      [2025-11-21 16:39:00.911]    Output I/O = PA2       <--- wake-up with WDG
      [2025-11-21 16:39:00.911]   _Post_Proc
      [2025-11-21 16:39:00.914]   @ Entered None ISR      <--- Never enter ISR
      [2025-11-21 16:39:00.914] <- wake-up
      [2025-11-21 16:39:00.914]