ST AN3413 Application note

AN3413

Application note

STM32L-DISCOVERY: current consumption measurement and touch sensing demonstration

Introduction

This application note provides an overview of the demonstration firmware delivered with the STM32L-DISCOVERY evaluation board. It allows you to explore the rich set of power saving modes available in the STM32L microcontroller by using the STM32L-DISCOVERY embedded IDD measurement circuit that is used to demonstrate the real capabilities of the ultra low power microcontroller STM32L.

The demonstration application does not require any additional hardware. Once the STM32L-DISCOVERY is powered-up through a USB cable connected to the host PC, the application is ready to display the STM32L power consumption of each low-power modes selected by the user.

In addition the demonstration firmware allow you to explore touch sensing capabilities of STM32L microcontroller demonstrated by sensing of linear touch sensor or set of four touchkeys.

Reference documents

STM32L-DISCOVERY evaluation board user manual (UM1079)

STM32L151xx and STM32L152xx Flash and EEPROM programming (PM0062)

The above documents are available at http://www.st.com.

July 2011

Doc ID 018933 Rev 1

1/18

www.st.com

Contents

AN3413

 

 

Contents

1

Application description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

 

1.1

Used hardware components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

 

1.2

STM32L-DISCOVERY hardware settings . . . . . . . . . . . . . . . . . . . . . . . . .

3

 

1.3

Application schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3

 

1.4

Application principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

4

1.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4.2 IDD measurement principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5 Getting started with the application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.5.1 Demo mode - Touch sensing demonstration and IDD measurement . . . . 6 1.5.2 Bias current record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 1.5.3 Manufacturing test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1.6 Low power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2

Software description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

10

 

2.1

STM32L peripherals used by the application . . . . . . . . . . . . . . . . . . . . . .

10

 

2.2

STM32L15x standard firmware library configuration . . . . . . . . . . . . . . . .

11

 

2.3

Application software flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11

2.3.1 Main application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.3.2 Demo mode (IDD measurement) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3

Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

16

4

Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

17

2/18

Doc ID 018933 Rev 1

AN3413

Application description

 

 

1 Application description

1.1Used hardware components

This application example uses the hardware components available on STM32LDISCOVERY; on-board LEDs (green LD3 and blue LD4), the 6-digit/4-bar LCD glass display, the user push-button and touch sense slider. No additional components are required.

1.2STM32L-DISCOVERY hardware settings

 

The IDD jumper JP1 must be placed in position ON for standard operation (except for bias

 

current record operation, see Section 1.5.2).

 

Both jumpers on CN3 must be fitted to allow communication of STM32L15x with ST-Link

 

debugging tool thru SWD interface.

Note:

All solder bridges must be in the default state as described in UM1079.

1.3 Application schematics

Figure 1 shows the simplified application electrical schematics.

Figure 1. Application schematics

)$$$MEASUREMENTSCIRCUITRY

 

0!

0!

0#

 

0"

 

0!

2

 

 

 

 

 

Ȱ

 

 

 

,$

34- , 2"4

'REEN

0"

 

 

 

 

 

 

2

 

 

 

Ȱ

 

 

,$

,#$#CONTROLLER

"LUE

,#$#/-; = ,#$3%'; =

 

 

 

 

"!2

6$$ 5SER PUSH BUTTON

#

N&

2

4OUCH SENSING

 

 

 

 

 

 

K Ȱ

 

 

 

 

 

 

LINEAR SENSOR

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PB0..1, PC4..5,

PA6..7

,#$

-3 6

Doc ID 018933 Rev 1

3/18

Application description

AN3413

 

 

1.4Application principle

1.4.1Overview

STM32L-DISCOVERY includes specific analog and logic hardware that is connected to STM32L152 microcontroller and which is intended to measure and display the supply IDD current when the device is placed in different power consumption modes such as:

Run mode

Sleep mode

Low power run mode

Low power sleep mode

Stop mode with operating RTC

Stop mode without RTC

Standby mode

The user reads the value displayed on the STM32L-DISCOVERY’s LCD panel, to know how much power the device is currently consuming.

With this demonstration, you can obtain an overview of low power modes and supply current requirements for each low power mode available on STM32L152.

The firmware associated with this application note also provides a demonstration of the touch sensing functionality available on STM32L-DISCOVERY. The touch sensing electrodes can be configured either as a linear touch sensor to perform linear sensing of finger position displayed as a percentage on the LCD, or, it can be configured as a group of four independent touchkeys.

It also includes a manufacturing test mode for performing a quick diagnosis of the STM32LDISCOVERY related to this application example. See Section 1.5.3: Manufacturing test for details regarding the test activation and for an explanation of the different test modes.

1.4.2IDD measurement principle

The STM32L-DISCOVERY IDD measurement circuitry consists of measuring the high side shunt voltage value V at the terminals of a high precision serial resistor (1%) inserted between the +3V3 power supply and the VDD pin of the MCU. Depending on the device power modes, the application uses R or [2000 + 2] x R as the equivalent resistor value by closing or opening K1. In Run mode, the current is in the range of mA, K1 is closed, and the equivalent resistor is R. In low power modes, the current is in the µA range, K1 is opened, and the equivalent resistance is 2002 x R.

4/18

Doc ID 018933 Rev 1

ST AN3413 Application note

AN3413

Application description

 

 

Figure 2. IDD measurement equivalent circuitry

 

 

 

6

 

 

 

 

)$$

 

 

 

2

 

'AIN

 

 

 

 

 

 

6

!

 

+

K

 

3

 

 

#

 

 

 

 

 

 

 

1

1

 

6$$

 

 

0!

 

 

 

 

 

 

 

 

)$$ MEAS

 

#OUNTER

34- , X

6

 

 

 

 

 

0!

+

 

 

 

 

 

%.

0#

,0 WAKE UP

 

 

 

 

'.$

 

 

 

 

 

-3 6

This resistor is connected between the differential inputs of a high-side current sense operational amplifier (A) with a fixed gain that amplifies the voltage (V) present on the resistors. A sample and hold stage is placed at the operational amplifier output and is then connected to an analog input of the MCU (PA4 IDD Measurement) that finally converts the resulting voltage, image of the consumption current.

In low power modes only, a counter enabled by STM32L15x (PC13 pin) manages the measurement timing while the microcontroller is idle. The microcontroller is woken-up after a 150 ms delay when the rising edge is triggered on a wake-up pin (PA0) controlled by the K2 switch.

While the microcontroller is in one of the power saving modes, a capacitor (C) is charged with the voltage amplified by the operational amplifier. The microcontroller can later sample (during its wake-up phase - 50 ms) the value of capacitor voltage proportional to the current consumption of MCU in low power mode. Switch S is opened at device start-up in order to keep the charge collected in capacitor (C) intact while the microcontroller is in low power mode.

The current measurement precision is enhanced by taking into account the current bias of high-side current operational amplifier. When JP1 is placed in OFF position (IDD measurement circuitry disabled), a special test invoked by the user at device start-up measures this current value and stores it in the non-volatile memory. Once this value is stored in the device, it is deducted from the next IDD measurement to compensate errors due to I bias current (see Section 1.5.2: Bias current record).

Doc ID 018933 Rev 1

5/18

Application description

AN3413

 

 

For additional information related to the IDD measurement feature, please refer to STM32LDISCOVERY evaluation board user manual (UM1079).

1.5Getting started with the application

This STM32L-DISCOVERY example application has 3 application modes that can be run:

Demo mode (touch sensor, IDD measurement)

Bias current record

Manufacturing test

Demo mode is available at application power-up while the two others are invoked by the user using a specific procedure that is described in detail later in this chapter. However, for best performance, it is recommended to measure and record the bias current before starting evaluation of low power mode IDD current.

1.5.1Demo mode - Touch sensing demonstration and IDD measurement

Once the application is powered-up via the USB cable (or by external power supply), it starts displaying a welcome message and then, after a few seconds, the value of the VDD voltage applied to the STM32L device.

LD3 (green LED) and LD4 (blue LED) blink alternately. As soon as IDD consumption values are displayed, both LEDs are turned off.

The User push-button allows you to change the functions as described in the state diagram in Figure 3.

The first step is a demonstration of the linear touch sensor function followed by a touchkey demo activated by pressing the user button.

When the used push button is pressed again, the power consumption measurement functions are launched. These functions consist of configuring the device for each low power consumption mode and then measuring and displaying the result on the LCD panel.

6/18

Doc ID 018933 Rev 1

Loading...
+ 12 hidden pages