18 Creating LPBAM projects ¶
18.1 LPBAM overview ¶
Disclaimer: to learn about the LPBAM mode and its usage, it is recommended to read the LPBAM application note available on www.st.com, and the LPBAM utility getting started guide located under the Utilities folder of the STM32Cube firmware package.
18.1.1 LPBAM operating mode ¶
LPBAM stands for low power background autonomous mode. It is an operating mode that allows peripherals to be functional and autonomous independently from power modes and without any software running. It is performed thanks to a hardware subsystem embedded in STM32 products. Thanks to DMA transfers in Linked-list mode, the LPBAM subsystem can chain different actions to build a useful functionality (peripheral configurations and transfers). Optionally, it can generate asynchronous events and interrupts. It operates without any CPU intervention. Consequently, the two major benefits from using the LPBAM subsystem mechanisms are an optimized power consumption, and an offloaded CPU.
18.1.2 LPBAM firmware ¶
The LPBAM firmware has been designed to help users create LPBAM applications: the LPBAM utility is a set of modular drivers located under the Utilities folder of the STM32Cube firmware package. Each module comes as a pair of C file that provides the APIs needed to build an application scenario. Each module manages the configurability and the data transfers for a given peripheral. The LPBAM utility is designed to be compatible with any STM32 devices supporting LPBAM subsystem mechanisms through a configuration module: it requires a configuration file stm32_lpbam_conf.h aligned with the application needs. The LPBAM utility has a single application entry point, the stm32_lpbam.h, that must be included in the project.
18.1.3 Supported series ¶
The LPBAM firmware supports STM32U575/585, STM32U595/5A5 and STM32U599/5A9 products, for projects with or without TrustZone activated.
STM32CubeMX 6.5.0 introduces LPBAM for projects without TrustZone activated on the
STM32U575/585 product line: users can create LPBAM applications for their project using STM32CubeMX LPBAM Scenario & Configuration view and generate the corresponding code. The generated C project embeds the LPBAM firmware.
STM32CubeMX 6.6.0 adds LPBAM support for projects with TrustZone activated.
18.1.4 LPBAM design ¶
It is recommended to use LPBAM to save power and offload the CPU.
The LPBAM mechanism supports the following set of peripherals on the Smart Run Domain: ADC4, COMP1/2, DAC1, I2C3, LPDMA1, LPGPIO, LPTIM1/2/3, LPUART1, OPAMP1/2, SPI3, VREFBUF.
According to the LPDMA implementation in the Smart run domain, the LPBAM has access only to SRAM4.
The LPBAM mechanism implementation can run autonomously until Stop2 mode. • To reach the lowest power consumption, the system power usage, the system clock and the autonomous peripheral kernel clock can be configured:
18.1.5 LPBAM project support in STM32CubeMX ¶
An LPBAM project is composed of a main project, and of one or more LPBAM applications.
Figure 698. LPBAM project
18.2 Creating an LPBAM project ¶
18.2.1 LPBAM feature availability ¶
When a project with LPBAM feature capability is opened, a dedicated entry is shown in the user interface (see Figure 700). The feature is optional and when it is not used, it has no impact on the generated project.
18.2.2 Describing an LPBAM project ¶
Describing an LPBAM project in STM32CubeMX consists in describing the main project using STM32CubeMX main project page, and one or more LPBAM applications using the dedicated LPBAM Scenario & Configuration page.
Starting with STM32CubeMX 6.5:
Create a project by selecting an MCU or board part number from the STM32U575/585 product line.
Do not activate TrustZone for the project.
Click “LPBAM Scenario & Configuration” ribbon to view LPBAM dedicated page.
The LPBAM context is highlighted with a pink border. You can switch back and forth between the main project configuration and the LPBAM Scenario & Configuration by clicking the corresponding ribbon.
Figure 701. LPBAM Scenario & Configuration view ¶
18.2.3 Managing LPBAM applications in a project ¶
When entering the LPBAM Scenario & Configuration view, you must first add an LPBAM application.
Adding, removing, renaming, and switching between LPBAM applications is done from the left panel under the LPBAM manager section.
To add the first LPBAM application, click “Add Application”:
If the default name is kept, the application “LpbamApp1” is created.
The first Queue “Queue1” of LpbamApp1 is created.
The configuration views (LPBAM scenario, pinout & ip, clock) necessary to describe Lpbam App1 are available.
To add more queues, click “Add Queue”
To delete an application (or a queue), right-click the application (or the queue) name and select “Delete”.
To rename an application (or a queue), right-click the application (or the queue) name and select “Rename”. Note that the application name is used in the generated project.
To switch between LPBAM applications, click the application name, this loads the LPBAM panel for the selected application.
To switch between queues in an LPBAM application, click the queue name: the middle and right panels are refreshed to display the selected queue and its configuration.
Figure 702. Adding an application
18.3 Describing an LPBAM application ¶
18.3.1 Overview (SoC & IPs configuration, runtime scenario) ¶
Describing an LPBAM application consists in configuring the SoC and IPs, as it is done for a standard STM32CubeMX project, as well as describing the runtime part of the application.
SoC and IPs configuration ¶
To configure IP and SOC in the context of an LPBAM application, use the Pinout & Configuration and Clock configuration provided with the LPBAM application.
Figure 703. SoC and IPs configuration
With standard STM32CubeMX projects, the user must add the code to manage the runtime behavior of the main application based on STM32Cube HAL or LL driver APIs, such as HAL_COMP_Start, HAL_TIM_Start, HAL_TIM_Stop.
For LPBAM applications, STM32CubeMX provides the LPBAM Scenario & Configuration panel to create the runtime description (scenario). As shown in Figure 704, this panel is divided in three parts.
Figure 704. LPBAM scenario: creation and configuration panels
Note: LPBAM applications use the LPBAM firmware APIs and consist of chained DMA transfers.
In the context of an LPBAM application, the first panel is used for:
Managing queues for the application.
Browsing and adding nodes to the queue currently selected in STM32CubeMX user interface.
Application specific settings. These settings cannot be changed nor disabled when using LPBAM on STM32U5 series.
The second panel displays the diagram of the queue currently selected for one selected queue of the LPBAM application.
The third panel lets the user to configure either the queue (if the queue name is clicked), or a node (if the node is selected on the diagram).
18.3.2 SoC& IPs: configuring the clock ¶
The LPBAM subsystem is functional down to STOP2 mode and supports only IPs on the Smart run domain. Consequently, in the LPBAM context, only a subset of the clock tree can be configured. Refer to Section 4.10 for details on how to configure a clock tree in
STM32CubeMX.
18.3.3 SoC & IPs: configuring the IPs ¶
Only IPs of the Smart run domain are available in the LPBAM context.
In the LPBAM context, most IPs show the same configuration possibilities as the main project. However, for some IPs, some additional configuration is needed. For example, when an IP internal interrupt can be used in the LPBAM context, a dedicated configuration Tab is shown.
Figure 706. Available IPs
Figure 707. IP configuration: advanced settings ¶
18.3.4 SoC & IPs: configuring low power settings ¶
Starting with STM32CubeMX6.5, users can configure low power settings for their project. These settings (to be found under the PWR IP) are very important to minimize the power consumption of an LPBAM application.
18.3.5 LPBAM scenario: managing queues ¶
An LPBAM scenario consists of one or more queues, each with one or more nodes. The center panel describes the scenario of the LPBAM application: click the queue name to display its diagram in the center panel and its configuration in the right panel. The name of the selected queue is underlined in blue.
To add more queues, click the “+” button in that panel, or click “Add queues” from the LPBAM management section in the left panel:
The maximum number of queues is four on STM32U5 series, limited by the number of LPDMA1 channels.
Adding an LPBAM application to the project automatically creates one empty queue for that application.
Warning: For LPBAM applications with multiple queues, STM32CubeMX does not manage the runtime synchronization between queues. It is the user’s responsibility when assembling its final application to “start” the different queues at runtime.
The “LPBAM Management” section allows to remove and rename queues:
To delete a queue, right-click the queue name and select “Delete”.
To rename a queue, right-click the queue name and select “Rename”.
To switch between queues in an LPBAM application, click the queue name: the middle and right panels are refreshed to display the selected queue and its configuration.
18.3.6 Queue description: managing nodes ¶
A queue description consists of a sequence of functional nodes on a timeline: the sequence is displayed as a diagram in the central panel and the queue configuration in the right panel.
To add nodes to a queue:
Click the name of the queue to be updated.
Use the “LPBAM function Toolbox”, in the left panel to browse the list of IPs and functions (LPBAM firmware APIs) that can be used to create nodes.
Click the IP name to expand and see the list of available functions. • Click the “+” sign next to the function name to add the function as a node in the queue:
the queue diagram in the center panel is updated accordingly.
Example: on Queue1 of LpbamAp1, COMP1 is started, then data transfer on COMP1 Output is performed (see Figure 709).
To remove nodes from the diagram, click the cross on the node right-end-upper corner.
Figure 709. Adding nodes to a queue
18.3.7 Queue description: configuring the queue in circular mode ¶
STM32CubeMX offers the possibility to design circular queues:
Select the queue to be configured by clicking the queue name in the center panel: the queue configuration is displayed in the right panel.
Click the Circular mode checkbox to configure the queue in circular mode: by default, the queue loops back to the first node (see Figure 710).
To loop back to a different node, click the end of the arrow and drag it to the node of choice.
To remove the loop, uncheck Circular mode.
An example is provided in Figure 711: when the queue is executed, the two first nodes and the configuration of the third node are executed once. whereas the data transfer is repeated as part of the loop.
Figure 711. Queue looping back on IP data transfer ¶
18.3.8 Queue description: configuring the DMA channel hosting the queue ¶
The execution of an LPBAM queue consists of LPDMA chained transfers. The DMA hosting the queue execution must be configured as needed by the application (see Figure 712).
Figure 712. LPBAM queue: DMA configuration
DMA channel NVIC configuration ¶
NVIC settings are available only if one DMA channel interrupt is enabled (see right panel in Figure 712). The preemption priority and sub priority ranges in the LPBAM context depend on the NVIC priority group set for the whole project (the main project with the LPBAM applications).
Warning: Always check preemption and sub-priorities in the LPBAM context after changing the NVIC priority group from the main project Pinout & Configuration view.
18.3.9 Node description: accessing contextual help and documentation ¶
STM32CubeMX provides contextual help and link to reference documentation on LPBAM functions to guide the user during the function selection process:
From the “LPBAM function Toolbox” in the left panel, hover the mouse on an IP name to show the contextual help with links to reference documentation (see Figure 713). • It is recommended to read carefully the LPBAM global documentation and the IP “Description, Usage and Constraint” to learn how to assemble nodes in a queue, several queues, what can be done and what cannot be done. Some restrictions apply and are due to the LPBAM mechanism. They are not coming from the IP itself or from HAL constraints.
18.3.10 Node description: configuring node parameters ¶
Once a function is chosen from the “LPBAM Function Toolbox” and added to a queue, it can be configured. In the center panel, click on a node to select it: the function is highlighted in pink, and its configuration is shown in the right panel (see Figure 714).
The example shows the “Start” parameters of the LPBAM COMP1_Start function. The HAL driver uses the same parameter names to configure a COMP IP. As mentioned before, the LPBAM firmware is not a HAL driver. However, the IP being unique, the LPBAM driver has been designed so that the IP parameters use, whenever possible, the same naming as found in the HAL driver.
properly configured in the “Pinout & Configuration” view.
When a parameter is set to a hardware resource such as a GPIO, the resource must be configured in the Pinout & Configuration view.
In the example shown in Figure 714, the COMP “Input Plus” is set to PC5. If PC5 is not configured in the “Pinout & configuration” view, the generated LPBAM application can gets a “null signal” on Input Plus, and will be not functional.
To fix this issue:
Go to the Pinout&Configuration view
Search PC5 using the search field
Right-click the PC5 pin and select COMP_Inp (see Figure 715)
Figure 715. LPBAM node: configuring hardware resources ¶
Note: All constraints concerning the initial configuration of the IP are mentioned in the LPBAM firmware documentation. Use STM32CubeMX “LPBAM Design check” mechanism (see dedicated section) to detect missing configurations.
18.3.11 Node description: configuring a trigger ¶
For all IPs and functions, with the LPBAM firmware it is possible to use a hardware signal to trigger a node. STM32CubeMX allows to configure such trigger from the node configuration panel. By default, the node execution is not triggered. When trigger is enabled, all possible trigger signals are listed.
Warning: It is the user responsibility to properly configure the triggers. STM32CubeMX does not check for configuration errors.
Taking the COMP function “Start” as an example (see Figure 716), choose the function execution to be triggered on the rising edge of hardware signal, for the example, then, select the hardware signal among the list of hardware signals proposed.
Figure 716. LPBAM node trigger configuration
Figure 717. LPBAM node triggered using timer channel ¶
18.3.12 Node description: reconfiguring a DMA for data transfer ¶
Nodes set to a function managing data transfers (all functions with associated data transfer and with a name not ending with _Config), come with a specific configuration section: “Reconfigure DMA for Data Transfer” (see Figure 718).
Each DMA data transfer is based on a specific configuration, including, among others, data size, buffer address, address increment. The DMA default settings are functional.
Figure 718. LPBAM node: reconfiguring a DMA
18.4 Checking the LPBAM design ¶
STM32CubeMX offers users with the possibility to check their LPBAM design for coherency and completeness, by detecting:
Incoherences between the IP LPBAM function selected for a node and the corresponding IP configuration.
Wrong queue designs (the sequence of nodes is invalid).
Click CHECK LPBAM DESIGN to check all LPBAM applications currently available in the project. Results appear in the LPBAM output log window (see Figure 720).
Note: Messages raised on the LPBAM design do not prevent users to generate the C code for their project. Supported type of messages are ERROR (in red), Warning (in orange), and Information (in blue).
18.5 Generating a project with LPBAM applications ¶
Click Generate Code from the main project view. As exemplified in Figure 720, the resulting project shows, in addition to the main project files and folders, the stm32_lpbam_conf.h file, a dedicated folder for the configuration code, and the utilities folder with the LPBAM utility firmware.
Figure 721. STM32CubeMX project generated with LPBAM applications ¶
In the Core/Inc folder, the stm32_lpbam_conf.h file that defines all the LPBAM modules enabled for the LPBAM applications, to be used by the LPBAM utility firmware.
In the LPBAM folder, the code for the LPBAM applications and their scenarios. The lpbam_<application name>.h file provides the prototypes of the functions to call in the main project to initialize the application, build and initialize the scenario, link it with the DMA, start it, stop it, unlink it, and de-initialize it.
As an example, for the LpbamAp1 application, STM32CubeMX generates the following functions:
/* LpbamAp1 application initialization */ void MX_LpbamAp1_Init(void);
/* LpbamAp1 application - scenario initialization */ void MX_LpbamAp1_Scenario_Init(void);
/* LpbamAp1 application - scenario build */ void MX_LpbamAp1_Scenario_Build(void);
/* LpbamAp1 application - scenario link */ void MX_LpbamAp1_Scenario_Link(DMA_HandleTypeDef *hdma);
/* LpbamAp1 application - scenario start */ void MX_LpbamAp1_Scenario_Start(DMA_HandleTypeDef *hdma); /* LpbamAp1 application - scenario stop */ void MX_LpbamAp1_Scenario_Stop(DMA_HandleTypeDef *hdma);
/* LpbamAp1 application - scenario unlink */ void MX_LpbamAp1_Scenario_UnLink(DMA_HandleTypeDef *hdma);
/* LpbamAp1 application - scenario de-initialization */ void MX_LpbamAp1_Scenario_DeInit(void);
18.6 LPBAM application for TrustZone activated projects ¶
Starting with STM32CubeMX 6.6.0, users can create LPBAM applications for projects with TrustZone activated.
Access to MCU selector and select an STM32U575/585 device
Click Create a new project
Choose the option “with TrustZone activated”
STM32CubeMX standard project view ¶
STM32CubeMX standard project view proposes security settings for peripherals ( Figure 722) and the clock tree ( Figure 723).
STM32CubeMX LPBAM view ¶
In STM32CubeMX LPBAM Application configuration context, the peripherals and the clock tree do not come with dedicated security settings (see Figure 724 and Figure 725). The choice of context, secure or nonsecure, is done at LPBAM application level ( Figure 726).
Security settings coherency check ¶
1. Click .. image:: ../../../assets/media/image1354.webp
- width :
1.5325in
- height :
0.195in
Enable Show Attribute Warning Messages to see details about LPBAM security related configuration issues (see Figure 727)
Figure 722. STM32CubeMX project - Peripheral secure context assignment ¶
Figure 723. STM32CubeMX project - Clock source secure context assignment ¶
Figure 724. LPBAM project - Peripheral no context assignment