an4515-using-batch-acquisition-mode-bam-to-maximize-power-efficiency-on-stm32f410-stm32f411-stm32f412-stm32f413-microcontroller-lines-stmicroelectronics
an4515-using-batch-acquisition-mode-bam-to-maximize-power-efficiency-on-stm32f410-stm32f411-stm32f412-stm32f413-microcontroller-lines-stmicroelectronics
Application note
Using Batch Acquisition Mode (BAM) to maximize power efficiency on
STM32F410, STM32F411, STM32F412, STM32F413 microcontroller lines
Introduction
The STM32F410, STM32F411, STM32F412 and STM32F413 lines are part of the STM32
Dynamic Efficiency™ microcontrollers. These devices are the entry level to the high-
performance STM32F4 Series and offer the best balance of dynamic power consumption
and processing performance, while achieving outstanding low-power consumption in Run,
Sleep and Stop modes.
With the new Batch Acquisition Mode (BAM) which allows optimizing the power
consumption for data batching, the STM32F410, STM32F411, STM32F412 and
STM32F413 microcontroller lines bring the Dynamic Efficiency to a new level.
This application note guides the user to achieve the expected power consumptions on the
STM32F410, STM32F411, STM32F412 and STM32F413 microcontrollers through an
application case. It also provides an example of how to implement the BAM.
This application note is provided with X-CUBE-BAM firmware package.
Contents
1 Application Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.1 Hardware high level description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Low-power modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Batch Acquisition Mode (BAM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.1 Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.2 BAM use case . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3.3 How to implement BAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.4 How to execute code from RAM using Keil® MDK-ARM™ toolchain . . 11
1.3.5 How to execute code from RAM using IAR-EWARM toolchain . . . . . . . 13
1.3.6 How to execute code from RAM using AC6-SW4STM32 toolchain . . . 16
4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
List of tables
List of figures
1 Application Overview
This section gives an overview of the application note use case, details how the user can
implement the BAM and describes each low-power mode involved in the use case
operation.
/60
'6
;18&/(2,.6$
6HQVRU
86%
9L
&RP UWXDO
3RUW
83
'LVSOD\
3&
'2:1
18&/(2)5(
0DVWHU
06Y9
1. The above block diagram also applies to STM32F410, STM32F412 and STM32F413 lines.
1.3.1 Principle
The Batch Acquisition Mode (BAM) optimizes the 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.
• The MCU core is put in Sleep mode waiting for an interrupt/event to wake up.
670)[(
&257(; /60'6
0
.%
)ODVK VDPSOHV
,& $FFHOHURPHWHU
$57
.%
65$0
VWUHDP
VWUHDP
VWUHDP
'0$
VWUHDP
VWUHDP
VWUHDP
VWUHDP
VWUHDP
/RZSRZHUEORFNV
$FWLYHEORFNV
06Y9
1. This use case also applies to STM32F410, STM32F412 and STM32F413 lines.
6WDUW
H[HFXWLRQIURP5$0
6ZLWFK2IIWKH)ODVK
6ZLWFK2IIWKH)ODVK
,QWHUIDFH
:),
'0$WUDQVIHU
FRPSOHWH
LQWHUUXSW
([HFXWH,65URXWLQH
6ZLWFK2QWKH)ODVK,QWHUIDFH
6ZLWFK2QWKH)ODVK
'HOD\ wV
7HPSR
dĞŵƉŽсϬ
(QG
H[HFXWLRQIURP5$0
06Y9
^ƚĂƌƚ
ĞdžĞĐƵƚŝŽŶĨƌŽŵZD
'LVDEOHLQWHUUXSWV
6ZLWFK2IIWKH)ODVK
6ZLWFK2IIWKH)ODVK
,QWHUIDFH
:),
DƚƌĂŶƐĨĞƌ
ĐŽŵƉůĞƚĞŝŶƚĞƌƌƵƉƚ
6ZLWFK2QWKH)ODVK
/ŶƚĞƌĨĂĐĞ
6ZLWFK2QWKH)ODVK
'HOD\ wV
7HPSR
dĞŵƉŽсϬ
(QDEOHLQWHUUXSWV
([HFXWH,65URXWLQH
ŶĚ
ĞdžĞĐƵƚŝŽŶĨƌŽŵZD
06Y9
6WDUW
H[HFXWLRQIURP5$0
6ZLWFK2IIWKH)ODVK
6ZLWFK2IIWKH)ODVK,QWHUIDFH
:)(
ǀĞŶƚсϭ
6ZLWFK2QWKH)ODVK,QWHUIDFH
6ZLWFK2QWKH)ODVK
'HOD\
7HPSR dĞŵƉŽсϬ
(QG
H[HFXWLRQIURP5$0
06Y9
1.3.4 How to execute code from RAM using Keil® MDK-ARM™ toolchain
This section gives an overview of the steps required to execute part of the application code
from RAM using the Keil MDK-ARM toolchain.
06Y9
4. Refer to the modified scatter file for the project options (see Figure 8).
06Y9
'HILQHVDGGUHVV
ZKHUHWKHVHFRQG
YHFWRUWDEOHZLOOEH 'HILQHVDGGUHVV
ORFDWHG DUHDIRU5$0
PHPRU\
7HOOVWKHOLQNHUWR
FRS\WKHVHVHFWLRQV
DWVWDUWXSWLPH
3ODFHVVHFWLRQUDPDW
5$0UHJLRQGHILQHG
DERYH
06Y9
'HILQHVDGGUHVVZKHUH
WKHYHFWRUWDEOHZLOOEH
ORFDWHG
'HILQHVDGGUHVVZKHUHWKH
VRXUFHVILOHVZLOOEH
H[HFXWHG
06Y9
– Copy the vector table to the global array VectorTable[] (see Figure 15).
This step ensures that the vector table is placed in the internal SRAM at
0x20000000
5. Relocate the vector table to RAM0 by modifying the VTOR register in the SystemInit
function as following: SCB->VTOR = 0x2000 0000 | VECT_TAB_OFFSET
6. Modify the startup file to initialize data to be placed in RAM0 at the startup time. (See
Figure 16)
This section describes the case developed in this application note through a block diagram
and a state machine highlighting the different peripherals and the low-power modes that are
used.
670)[(
&257(; /60'6
0
.%
)ODVK VDPSOHV
,& $FFHOHURPHWHU
$57
,17
.%
86%9LUWXDO&RP3RUW
57& 65$0
3&7HUPLQDO
3$ 7[ VWUHDP
'LVSOD\
VWUHDP 3%
8$57 '0$ ,2V
3$ 5[ ;18&/(2,.6$
18&/(2)5(
0VY9
1. This use case also applies to STM32F410, STM32F412 and STM32F413 lines.
3$
67'%< 581
3$
6/((3 '0$7UDQVIHU
'0$7UDQVIHU 2QJRLQJ
0(06/RRS &RPSOHWH
581 '0$7UDQVIHU
&RPSOHWH
'0$
7UDQVIHU 6/((3 6/((3
2QJRLQJ 581
0(06(;7,
581
0(06(;7,
581 6723 8$57 5; (;7,
0(06(;7,
8$57 5; (;7,
581
6/((3
0(06(;7,
581 6/((3 581 6/((3
8$57 5;
'0$ 8$57 5; (;7,
7UDQVIHU (;7,
&RPSOHWH '0$
/RZSRZHUPRGH 7UDQVIHU
5XQPRGH 2QJRLQJ
%DWFK$FTXLVLWLRQ0RGH %$0
06Y9
The main steps of the application use case are the following:
1. The master and the sensor are powered on. By default the system is in STDBY state
(Standby mode).
2. The user starts running the application by pushing the user button on the Nucleo board.
The CPU goes to SLEEP1 state while a DMA transfers startup message is displayed
via USART2 and USB virtual comport.
3. When DMA transfers are complete, the CPU wakes up from SLEEP1 and enters STOP
waiting for the user to read the configuration menu below (see Figure 19):
1: Flash active while CPU in sleep: Flash memory is running
2: Stop Flash while CPU in sleep: this configuration brings out the BAM feature.
3: Enable Time Stamp and Flash active while CPU in sleep: this option is used to
track the different application state consumptions with using the period of each state
displayed in timestamp log.
4: Enable Time Stamp and stop Flash while CPU in sleep: this option allows
benefiting both from the second and third configurations.
Figure 19. Startup and Configuration menu
4. The system wakes up from Stop mode and enters SLEEP2 state waiting for the user to
select the desired configuration.
5. Once the configuration is selected, an external interrupt on USART2_RX wakes up the
CPU from Sleep mode.
6. The CPU enters Sleep mode again (SLEEP3 state) while a DMA transfers message is
sent via USART2.
7. After a DMA transfer complete interrupt has been received, the CPU configures the
MEMS and enters SLEEP4 state waiting for an accelerometer movement (UP or
DOWN direction). The DMA sends the ### Move MEMS UP or DOWN ### message
during Sleep mode.
8. After the MEMS has moved, the CPU wakes up from Sleep mode, configures the I2C
interface and DMA to transfer samples coming from the MEMS. The DMA then starts
sending data to the RAM while the Flash memory is stopped and the CPU goes back to
Sleep mode (SLEEP5 state).
9. 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)).
10. While the CPU is in Sleep mode (SLEEP6 state) and the Flash memory is stopped, the
DMA sends a complete log to the USART2 including MEMS direction and the
timestamp (see Figure 21).
7R3&
-3
7RPXOWLPHWHU
06Y9
Table 3 shows a significant current consumption reduction of around 27 % obtained with the
new STM32F410/STM32F411/STM32F412/STM32F413 Stop Flash memory while CPU in
Sleep feature (BAM).
4 Conclusion
This application note complements the datasheets and the reference manual by presenting
a user guide on the new BAM implementation offered by the STM32F410, STM32F411,
STM32F412 and STM32F413 lines.
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
STM32F410/STM32F411/STM32F412/STM32F413 low-power modes and, thanks to the
timestamp log to, determining all state periods and calculating the application average
consumption.
5 Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of Purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.