 Hi, I'm Troy Davis with ST Microelectronics, and today I'm taking you through an example project that uses the Low Power Background Autonomous mode found on the STM32U5 series microcontrollers. The agenda for today is to first provide some background information on what the LPBAM is, give an overview of the example project, then take you step by step through configuring an LPBAM application in STM32 CubemX. LPBAM stands for Low Power Background Autonomous Mode. The LPBAM optimizes the power consumption and allows you to use DMA to run peripherals autonomously in low power modes. Please pause the video to look at the table of available peripherals that the LPBAM allows in different stop modes. The smart run domain allows access to data buses that aren't normally available in low power modes down to stop 2. By usage of low power DMA, the smart run domain, and the LPBAM, you can concurrently run queues of peripherals in stop 2 mode with optimized power consumption. If you would like to learn more about the LPBAM, please refer to these related documents. With the background information out of the way, I will give an overview of the project that we will create. To follow along with this example, you will need a Nucleo U575 board, a MicroUSB cable, SDM32 CubemX, and SDM32 Cubed IDE. The purpose of this example project is to demonstrate running multiple queues with low power DMA concurrently and using low power timers to trigger the sequence. To do this, I am sending arbitrary data over SPI, UR, and GPIO using two LPDMA channels. The diagram on the right shows the queues that will run in stop 2 mode. The sequence will run at infinitum using circular DMA buffers. Low power timers control the frequency at which those queues are stepped through. Low power timer 1 and low power timer 3 will run at different frequencies to help demonstrate the independence of the queues. Before I start the hands-on portion of the video, please make sure you have downloaded the necessary software. CubemX will need to be at least version 6.5.0 at a minimum, as this is when the LPBAM utility was introduced. You will also want to make sure you have Cubed IDE 1.9.0 to ensure compatibility. You can download the CubemU5 firmware package through CubemX under Help, Manage Embedded Software Packages. Let's start this hands-on. In the CubemX homepage, press the Access to Board Selector button. Once the board selector is open, we want to search for the Nuculo U575. Select the board and press the Start Project button. Initialize all peripherals with the default mode and create a project without Trust Zone activated. Once we're in the pinout configuration, the first thing we're going to do is optimize power consumption by clearing the pinout and setting all the GPIOs to analog mode. Now we need to configure the instruction cache and low power DMA. Under System Core, go to iCache and set it to one-way direct map cache. Now go to LPDMA1, activate both Channel 0 and Channel 1 in Linked List mode. Now in the configuration for both channels, set the Execution mode to Circular, since we want our cues to run in a circular fashion. After this, we can switch to the LPBAM scenario and configuration tool. Once we're here, we can add an application and name it TXApp. Please name the scenario TXData. We'll want to go ahead and make our two cues, the first cue being our SPI and GPIO cue and the second cue being our UART cue. Now with our two cues set up, we'll want to go ahead and configure them. For the SPI and GPIO cue, make it Circular Mode. Now go down to SPI3, where we'll add a Transmit Data in our sequence. Now we can configure this part of the cue. Enter a function name, keep the number of data as one. The right buffer name is the actual name of the variable that we're going to use to transmit the data. And we want this to be triggered by Low Power Timer 1, Channel 1. Next thing we're going to do is add two right pins in the sequence. The first right pin is going to set the pin. So we'll name it pin set and set the pin state to set. And of course, once again, it's going to be triggered by LP time 1, Channel 1. The second one we're going to call pin reset. Pin state is reset and the function trigger is once again Low Power Timer 1, Channel 1. Now we can configure the cue handling the UART transfer. Once again, we'll put it in Circular Mode. Now we add the Transmit Data to our sequence and make sure the Circularity is on the Data node and not the Configuration node. Enter a function name. Once again, the data buffer name is going to be where the data itself is stored, offset 0, and data size 1. And we want this one to be executed on Low Power Timer 3, Channel 1. With our cues the way we'd like them, we can now go to the pin out and configuration. Next let's configure our GPIO PA1. From here we want to configure our triggering timers. Let's start with Low Power Timer 1. Mode is Counts Internal Clock Events and we'll activate Channel 1 as an output. I intend to use the Low Speed Internal Oscillator as the source. So here I'm setting up the period and pulse value to correspond to a 50% duty cycle and a 500 Hertz period. Now let's set up Low Power Timer 3. Very similar to Low Power Timer 1. Activate Channel 1 as an output. Again I want to use LSI as the clock source but this time I'm setting up the period such that it is 400 Hertz but the pulse value is still a 50% duty cycle. Now let's configure the Low Power UART. Set the mode to Asynchronous and set the Bot Rate to 9600. Data Direction as Transmit Only and now we want to configure the Trigger selection to match our sequence. So set it to Low Power Timer 3 out and set the Data Size to 1 just like in our sequence. Now let's configure SPI 3 as Transmit Only Master. Set the Prescaler to 256. This will make it easier to see on the Logic Analyzer. Just like the other one we want to match our trigger source to our sequence so set it to Low Power Timer 1, Channel 1. Now real quick here we're just going to remap the pins in a way that makes them more accessible on the Morpho characters. You can use Control, Click and Drag to reassign the pins. Please refer to the annotations on the screen for the remappings and the final pin map. Also note that you'll still have to solder in a wire for PA1. Now the last configuration stage is to set up the clocks. Change the UART source to MSIK. LP Timer 1 to LSI. LP Timer 3 to LSI as well. And SPI 3 to MSIK. Before we generate code we want to hit the Check LP BAM Design button to see if it throws us any errors. Since we are error free we want to go back to the scenario configuration and from here we can go to the Project Manager tab. Give our project a name. Select STM32 Cube IDE, uncheck Generate Under Root and Generate Code. When this window pops up select Yes you still want to generate code. Once the code is generated select Open Project. Select the workspace of your choice and hit Launch. Once it's open in the IDE we can start adding code. First we need to modify the linker to use RAM that is Functional and Stop To mode. Open up the linker. Here we want to take the memory section associated with RAM and assign it to the address of SRAM4. You can do so like this. Now we need to add the include that lets us access the generated LP BAM functions. In main.c under Application User Core add the include a user code begin includes. Now we'll set up our transmit data buffers along with an array of pointers for the LP DMA channels we want to use for our queues. In main.c we'll want to add the code to the user code begin PV section. To make sure our data buffers are visible to the LP BAM utility we need to add these external variables to the LP BAM build file. Under application user LP BAM TXapp open LP BAM TXapp TXData build.c and add the code to the user code begin EV section. In main.c we need to add the code that initializes builds and starts our LP BAM application. In main.c add the code to the user code begin to section. Now we just need to add the code that starts our hardware trigger low power timers. In main.c control click on MX TXapp TXData start to bring you to the function definition and paste the code in the user code begin TXapp TXData start section. Now the project is ready to build. Select the hammer icon in the top left corner to build the project. Once the project is done building select the run button and hit OK in the edit configuration window. If we take a look at the program output we can see LP Tx1 channel 1 is approximately the correct frequency and that on its rising edges it is triggering an SPI transfer, a pin set and a pin reset in that order. If we look at LP Tx3 channel 1 it's also the correct frequency and is triggering UART transfers on its rising edges. That's all for today. Thanks for watching.