STM32 Power Management

Source: Internet
Author: User



(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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.