STM8 power mode management and power consumption control

Publisher:SunshineHopeLatest update time:2021-02-06 Source: eefocusKeywords:STM8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

}


Keywords:STM8 Reference address:STM8 power mode management and power consumption control

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

STM8 Learning—LED
No matter what you learn, you must start with the simple things first. Driving the small lights will be the first lesson for learners. To make the small lights flash, you need to configure the status of the IO ports to let the IO ports output high and low levels at intervals. The interval time is at the ms level, other
[Microcontroller]
stm8 clock
There are 4 types of stm8 clock sources: 1. 16MHz high-speed internal clock source HSI 2. 1 to 16MHz high-speed external clock source HSE 3. 32.768KHz low-speed external clock source LSE 4. 38KHz low-speed internal clock source LSI These 4 clock sources can be used as system clocks. You can also use an oscilloscope t
[Microcontroller]
IAR - IAR FOR STM8 Installation
IAR for STM8 is an embedded work platform, mainly used in the development of STM8 series chips. Now (version 3.10 in 2018) it can support all STM8 chips on the market. Different IAR platforms require different installation software. The software has been uploaded and can be downloaded from the blog. The following is
[Microcontroller]
IAR - IAR FOR STM8 Installation
STM8 hardware PWM settings
I've been playing around with STM8 recently, learning and using it, and I found that there are many things I don't understand. I wrote this blog to record my experience of using PWM to control the speed of the motor in the past few days, and also to keep a technical archive for future use. 1. Initialize the timer
[Microcontroller]
STM8 interrupt vector table
// Copyright (c) 2009, Wolver Wang, Innov Inc. R&D Center // wolver@21com.com // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above cop
[Microcontroller]
STM8 Study Notes---Read the STM8S003 MCU serial number
I recently needed to use the serial number of the microcontroller when doing a project, so I looked up the method of reading the UID of the STM8S003 microcontroller. There are two ways to read the UID, one is to read it directly from the address, and the other is to define a union, set the starting address of the unio
[Microcontroller]
STM8 AWU registers
Control/Status Register (AWU_CSR) Address offset value: 0x00 Reset value: 0x00 Position 7:6 Reserved bit, must remain 0 Bit 5 WUF: Automatic wake-up flag This bit is set when the automatic wake-up module generates an interrupt and is cleared by reading AWU_CSR. Writing does not affect the value of this bit 0: No a
[Microcontroller]
STM8 AWU registers
STM8 STM8S208MB registers
Pin Type register The STM8S208MB register uses the LQFP80 package. The 80 here means that there are 80 pins, of which 68 are GPIO pins. According to the GPIO port function classification, they are PA group has 6 GPIO ports (PA1-PA6) PB group has 8 GPIO ports (PB0-PB7) There are 8 GPIO ports in the PC group (PC0-P
[Microcontroller]
STM8 STM8S208MB registers
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号