 Bienvenue à la mode haute-mode. Dans cette mode, nous allons parler de la mode haute-mode de la JZO. Dans cette mode, nous allons faire un lab, qui va mettre le microcontourage dans une mode haute-mode, qui s'appelle Stop One Mode, et wake-up avec le RTC, qui est la clé de temps réel qui est configurée pour wake-up la JZO chaque 5 secondes. Donc quand la JZO s'éteint, nous allons éteindre la LED pour un second et ensuite retourner au stop-mode. Nous avons aussi le user-button, donc la LED qui est connectée à l'user-button est configurée en extérieur interruptant et nous avons la capacité de wake-up la JZO de stop-mode. Les JZO de la JZO featuring FlexPowerControl, qui augmente la flexibilité en mode PowerManagement et réduisit la consumption d'applications. Run Mode can support a system clock running up to 64 MHz with only 100 MHz. At 16 MHz the consumption is even lower, 93 MHz. The SMA2 G0 devices support 7 main low power modes, low power run, sleep, low power sleep, stop-zero, stop-one, stand-by and shutdown modes. Each mode can be configured in many ways providing several additional sub-modes. In addition, the SMA2 G0 devices support a battery backup domain called VBAT. So the high flexibility in power management provide both high performance with a core mark score equal at 142 together with an outstanding power efficiency. The SMA2 G0 devices feature two stop-modes, stop-zero and stop-one, which are the lowest power modes with full retention and only 2 microseconds wake up time to run mode at 60 MHz. The contents of SRAM and peripherals registers are preserved in stop-modes. All high-end clocks are stopped. The 32 kHz external oscillator and the 32 kHz internal oscillator can be enabled and several peripherals can be active and wake up from stop-mode. The voltage regulator is configured is main regulator mode in stop-zero mode. So all the clocks in V-core domain are stopped in this mode. The PLL, the HSI-16 and the HSC oscillators are disabled. The RTC clocked by the internal or external low-speed oscillator can remain active. The BOR, so the brown-outry set is always enabled. Most of the peripherals' clocks are gated off but several peripherals are still functional in stop-zero mode. Now let's talk about the stop-1 mode. So stop-1 mode is the mode we're going to use during our lab. So the stop-1 mode is very similar to the stop-zero mode that we saw just before except that the power figures are much lower. As the main regulator is stopped and replaced by low-power regulator. So the stop-1 mode consumption without RTC is 1.3 microamp. Typical, at 3 volts we flash not powered and RTC disabled. The wake-up time is 5 microseconds with HSI-16 megahertz as system clock at wake-up. Regulator in mode 1 or 2. The flash memory as well as the HSI-16 are configurable. They can be stopped or kept enabled. So because we're going to use the RTC microcontrollers, I'm going to give you a quick overview about the RTC, so the real-time clock. So the RTC peripheral features an ultra-low-power calendar with alarms, which run in all the low-power modes. Additionally, when it is clocked by the low-power external oscillator, the LSE, at 32 kHz the RTC is functional even if the main power is off. So when VBAT domain is supplied by a backup battery on VBAT. The RTC consumes only 300 nm at 1.8 volts, including the LSE power consumption. The hardware calendar is provided by BCD format in our calendar which reduce the software load particularly when the date and time must be displayed. The backup registers and temperature detection belong to the temp peripheral. Ok, so now it's time for the lab. So, the low-power lab. So, first of all, we're going to close KM5 and from STM5 to QBMX we're going to open the EXTI project that we previously created and we're going to rename it as low-power. So I'm going to exit from KM5 in STM5 to QBMX I'm going to rename the project to low-power. The first step will be to enable the LSE which is the low-speed external clock. So, on the board on the nuclear board, you have a 32 kW that is connected to PC14 and PC15. So, we're going to use this to clock the RTC. So, now in STM5 to QBMX in the pinout and configuration tab we're going to expand the RCC which is located in the system core et we're going to choose the crystal ceramic resonator for LSE clock. So, this will enable on your pinout the pin PC14 and PC15. So, in STM5 to QBMX in the pinout and configuration tab I'm going to open or expand system core in RCC for LSE I'm going to select and ceramic resonator. So, now on my pinout PC14 et PC15 are being configured with alternate functions OSC32 in and out. The next step will be to enable and configure the RTC. So, in the pinout and configuration tab under timers we're going to expand RTC located here. Now, we're going to activate the clock source. So, by clicking activate clock source we're going to select internal wake up for wake up mode. Under timers I'm going to select RTC I'm going to click on activate clock source and for the wake up I'm going to select internal wake up. Now, we're going to choose the RTC clock source. So, in the clock configuration tab we're going to select LSE as input for the RTC as you can see here. So, in the clock configuration tab I'm going to select LSE to clock the RTC clock. Now, we're going to configure the RTC. So, the wake up counter calculation is as follow. So, we want a wake up time to be 5 seconds. So, the wake up counter will be programmed to 10246. So, the calculation is as below. So, with RTC clock set to RTC divided by 16 the wake up time base will be RTC pre-scalor divided by LSE. So, this means 16 divided by 32 kilohertz which is equivalent to 0.488 milliseconds. So, the wake up time equal wake up time base multiplied by wake up counter equals 0.488 milliseconds multiplied by the wake up counter. So, the wake up counter equal 5 seconds divided by 0.488 milliseconds. So, this is 10246. Now, we're going to configure the RTC in QMX. So, in the pinout configuration tab we're going to click on RTC and for the parameter settings of the RTC in the configuration settings we're going to input the following information. So, for the wake up clock we're going to enter RTC clock divided by 16 and for the wake up counter 10246 as we calculated the slide before. I'm going to pinout configuration tab going back to the RTC in the configuration settings I'm going to go to the parameter settings I'm going to enter RTC clock divided by 16 and here 10246. Now, we're going to enable the interrupts so, first in the configuration tab in the NVIC settings we're going to enable the interrupt for the RTC and then in the system view we're going to click on NVIC and we're going to make sure that the RTC and the XTI 4215 are enabled as shown here. So, I'm going to go to NVIC settings enable the RTC interrupt now, in the system view I'm going to go to the NVIC and make sure that both the RTC and the XTI line 4215 are enabled. We can now generate the code and once the window code generation is visible we can open the project. I'm going to generate the code and now I'm going to open the project by clicking on open project. We're going to add some code so, first in main.c in the user code Y section so, in the Y loop we're going to first have three lines of code for the run mode so, for one second we're going to turn on the LED after that, we enter the stop mode and when we wake up from the stop mode we need to reconfigure the clocks so, the code to add is also in the description of the video that you can find in this video or in the comments I'm going to add the code in my main.c in the Y loop right here I'm adding the code so, this code is located in the description of the video so, you can copy and paste it in the user code begin while section so, in the previous STM32 QBMX version so, we were missing one clock to be enabled so that, you know the RTC code will work properly so, basically we have to verify that this clock which is this in red, right there, the RTC APB clock is enabled in the function HAL underscore RTC underscore MSP init so, which is located in this file to G0 XXX underscore HAL underscore MSP.C let's verify that the clock has been enabled so, this is located in this file right here so, this STM32 G0 XXX underscore HAL underscore MSP.C I'm going to scroll down and check that in the HAL underscore RTC underscore MSP init the clock RTC APB is enabled so, if not, please add it same thing I added the code to be added in the description if needed so, please save now all the files and we're going to build the code remember, with the icon right here or F7 and once the code is built we're just going to load the code so, to load the code it's F8 or there is an icon like this so, this is the load icon so, why? because we're losing low power modes and if we were entering a debug session and running from a debug session we would lose the communication with the debugger when the micro enters in low power mode so, we're just going to load the code once the code is loaded on the reset button on the board and make sure that the code is following, you know, the spec that we wanted which is running for 1 second so, which is run mode for 1 second stop mode for 5 seconds and wake up with RTC and during the time the micro is in stop mode we can press the user button and wake it up from stop mode so, now I'm going to build the code so, once the code is built 0 error 0 warning I can now load the code so, you're going to load the code using download so, you're using this load button right here so, now the code is loaded I can now press on the reset button on my nuclear board and make sure that the application code is running as expected so, for 1 second the LED is on, so this is run mode and then for 5 seconds the LED is off so, this is the stop mode and then we wake up with RTC after 5 seconds and during the time the micro is in stop mode if I press on the user button I will wake up the micro directly and the light will be on