AN4515 STMICROELECTRONICS | Alldatasheet

Document overview

  • Manufacturer or author: Provided By ALLDATASHEET.COM(FREE DATASHEET DOWNLOAD SITE)
  • PDF pages: 24

Technical content

Datasheet sections

  • 1 Application Overview
  • 1.1 Hardware high level description
  • 1.2 Low-power modes
  • 1.3 Batch Acquisition Mode (BAM)
  • 1.3.1 Principle
  • 1.3.2 BAM use case
  • 1.3.3 How to implement BAM
  • 1.3.5 How to execute code from RAM using IAR-EWARM toolchain
  • 2 Application note use case
  • 2.1 Block diagram
  • 2.2 STM32F411xx used peripherals
  • 2.3 Functional description
  • 3 Application current consumption
  • 3.1 Hardware requirements
  • 3.2 Software settings
  • 3.3 Measured current consumption
  • 4 Conclusion
  • 5 Revision history

power consumption in Run, Sleep and Stop modes. This application note is provided with STSW-STM32154 firmware package. Table 1. Applicable products and software

1 Application Overview

1.1 Hardware high level description

direction (UP or DOWN) to a master STM32F411xx microcontroller. displayed via the USB virtual comport. Figure 1 shows a high-level block diagram of the application. Figure 1. Application high level block diagram instead of 32F401CDISCOVERY (STM32F401C-DISCO order code).

1.2 Low-power modes

This section describes the different low-power modes used in the application.

  • Low-power run mode The CPU and some of the peripherals are running. To further reduce power consumption, unused GPIOs configured as analog pins and peripherals are disabled.
  • Sleep mode In this mode only the CPU is stopped and the peripherals kept running. To reduce power consumption the Flash memory can be stopped before entering Sleep mode. Peripherals can wake up the CPU when an interrupt occurs.
  • Stop mode The CPU is in DeepSleep mode. All peripherals except RTC are disabled. Exiting Stop mode is done by issuing an interrupt.
  • Standby mode In this mode the power is only maintained for the RTC registers. The device is woken by a rising edge on the WKUP pin that generates a system reset. Note: For more details about the low-power modes refer to STM32F411xx datasheets.

1.3 Batch Acquisition Mode (BAM)

1.3.1 Principle

The Batch Acquisition Mode (BAM) optimizes power consumption for data batching. It allows exchanging batches of data through communication peripherals while the rest of the device (including the CPU) is in low-power mode:

  • Only the needed DMA streams are enabled and running to transfer data from communication interfaces to internal RAM.
  • Routine execution from RAM allows switching off the Flash memory and stopping the Flash Interface clock.
  • MCU core is put in Sleep mode waiting for an interrupt/event to wake up.

1.3.2 BAM use case

Figure 2 shows one part of the application note use case block diagram. It describes the different peripherals involved in the BAM and mentions their power state (low-power or active). In fact, during data reception, only the DMA stream0, I2C1 and SRAM are active. The MCU core is in Sleep mode and the Flash memory is stopped until the DMA transfer is complete.

Figure 2. Batch Acquisition Mode use case

1.3.3 How to implement BAM

Figure 3, Figure 4 and Figure 5 for a description).

  • Executing Interrupts from RAM
  • Executing Interrupts from Flash memory
  • Using events to wake up the CPU Executing interrupts from RAM This is the approach used in the application note use case (see Figure 3). The device is woken up from Sleep by an interrupt. The user application has therefore to store the required ISRs and the vector table in the RAM so that it is immediately executed from the RAM when the interrupt occurs. 06Y9 &257(; )ODVK $57 65$0 670)[( VDPSOHV $FFHOHURPHWHU VWUHDP VWUHDP VWUHDP VWUHDP VWUHDP VWUHDP VWUHDP VWUHDP '0$ /RZSRZHUEORFNV $FWLYHEORFNV /60/'+&

Figure 3. Executing ISRs from RAM

the Flash memory is enabled again (see Figure 4). Figure 4. Executing ISRs from Flash memory

1.3.4 How to execute code from RAM using Keil® MDK-ARM™ toolchain

from RAM using Keil MDK-ARM toolchain.

  1. Right click the file to place it in RAM and select Options.
  2. Select the RAM area in the Memory Assignment menu.

Figure 6. MDK-ARM file placement

  1. Make a second vector table and save it in a new file (startup_stm32f411xe_ram.s) that
  2. Place the interrupt handler to be executed from RAM in a new file named
  3. Place the required files in the right RAM area in the scatter file (see Figure 7).

1.3.5 How to execute code from RAM using IAR-EWARM toolchain

  1. Define the address area for RAM0 by indicating the start and end addresses.
  2. Tell the linker to copy at startup the section named ‘ram0’ from Flash memory to RAM0.
  3. Indicate to the linker that ram0 code se ction should be placed in the RAM0 area.

Figure 9. Update of EWARM linker

  1. Select Options from the displayed menu.
  2. Check override inherited settings from the displayed window.
  3. Select the output tab and type the name of the section already defined in the linker file

(.ram0 in this example) in the Code section name field.

  1. Update the linker file (.icf) (see Figure 9).

a) Define the address where the second ve ctor table will be located: 0x2000 0000. b) Tell the linker to copy the section named .intvec_RAM0 at startup.

  1. Update the startup file (see Figure 10)
  2. Place the interrupt handlers to be executed in RAM0 in the new stm32F4xx_it_ram.c

as described in Section : Executing a source file from RAM.

  1. Remap the vector table to RAM0. To do this, modify the VTOR register in SystemInit

Figure 10. Update of EWARM startup file to handle an interrupt

2 Application note use case

2.1 Block diagram

Figure 11 describes the different modules involved in the use case. Figure 11. Use case block diagram

2.2 STM32F411xx used peripherals

The application use case makes use of the below STM32F411xx peripherals:

  • Clocks Two clocks are used in this application: – HSI: 16 MHz system clock source – LSE: 32.768 kHz low-speed external crystal which drives the RTC clock
  • SysTick timer This timer is used for waiting loops or to generate timeouts (delays).
  • GPIOs – PA0: used as user pushbutton and wakeup pin from Standby mode – PA3: set as a pin with interrupt on USART2_RX input to wakeup from Stop mode – PA4: set as an input pin with interrupt connected to the MEMS PE4 pin (INT1) on 32F401CDISCOVERY. This pin is used to wake up the CPU from Sleep mode. – PB8(I2C1_SCL) and PB9(I2C1_SDA) connected to MEMS PB6 and PB9 – When the microcontroller is in low-power mode, unused I/Os are placed in analog input mode to reduce power consumption.
  • DMA1 DMA1 is used to transfer data while the CPU is in Sleep mode. – Stream0: enabled for receiving data from I2C1 – Stream6: enabled for transmitting data to USART2 – Unused streams are disabled
  • RTC The RTC is an independent timer/counter that provides a calendar with subseconds, seconds and minutes to generate timestamp events.It uses the LSE clock.
  • I2C1 The I2C1 interface receives data (11 samples) from the sensor at a speed up to 400 KHz.
  • USART2 The USART2 is used to transfer messages to USB virtual comport through the DMA. The USART2 is configured as follow: – Word Length = 8 bits – Stop Bit = one Stop bit – Parity = without parity – Baud rate = 9600 bauds – Hardware flow control disabled (RTS and CTS signals)
  • RAM A specific routine is executed from RAM when the Flash memory is switched off.

2.3 Functional description

The principle of this use case is summarized in the state machine shown in Figure 12. Figure 12. Use case state machine

  1. The master and the sensor are powere d on. By default the system is in STDBY state
  2. The user starts running the application by pushing the user button (PA0 on

startup message is displayed via USART2 and USB virtual comport.

  1. When DMA transfers are complete, the CPU wakes up from SLEEP1 and enters STOP

2: Stop Flash while CPU in sleep: this configuration brings out the BAM feature. benefiting both from the second and third configurations.

  1. Once the DMA data transfer is complete , an interrupt wakes up the CPU to handle

these data before it goes back to Sleep mode ((SLEEP6 state)).

  1. While the CPU is in Sleep mode ( SLEEP6 state) and the Flash memory is stopped, the

Figure 15. Log example when configuration 4 is selected

3 Application current consumption

3.1 Hardware requirements

the master and sensor as shown in Figure 16. Figure 16. Hardware environment

  • Windows® PC
  • Two mini USB cables to power on the boards and to connect the Nucleo embedded ST- LINK for debugging and programming
  • Five connectors to link the 32F401CDISCOVERY pins with the corresponding Nucleo pins as described in Table 3.
  • A multimeter to measure current consumption.

Table 3. Master and sensor board connection

3.2 Software settings

with optimization Level3(-O3).

3.3 Measured current consumption

  • Flash memory stopped and CPU in Sleep mode
  • Flash memory active and the CPU in Sleep mode. Table 4 describes the average measures obtained for the MEMS loop part (SLEEP5, RUN7, SLEEP6 and RUN8) in the use case state machine. Table 4 shows a significant current consumption reduction of around 27 % obtained with the new STM32F411xx Stop Flash while CPU in Sleep feature (BAM).

Table 4. Current consumption example

4 Conclusion

This application note complements the datasheets and reference manual by presenting a user guide on the new BAM implementation offered by STM32F411 line. A use case highlights the significant current consumption reduction obtained by using the BAM (Stop flash while CPU in sleep mode). It also allows assessing the different STM32F411xx low-power modes and, thanks to the timestamp log to, determining all state periods and calculating the application average consumption.

5 Revision history

Table 5. Document revision history 19-Dec-2014 1 Initial release.