1.. zephyr:code-sample:: stm32_pm_serial_wakeup
2   :name: Serial wakeup
3   :relevant-api: subsys_pm_device
4
5   Wake up on serial activity on STM32.
6
7Overview
8********
9
10This sample is a minimum application to demonstrate serial wakeup functionality
11in low power context.
12
13.. _stm32-pm-serial-wakeup-sample-requirements:
14
15Requirements
16************
17
181. The board should support enabling PM. For a STM32 based target, it means that
19it should support a clock source alternative to Cortex Systick that can be used
20in core sleep states, as LPTIM (:dtcompatible:`st,stm32-lptim`).
21
222. The serial port used by the shell should be configured, using device tree, to
23be a functional wakeup source:
24
25  - Clocked by an oscillator available in Stop mode (LSE, LSI) or an oscillator capable
26    that can be requested dynamically by device on activity detection (HSI on STM32WB).
27  - Matching oscillator sources should be enabled
28  - If LSE is selected as clock source and shell serial port is a LPUART current speed
29    should be adapted (9600 bauds)
30  - Port should be set as "wakeup-source"
31
32Note: Using HSI clock is a specific
33
34Building and Running
35********************
36
37Build and flash this sample as follows, changing ``nucleo_wb55rg`` for a board
38configured to be compatible with this sample.
39
40.. zephyr-app-commands::
41   :zephyr-app: samples/boards/st/power_mgmt/serial_wakeup
42   :board: nucleo_wb55rg
43   :goals: build flash
44   :compact:
45
46After flashing, the shell is enabled and device enter sleep mode.
47User is able to wake up the device by typing into the shell
48
49PM configurations
50*****************
51
52By default, :kconfig:option:`CONFIG_PM_DEVICE` and :kconfig:option:`CONFIG_PM_DEVICE_RUNTIME`
53are enabled, but user can also deactivate both or former to see each configuration in play.
54
55Debugging
56*********
57
58:kconfig:option:`CONFIG_DEBUG` could be enabled to allow debug. Note that debug mode prevents
59target to reach low power consumption.
60Also note that after debug mode has been disabled, target should also be powered off in order
61to get back to normal mode and reach low power consumption.
62
63PM measurements on stm32l562e_dk using stm32l562e_dk PM shield
64**************************************************************
65
66Plug Power shield
67Plug ST-Link
68Set JP4 To 5V ST-Link
69Set SW1 to PM_SEL_VDD
70STM32Cube PowerMonitor settings to be applied:
71
72  - Sampling Freq: max
73  - Functional Mode: High
74
75Optimal configuration for low power consumption
76***********************************************
77
78In order to reach lower power consumption numbers following parameters should be taken
79into account:
80
81  - Use a LPUART instead of a basic U(S)ART node
82  - Chose LSE as clock source
83  - Ensure no other oscillators are enabled (disable HSI, ...)
84  - Provide "sleep" pinctrl configuration to other uart nodes.
85  - Disable Debug mode
86
87 With all these conditions matched, one can reach 10uA on stm32l562e_dk with this sample.
88