0:07
hello everyone welcome to controllers
0:11
tech I have already covered sleep mode
0:14
and stop mode today in this video I will
0:19
cover the standby mode in stm32 let's
0:24
take a look at the data sheet these are
0:30
the common steps in other modes - other
0:33
than these the wake up flag must be
0:36
cleared before going to standby mode if
0:39
the RTC is chosen then RTC wakeup flag
0:49
we can exit the standby mode using
0:52
wakeup pin or RTC interrupt or watchdog
1:02
the latency of standby mode is same as
1:05
reset when the MCU wakes up from the
1:10
standby mode the SPF flag in the power
1:13
control register is set we will use this
1:16
fact to perform some operations after
1:19
waking up from the standby let's start
1:22
by creating a project in the cube IDE I
1:32
am using stm32f4 for 6r II controller
1:42
give some name to this project and click
1:45
finish here is the cube MX first of all
1:54
I am selecting the external crystal for
1:57
the clock enable the UART for
2:06
communicating with the computer pa5 is
2:14
connected to the led enable the wake-up
2:20
pin let's go to the clock setup I have
2:26
eight megahertz external crystal and I
2:28
want the system clock of 180 megahertz
2:40
click Save to generate the project
2:59
when the MCU wakes up all these will be
3:09
to confirm if the system was resumed
3:11
from standby mode we will check this SV
3:14
flag if the flag is set means the MCU
3:18
woke up from the standby mode
3:43
first thing we will do is clear the flag
3:54
next we will display this string on the
4:15
and then toggle the LED few time with
4:40
disable the wake-up pin wake-up pin one
4:48
is common in all MCU wakeup pin two and
4:53
three are supported by these
4:55
microcontrollers only I am using wakeup
4:59
pin one as its present in all the MCU
5:01
and it is the pin PA zero
5:21
now this is the procedure to enter the
5:24
standby mode as mentioned in the
5:28
datasheet we must clear the wake up flag
5:30
before entering the standby
5:51
I am going to display this string blink
5:55
the LED for the indication this blinking
5:59
rate is different from the initial one
6:02
we must enable the wake-up pin before
6:19
just to make sure now finally enter the
6:43
include the string dot H file for string
6:47
related operations let's build this code
6:53
I am going to use the debugger
7:25
as you can see when I press the reset
7:29
the string got printed on the console
7:31
LED blinks at 750 milliseconds delay and
7:35
the MCU goes into the standby mode when
7:39
the button is pressed the MCU wakes up
7:42
and string got printed and LED blinks at
7:45
200 milliseconds to indicate the wakeup
7:48
same thing happens if I press the button
8:04
we can also use the RTC to wake the
8:07
device up I have already covered the RTC
8:11
set up in my stop mode video in RTC wake
8:15
up select internal wake up make sure you
8:19
turn on the interrupts leave everything
8:22
as it is we don't need to set the time
8:25
this is a periodic wakeup and setting
8:28
time doesn't affect it
8:38
now go to the RTC initialization
8:41
function and copy this function also
9:00
just like we enabled the wake-up pin we
9:03
are also going to enable the RTC wakeup
9:05
inside the main function I have already
9:13
explained this calculation in my sleep
9:15
mode video you can check it out on the
9:20
anyway this calculation is self
9:22
explanatory I am using the periodic
9:26
delay of 5 seconds here
9:28
as mentioned in the datasheet if we are
9:31
using RTC to wake the MCU up we need to
9:34
clear the RTC wake-up flag also
9:44
after wake up just like disabling the
9:47
wake-up pin we must also deactivate the
10:06
let's build this code and run it you can
10:15
see the current consumption on the
10:17
ammeter also right now the range is set
10:20
at 200 milliamps when the device is
10:24
running normally the consumption is
10:26
around 36 milliamps but when it goes
10:30
into the standby mode it's showing zero
10:34
let me reduce the range to 2 milliamps
10:37
now you won't be able to see the higher
10:40
range but you can see the current during
10:44
yes it's around point zero zero two
10:48
milliamps which is 2 micro ampere this
10:52
is extremely low consumption the MCU is
10:55
waking up every 5 seconds because of the
10:58
periodic wake up of RTC we can also use
11:02
the wake-up pin to wake the controller
11:18
you can see the SPF flag and w UF flag
11:23
described in the datasheet now all three
11:26
low power modes are covered in stop mode
11:30
there is one feature called under drive
11:32
mode it's not present in cortex m3 and
11:36
maybe in other series also but its
11:40
present in f4 for 6r II and I will cover
11:43
it in few days you can use these low
11:47
power modes according to your
11:49
application this is it guys I hope you
11:53
understood the video you can download
11:56
the code from the link in the
11:58
description have a nice day