Getting started with LPBAM

Revision as of 16:58, 10 February 2023 by Registered User (→‎STM32CubeMX LPBAM Configuration)

This article explains the LPBAM feature, when and how to use it, it also provides code examples.

1. Introduction to LPBAM

The LPBAM stands for low-power background autonomous mode. It is an operating mode available in STM32U5 products series that allows peripherals to be functional and autonomous independently from the device power modes, down to Stop 2 mode, without any software running. The LPBAM subsystem can chain different operations thanks to DMA linked-list transfers.
File:LPBAM in U5.png
The DMA operations can be related to:

  • Peripheral data transfer
  • Peripheral reconfiguration

Using LPBAM optimizes automatically the consumption:
The device can be in a low power mode down to Stop 2, without any need to wake up for managing peripheral operation, thus saving energy loss during device wakeup time and run operation.
The bus clock and kernel clocks of peripherals are distributed only when requested by the autonomous peripherals.

1.1. Smart Run Domain (SRD)

The STM32U5 is split into two domains: CPU domain (CD) and SmartRun domain (SRD) File:Smart Run Domain.png

The SRD architecture relies on a DMA allowing autonomous operation during low-power modes down to Stop 2. This architecture also features a 32-bit AHB bus matrix that interconnects:

  • two masters:

– the main AHB bus matrix
– LPDMA1 (low-power DMA featuring one master port)

  • two slaves:

– AHB3 peripherals including AHB to APB bridge connected to APB3
– internal SRAM4

Info white.png Information
The SRAM4 is the only SRAM that can be accessed by the LPDMA1.

1.2. Peripherals supporting LPBAM

There is 2 types of peripherals :

  • Autonomous peripherals : which have clock request capability and support DMA transfer in STOP mode.
  • Passive peripherals : can only be reconfigured or used as trigger, they do not support DMA or clock request.

LPBAM is an operating mode that allows peripherals to function autonomously, independently of power modes, and without running any software. So autonomous peripherals can request their clock (kernel or bus clocks), and can then stay functional in Stop mode where the clocks are disabled by default to reduce consumption (except for LSE and LSI low-power low-speed oscillators).
The table below lists all peripherals that support LPBAM

Low-power mode Peripherals
Stop 0 and Stop 1 ADC4, ADF1, DAC1, GPDMA1, LPDMA1, LPTIMx (x = 1 to 4), LPUART1, MDF1, I2Cx (x = 1 to 4),

SPIx (x = 1 to 3), USARTx (x = 1 to 5)

Stop 2 ADC4, ADF1, DAC1, LPDMA1, LPTIM1, LPTIM3, LPUART1, I2C3, SPI3

1.3. LPBAM main use cases

Here below examples of use cases that can be done using LPBAM while remaining in Stop mode

1.3.1. I2C slave/Master transfer - SPI or UART RX/TX

This case is applicable when interfacing with external components like a MEM sensor for example over I2C or SPI. LPBAM and LPDMA can be used to transfer data from the peripheral into memory, and the MCU core will only wake up when the transfer is completed : Wakeup on Complete.
File:I2C SPI transfer.png
There is related examples in the STM32U5 Cube Firmware :
1) STM32Cube\Repository\STM32Cube_FW_U5_V1.2.0\Projects\NUCLEO-U575ZI-Q\Applications\LPBAM\LPBAM_I2C_TransmitReceive
2) STM32Cube\Repository\STM32Cube_FW_U5_V1.2.0\Projects\NUCLEO-U575ZI-Q\Applications\LPBAM\LPBAM_SPI_TransmitReceive

1.3.2. ADC or DAC conversion triggered by a low-power timer LPTIM

We can also trigger ADC with a periodic timer and store the data into memory while the rest of the device is sleeping File:ADC trigger.png
There is a related example in the STM32U5 Cube Firmware :
STM32Cube\Repository\STM32Cube_FW_U5_V1.2.0\Projects\NUCLEO-U575ZI-Q\Applications\LPBAM\LPBAM_ADC_TempSense

Info white.png Information
Check AN5816 [1] for the STM32CubeMX LPBAM TempSense application descroption and building.

1.3.3. LPTIM PWM ration change, Input Capture, Pulse Counter

The LPTIM can be used for timing and for output generation while the STM32 device is in low-power mode. it provides the basic functions of the STM32 general-purpose timers with the advantage of a very‑low power consumption. Additionally, when configured in Asynchronous counting mode, the LPTIM keeps running even when no internal clock source is active.

File:LPTIM Trigger using LPBAM.png

There is a related example in the STM32U5 Cube Firmware :
STM32Cube\Repository\STM32Cube_FW_U5_V1.2.0\Projects\NUCLEO-U575ZI-Q\Applications\LPBAM\LPBAM_LPTIM_PWMGen

Info white.png Information
Check AN4865 [2] for Low-power timer (LPTIM) applicative use cases on STM32 MCUs and MPUs.

More complex applications can be built using several DMA channels or chaining operations from different peripherals on the same channel as it is the case in AN5834 [3] which describes the LC sensor metering feature included in the STM32U5 Nucleo board NUCLEO-U575ZI-Q[4].

2. LPBAM Example Overview

To follow along with this example, you will need a NUCLEO-U575 board.
Before starting the hands-on, make sure you have installed the following software :

  • STM32CubeMX 6.5.0 (minimum version)
  • STM32CubeIDE 1.9.0
  • Cube U5 software package

2.1. Block Diagram

2.2. Objectives

The purpose of this example is to demonstrate how to :

  • Run multiple queues with LPGPIO concurrently by using low-power timer LPTIM to trigger the sequence.
  • Configure LPBAM scenario
  • Measure the power consumption in STOP2 mode

2.3. STM32CubeMX LPBAM Configuration

To create an LPBAM application using the STM32CubeMX tool, the user needs the STM32CubeMX standard view. This sets up the main application and code generation, and the LPBAM view to build the LPBAM applications.

  • Open STM32CubeMX and choose your board in the board selector menu :

File:board selection.png
Then choose start project with no peripheral initialization pushing on "NO" button. (To avoid generation of useless project code, the required peripherals are initialized later.)
File:peripheral initialization popup.png
To build an LPBAM application when TrustZone® is deactivated:

  • Choose "without TrustZone activated".
  • Click on OK.

File:trustzone disactivated.png
The STM32CubeMX tool entry point is always the standard view. Opening the project manager and saving the main project is recommended. For this application:

  • Click on project manager panel.
  • Name the project LPBAM_LPGPIO_LPTIM
  • For the "Project Location", save the project with the other examples in the firmware package.

At this point, the project is configured and the .IOC file is saved under the selected path. To increase the system performance, enabling the ICACHE peripheral in one-way configuration is recommended. To do this, click on the "System Core" menu, then on the "ICACHE" peripheral, and change "Mode" to "1-way (direct mapped cache)".

File:ICache activation in STM32CubeMX.png

2.4. Code configuration

2.5. Power Consumption measurement

3. References

[[category:Getting_started_with_STM32_system_peripherals | 25]]

  1. [[1]]
  2. [[2]]
  3. [[3]]
  4. [[4]]