1. Power consumption control adjustment
1. Hardware function adjustment
2. Software function adjustment
3. Experience
3.3V power supply is more energy-efficient than 5V
HSI saves more power than HSE
The lower the crystal frequency, the more power it saves
Reading and writing RAM saves more power than FLASH
On-chip resources affect power consumption, and those not in use should be turned off using the PCG function.
2. Power Management
How to enter the mode?
Enter wait mode: asm("WFI");
Enter active shutdown mode: asm("HALT"); // Enable AWU and execute this statement to enter active shutdown mode
Entering the shutdown mode: asm("HALT"); //If AWU is not enabled, executing this statement will cause the system to enter the shutdown mode.
3. Automatic wake-up AWU structure and configuration
Automatic wake-up unit for MCU active stop mode,
1. Clock source
AWU can choose two clock sources: LSI and HSE
Selected by the "CKAWUSEL" bit in option byte OPT4:
Set to 0 ==》LSI (default);
Set to 1 ==》HSE.
2. Clock source frequency division coefficient
Select by the "PRSC[1:0]" bits in option byte OPT4:
Through the settings of steps 1 and 2, a rough clock LS is obtained.
3. Correct the clock frequency (not often used)
Use the "MSR" bit in the AWU_CSR control/status register and the input capture channel 1 of TIM3 or TIM1 to detect the clock frequency of LS. If an error is found, reconfigure APR[5:0] in the asynchronous prescaler AWU_APR to correct the timing.
4. Configure asynchronous prescaler
Configure the APR[5:0] in the asynchronous prescaler AWU_APR to configure the appropriate division value
APR: Prescaler factor
5. Write time base selection register
Write AWUTB[3:0] in the time base select register AWU_TBR to select the required automatic wake-up delay interval
AWUTB: Time interval
How to set it up?
Refer to this table:
For example, if we want to set a 6ms timing, we can find: AWUTB=0101
According to the calculation formula: 3 seconds =
Where fLS=128000, we can calculate: APR=48
Check the APR table again
Determine that APR should be assigned a value of 2E
6. Control bit enable
Set the AWUEN bit in the Control/Status Register (AWU_CSR)
7. Execute the HALT command to enter active shutdown
asm("HALT");
The four specific operations are as follows
① Turn on LSI and set the fast wake-up function at the same time. Both functions are in the CLK_ICKR register.
CLK_ICKR|=0x0C; //Turn on LSI clock and enable fast wakeup from active stop mode
② Determine whether the FLASH is powered off after entering active shutdown
FLASH_CR1&=0x0B; //Flash does not power down in active stop mode
③ Set the prescaler value
AWU_APR=0x26; //Configure pre-scaling value
④ Set the AWU wake-up time interval
AWU_TBR=0x0C; //Configure AWU wake-up time interval
⑤ Enable AWU
AWU_CSR1|=0x10; // Enable "AWUEN" to start AWU
⑥ Enter active shutdown mode
asm("HALT");
⑦ If you write an active shutdown wake-up interrupt, it will be triggered when waking up, so you should write an interrupt response function
#pragma vector=3
__interrupt void AWU_IRQHandler(void) //Automatically wake up AWU interrupt function
{
//Write the interrupt response function here
AWU_CSR1|=0x10; //Continue to enable AWU
//asm("HALT");
}
The first few steps can be written as an initialization function: AWU_init()
void AWU_init(void)
{
CLK_ICKR|=0x0C; //Turn on LSI clock and enable fast wakeup from active stop mode
FLASH_CR1&=0x0B; //Flash does not power down in active stop mode
AWU_APR=0x26; //Configure pre-scaling value
AWU_TBR=0x0C; //Configure AWU wake-up time interval
AWU_CSR1|=0x10; // Enable "AWUEN" to start AWU
}
Previous article:STM8 library function development manual (1) //Project template, GPIO, clock
Next article:STM8 internal memory structure and programming
Recommended ReadingLatest update time:2024-11-16 12:00
- Popular Resources
- Popular amplifiers
- STM8 C language programming (1) - basic program and startup code analysis
- Description of the BLDC back-EMF sampling method based on the STM8 official library
- STM32 MCU project example: Smart watch design based on TouchGFX (8) Associating the underlying driver with the UI
- uCOS-III Kernel Implementation and Application Development Practical Guide - Based on STM32 (Wildfire)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Submit your work --- Childish posture reminder
- EEWORLD University Hall----Live Replay: TI takes you to experience the interconnected and efficient smart home solution
- Thank you all for your help. Thank you very much.
- Array sorting problem
- Robust Design of I2C Serial EEPROM Application System.pdf
- Original 100KWh Solar Photovoltaic Off-Grid Battery Management System
- What are some good ways to reverse check silk screen printing? Welcome to chat and share your experience
- Upgrade the embedded RISC-V compiler
- [HC32F460 Development Board Review] 02. Build the development environment, create a project, and implement the LED flashing function
- DCDC ripple experiment