(1) 3: mode
① sleep mode ② stop mode ③ Standby mode
1. Sleep mode: CORTEX-M3 core (understood as CPU) stop working, CPU powered 1.8V has, around any execution. Perform
2. Shutdown mode: All clocks are stopped, CPU power 1.8V is not broken. Run from original location after wake up
3. Standby mode: Clock all off, CPU power 1.8V also broken, wake up after the program run again
Can be the image of the test:
CPU: The Emperor
CPU Power 1.8V: Queen
Peripherals: General
So:
1. Sleep mode: Only the Emperor sleeps
2. Shutdown mode: The Emperor, the general sleeps
3. Standby mode: The Emperor, the Queen. The general is all asleep.
(principle: The Queen does not sleep, the program can be retained, wake up from the original location to run)
(b) Procedure Brief introduction (library function)
1. Sleep mode
while (1) {/* wait interrupt */led1 (ON);D Elay (0xFFFFF); LED1 (OFF); LED2 (on); Delay (0xFFFFF); LED2 (OFF); LED3 (on); Delay (0xFFFFF); LED3 (OFF); __wfi ();}
__wfi (); Go to sleep mode and interrupt wake-up at random. No more clock configuration after wake-up
2. Stop mode
①/* due to the use of its peripheral clock. It needs to be pwr*/.
②/* Enable power management Unit Clock */
Rcc_apb1periphclockcmd (RCC_APB1PERIPH_PWR, ENABLE);
③ Enter stop mode
Pwr_enterstopmode (PWR_REGULATOR_LOWPOWER,PWR_STOPENTRY_WFI);
④ Wakeup: External interrupt
Since the general sleeps, (and the peripheral clock is turned off, so it needs to be configured again) after wake up need to start HSE again
Sysclkconfig_stop ();
void Sysclkconfig_stop (void) {ErrorStatus hsestartupstatus; /* Enable HSE * /Rcc_hseconfig (rcc_hse_on); /* Wait for HSE to be ready * /Hsestartupstatus = Rcc_waitforhsestartup (); if (Hsestartupstatus = = SUCCESS) {/ * Enable PLL * /Rcc_pllcmd (enable); /* Wait for the PLL to be ready * /while (Rcc_getflagstatus (rcc_flag_pllrdy) = = RESET) { }/ * Select PLL as the system clock source * / Rcc_sysclkconfig (RCC_SYSCLKSOURCE_PLLCLK); /* Wait for the PLL to be selected as the system clock source * /while (Rcc_getsysclksource ()! = 0x08) { } }}
3. Standby mode
①/* due to the use of its peripheral clock, etc., it needs to pwr*/
②/* Enable power management Unit Clock */
Rcc_apb1periphclockcmd (RCC_APB1PERIPH_PWR, ENABLE);
③ into Standby mode
/* Enable the Wkup pin wake-up function, Wkup is the second function. Do not configure its output mode (not too understand) */pwr_wakeuppincmd (ENABLE);/* Enter Standby mode */pwr_enterstandbymode ();
④ Wakeup, reset wakeup. PA0 Rising Edge Wake Up
⑤ detection is reset wakeup or PA0 rising edge wake Up
if (Pwr_getflagstatus (pwr_flag_wu) = = SET) {printf ("\ r \ n PA0 rising edge wake \ r \ n");} else printf ("\ r \ n other \ r \ n");
Since the standby wakeup program runs from the beginning, it is not necessary to configure the clock function.
A madman with a brain
Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.
STM32 Power Management