AN3269 STMICROELECTRONICS | Alldatasheet
Document overview
- Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
- PDF pages: 19
Technical content
Datasheet sections
- 1 Application description
- 1.1 Hardware required
- 1.2 STM8L-DISCOVERY hardware settings
- 1.3 Application schematics
- 1.4 Application principle
- 1.4.1 Overview
- 1.4.2 I DD measurement principle
- 1.5 Getting started with the application
- 1.5.1 Demo mode (I DD measurement)
- 1.5.2 Bias current record
- 1.5.3 Manufacturing test
- 1.6 Low power modes
- 2 Software description
- 2.1 STM8L peripherals used by the application
- 2.2 STM8L15x standard firmware library configur ation
- 2.3 Application software flowcharts
- 2.3.1 Main application flowchart
- 2.3.2 Demo mode (I DD measurement)
- 3 Conclusion
- 4 Revision history
September 2010 Doc ID 17904 Rev 1 1/19 AN3269 Application note Introduction to STM8L15x power saving modes using the STM8L-DISCOVERY IDD measurement feature Introduction This application note introduces some of the power saving modes available in the STM8L microcontroller family. The STM8L-DISCOVERY has a built-in IDD measurement feature that is used to demonstrate the real capabilities of the STM8L15x microcontroller’s low power modes. This application does not require any additional hardware. Once the STM8L-DISCOVERY is powered-up through a USB cable connected to the host PC, the application is ready to dynamically display the STM8L power consumption in each of the different modes selected by the user. This software example comes preloaded with your STM8L-DISCOVERY and is readily accessible at application power-up. Reference documents ■ STM8L-DISCOVERY evaluation board user manual (UM0970) ■ STM8L-DISCOVERY software user manual Developing and debugging your STM8L- DISCOVERY application code (UM0991) ■ Application note STM8L family power management (AN3147) The above documents are available at http://www.st.com.
1 Application description
1.1 Hardware required
1.2 STM8L-DISCOVERY hardware settings
current record operation, see Section 1.5.2). Note: All solder bridges SB11 to SB17 must be shorted (bottom side of STM8L-DISCOVERY).
1.3 Application schematics
Figure 1 shows the application electrical schematics. Figure 1. Application schematics
1.4 Application principle
1.4.1 Overview
- Run mode
- LPR (Low power run mode) with LCD display ON
- LPR (Low power run mode) with LCD display OFF
- Halt mode The user reads the value displayed on the STM8L-DISCOVERY’s LCD panel, to know how much power the device is currently consuming. With this demonstration, you can obtain a precise and dynamic measurement of the STM8L152 supply current depending on the low power mode used. It also includes a manufacturing test mode for performing a quick diagnosis of the STM8L- DISCOVERY related to this application example. See Section 1.5.3: Manufacturing test to have details regarding the test activation and meaning.
1.4.2 I DD measurement principle
Figure 2. I
converts the resulting voltage, image of the consumption current. 150 ms delay controlled by the K2 switch. capacitor (C) intact while the microcontroller is in low power mode. current (see Section 1.5.2: Bias current record). DISCOVERY evaluation board user manual (UM0970).
1.5 Getting started with the application
- Demo mode (IDD measurement)
- Bias current record
- Manufacturing test Demo mode is available at application power-up while the two other ones are called by the user according to a specific procedure that is detailed later in this chapter. However, for best performance, it is recommended to control and record the Bias current before starting precise I DD measurement displays.
1.5.1 Demo mode (I DD measurement)
voltage applied to the STM8L device. are displayed, both LEDs are turned off. Figure 3. Each function consists of configuring the device with any required settings and then measuring and displaying the result on the LCD panel.
Figure 3. Function Change state diagram display the power consumption value. Table 1. Bars and LCD display linked to functions
1.5.2 Bias current record
This operation consists of storing in memory the value of the bias current inherent to operational amplifier A (see Figure 2) of your STM8L-DISCOVERY . The bias current value is taken into account for low power measurements in order to minimize measurement errors. Once recorded, this value does not need to be refreshed and is kept in non-volatile memory for future use. It is recommended to perform this operation when you start your evaluation in order to obtain the best precision. This mode is only accessible at application power-up by executing the following actions in the order below:
- Switch OFF STM8L-DISCOVERY
- Place JP1 in OFF position (IDD measurement disabled)
- Maintain USER push-button pressed while switching ON the STM8L-DISCOVERY
- At power on, a scrolling message “Bias Current” is displayed
- Release the USER push-button; the bias current value is displayed and immediately stored in non-volatile memory Once this operation completed, replace JP1 in ON position so that the measurement circuitry connects again to STM8L152 (IDD measurement enabled).
1.5.3 Manufacturing test
Y ou can access this mode while Demo mode is running, by pressing the USER push-button for more than 3 seconds and by releasing it. This allows you to verify that the hardware modules needed by the STM8L-DISCOVERY for this example are working properly. In this mode, application checks the LSE oscillator (Low Speed External), V DD voltage value, IDD RUN, IDD HALT and LP (low power) IDD currents. The currents are tested with lower and upper limits. For each test function, the application displays “OK” and the measured values when available. If all checks are successfully completed, then the message “TEST OK” is continuously displayed. If one of the tests fails, then the application alerts the user by continuously displaying the test name followed by “NO OK”. To exit this manufacturing test, press the RESET button. Note: Generally, if the manufacturing test is not successful, first check that JP1 is placed in the ON position and that solder bridges SB11 to SB17 are shorted. If errors are found in the Low power and Halt modes I DD measurements, the bias current record operation should be performed again.
1.6 Low power modes
The low power modes used in this application example are:
- Low power run mode (with or without LCD): In this mode the CPU and some of the peripherals are running. As selected, the LCD can be used or not. In the latter case, the LCD and the RTC clock are disabled to save power and GPIOs are placed in output push-pull configuration to limit consumption. During Low power run mode, the code is executed from RAM and CPU is clocked by the LSI oscillator. Flash and data EEPROM are stopped and the voltage regulator is configured in Ultra low power mode. The
microcontroller can be woken up from this power saving mode by an external event generated by a GPIO.
- Halt mode: CPU, oscillator and peripherals are stopped, device remains powered on. Voltage regulator is configured in Ultra low power mode. Device wakeup is done with external interrupt. For further information, please refer to STM8L family power management (AN3147).
AN3269 Software description Doc ID 17904 Rev 1 11/19
2 Software description
2.1 STM8L peripherals used by the application
This application example uses the following STM8L peripherals with the settings described below: ADC ADC performs analog-to-digital conversions of the internal reference voltage (V DD voltage display) and of the voltage coming from the operational amplifier that is the image of IDD current.
- ADC resolution: 12-bit
- ADC conversion mode: single
- ADC sampling time: 9 cycles TIM4 TIM4 is used to generating the delays needed for display or wait loops. GPIOs Port C and Port E are connected to the USER push-button and the LEDs.
- PC1 set as an input floating pin with interrupt (USER push-button)
- PC7 and PE7 set as an output push-pull pin (LD4 and LD3 LEDs respectively)
- PE6 set as an input floating pin with interrupt (IDD Wakeup) with detection on rising edge
- During the low power modes, I/Os are placed in output push-pull to reduce power consumption except for a few pins related to the hardware interface (buttons, PF0 I DD measurement pin, PE6 LP WakeUp pin and PC4)
- All Schmitt triggers on standard I/O pins are disabled to reduce power consumption
- The Schmitt trigger on PF0 is disabled in order to avoid measurement errors LCD controller The different functions available in the firmware library for LCD are used to initialize, clear, display strings and scrolling messages needed in the application code. For some low power mode measurements, the LCD controller is turned OFF to minimize the current consumption of STM8L152. Clock The HSI (high speed internal) 16 MHz oscillator is selected as clock source. The application manages the peripheral clocks depending on the selected power saving mode. When the device enters low power run mode, HSI is switched OFF and LSI acts as the main clock source until the device is woken-up by an external event. When exiting Low power run mode, the device switches the HSI oscillator back ON. On the other hand, LSE is switched ON during Manufacturing test mode (see Section 1.5.3).
2.2 STM8L15x standard firmware library configuration
The stm8l15x_conf.h file of the STM8L standard firmware library allows you to configure the library by enabling the peripheral functions used by the application.
2.3 Application software flowcharts
2.3.1 Main application flowchart
Figure 4. Main application flowchart
needs to be restarted by pressing the RESET button.
2.3.2 Demo mode (I DD measurement)
the USER pushbutton (as described in Section 1.5.1).
- Configuring the device according to the selected power mode
- IDD measurement and display (this part is common for all power modes) The Demo mode sequence is as follows:
Figure 5. Demo mode sequence
Figure 6. Measurement and display flowchart average value is computed at the end before to be converted and displayed on LCD. DD measurement and display routine.
Figure 7. Low power run mode flowchart
Figure 8. Halt mode flowchart
3 Conclusion
A multitude of new mobile, communications-based, wireless, entertainment and computing applications being developed for tomorrow’s markets need more and more performance and longer times between battery recharging. STM8L both combines high performance core and ultra-low-power consumption modes. This example allows you to evaluate the current consumption of the STM8L microcontroller in various operating conditions and to demonstrate its low-power capabilities by directly providing the consumption value to STM8L-DISCOVERY users on the LCD panel. With this example, STM8L-DISCOVERY provide a very low cost environment that can be used for additional development projects where device consumption and application autonomy take on their full meaning. It can be a useful starting point that can easily expanded to investigate other aspects of the user’s target application.
4 Revision history
Table 2. Document revision history