 So, let's dive into the hands-on so we can actually see how this is used. At this point, what I'm going to do is I'm going to swap to the cheat sheet because it's probably going to be easier to follow. So, we're now at the LPBAM hands-on section. If I just give you an overview of what we're trying to achieve first. So, we're going to set up an example kind of similar to what we used before. We're going to use the ADC, ADC4, and low-power DMA. And we'll use two channels of low-power DMA. We could use only one, but to kind of highlight how flexible this is, we'll use two to show you how it's configured in the tool. And the idea is that we trigger the ADC samples from the low-power timer. And the low-power timer is configured to give samples at two different frequencies or two different data rates. So, we'll have this running for one second at 256 hertz, which generates 256 half-words of data. And then we'll reconfigure the timer to change the sample rate to 64 hertz. So, we'll reduce the sample rate and again sample for a second, which gives us 64 bits of data, half-words of data. So, we'll take channel 1 DMA to actually do the DMA transfers from the ADC to the memory. And we'll use a second channel, channel 0, to reconfigure the parameters of the timer so that we can implement the PWM function. So, for Q1, we are handling the timer. So, we'll have three function nodes as you'll see later. The first thing we do is we configure the timer and start it. We start it running with a sample rate of 256 hertz. And then once the transfer is complete from the ADC at 256 hertz, we then reconfigure the timer to 64 hertz and then go around the loop like that. For the ADC, this is quite simple. We're literally just taking data from the ADC data conversion register and transferring it into memory. And we will, because we have a total of 320 samples in total, we'll store 320 samples into memory. So, let's actually start the hands-on now. So, the other two guys used CubeMX for the design for creating the basic configuration and then swapped over to Cube IDE. It's completely a matter of personal choice, but I thought it was a good idea to show you how all of that can be done within Cube IDE itself. So, Cube IDE actually includes all of the functionality of CubeMX in the one tool. If you were using something like IAR or KyleMDK as your IDE environment, then you would use CubeMX to generate your configuration and import it into that tool. But I wanted to highlight that ST have their own tool as well to do all that, which is Cube IDE. So, before we start, I recommend that if you have any other open projects from before, I would recommend to close them down because it's very easy to get mixed up between different files and you end up editing one file and saving it, but it's not part of your actual project. So, I do suggest that you close all existing projects. So, do that by right clicking on any open projects and then select close project. So, we want to start a new project. We're going to start one from scratch. The first thing we do is we go to File, New, STM32 Project. And this will pull up the target selection wizard, which is very similar now to what you would have seen in CubeMX. And we need to target the specific... We're going to start with a microcontroller, but I want to show you a tip because I can never remember the actual specific part number that's on the board. But I know that I can select this nuclear board that we have in the what we call the board selector tab. So, if you click on board selector and type U575, it will pull up the nuclear board, but it also tells you what the mounted MCU is. And if we were to click on that, that would take us directly to the MCU selector tab. So, it swaps focus and allows us to very quickly select the individual MCU that's used on that board. So, it's important that we're selecting it from the MCU tab because we're starting with a completely blank piece of paper as it were, but this is a quick way of selecting the correct component. So, make sure that you have the STM32 U575 ZIT6Q highlighted, and then press Next. We need to give our project a name. This can be anything you want, but I'm going to call it LPBAM, for example. Now, we don't have to worry about tool chain selection because we're doing all of this within cube IDE, so it's all set for you directly. We can click Finish at this point, or we can click the Next button, and the Next button just allows us to review that it's using a specific device with a specific firmware package. You should have the correct device selected here, so then we click on Finish, and it will go away, and it will start to build the Cubamex configuration for you, and it will open it up in a new window in cube IDE. If your machine is slow like mine is today, it might take a few seconds. You'll see the usual warning that we've seen all day about iCache, because we haven't had a chance to set it yet, so it's warning us that it's not been enabled. We still do want to generate code though, so we click on Yes. Okay. Right. I actually have my Cubamex perspective fully maximized. I meant to reset that before I started this hands-on. Do that now, and I'll show you why I'm doing that in a minute. But this is what you will see when it opens up normally. You'll see the standard cube IDE project navigator structure here, and then because we've opened up a Cubamex perspective, we've got what looks like a mini version of Cubamex running in the cube IDE window. Now, it may be that you find that these windows are a little bit restrictive in terms of space, especially when you have only one monitor to play with, like on a laptop, for example. So instead of, we can reuse some of this space by maximizing this view. So we would go up to this Maximize button here, and we maximized the Cubamex perspective. So if I click on that, it will essentially take up all of the spare space, and now it looks identical to how the Cubamex looked. So now we've got our project open. The first thing we want to do is to get rid of some of these warnings that we were dealing with. So the first one was the iCache warning, if you remember. So we go to the System Core, iCache, and let's enable it and select one-way direct mapped. And that will turn off the warnings that we normally get when we generate code. So now we want to enable the low-power DMA. So if we go to the low-power DMA option here, and we want to use two channels, one channel for the ADC, one channel for the low-power timer. So if we select channel zero and select it to Linkless Mode and do the same for channel one, put that to Linkless Mode, that allows us to do that. So for channel one, we actually want to enable the interrupt for channel one because channel one is the timer channel and channel zero is for the ADC. So we want to enable the interrupt for channel one, global interrupt. So on the NVIC tab here, click on Enabled for the interrupt. Everything else stays the same. The other thing we need to do, because we're all about trying to save power for this example, is to make sure that we're using the Switch Mode Power Supply option rather than the LDO option. So as I think you saw with Anders, we go down to the Power and Thermal block, click on Power, and we need to make sure, if it's not set already, that the power regulator setting is for SNPS. Now, if you've done this in Qubemax, it probably will be SNPS automatically, but it's not that way if you use Qubemide, so we need to change that. So we select SNPS, and then we need to double check the clock settings. The default clock settings are probably right, but it's worth just checking. So we want to use MSIS, which is already selected, and this default configuration gives us an H clock of 4 MHz. We're not trying to run things really really super fast, because the whole point is we're trying to save power. Okay, so that's the peripheral setup. If I just go back to the pinout and configuration view that you're used to, you'll see that there's actually two discrete tabs here, one of them is new. It's called LP-BAM scenario and configuration, and this is an extra set of tools that are part of Qubemax and Qubemide that allows us to automate the process of generating link lists that are targeted for LP-BAM operation. So these are link lists that we're using with low power DMA, rather than GP-DMA, and they're going to be used in stop-to mode. So we shift our focus to the LP-BAM scenario editor, and we do that just by clicking on that tab, double-clicking on it rather, and it should bring up this new screen, and we know we're in the LP-BAM tool because the background changes from the sort of ST blue to this pink or red colour. And first thing we need to do is click on the add application icon here under LP-BAM manager. This will open up a new configuration for us, and in this left-hand pane, this is where we have access to all of the individual peripherals that are active or can be active in this smart run domain. So we've got ADC4, which we're going to use in a minute, and LP-Timer1. So we select the components from this area, and then we have our queues displayed in this middle panel, and then on the right-hand side is where we configure the queue as a whole and also the individual nodes, and you'll see me do that as we go along. So under scenario here, we have a default queue name already allocated, but we're going to change that to something a little bit more informative, so we'll call it timer. So we're creating one queue for the timer, and we want to create another queue, so if I click on add queue, and we call this ADC, then hit return. So now in our queue editor view, we have two individual tabs, timer and ADC. We can see the cursor move here when we swap tabs. So these are our two separate DMA channel queues. Now we need to actually configure them. So if you select the timer queue, you can either select it from clicking on the actual tab here, or you can select it by selecting under the scenario editor, but it doesn't matter, but it's important that the timer queue is selected, and we want to now add the functionality or the individual nodes of this queue that we wish to use. So we go, because this is a timer queue, we want to configure the LP timer one, LP TIM, we select that, expand it, and now we have some options. And first of all, we want a start block. So click on start, and then, and this is used to configure the timer. Okay, it's just to do the initial configuration and to start the timer itself. But if you remember, we wanted two separate configurations for the timer. One to sample at 256 hertz, and one to sample at 64 hertz. So we have two PWM blocks that we want to add. So we go to PWM, click plus, and that gives us a configuration block for PWM mode. And we want another one, so we click on it again. So eventually we should have three blocks. First one is initialization and start block, and then we have two blocks that control how the PWM function is working. Okay, so that's how we want to configure the timer. We'll come back and do the actual detail configuration shortly. But now we want to go to the ADC tab, and this is swapping us to the ADC queue. And now we need to go to ADC four, and we need to select ADC conversion data. So here there are three different versions of ADC conversion. I'll try and explain what the differences are. Conversion config is simply a block that configures the ADC. So which ADC channel is being used, what it sample rates are, et cetera. Conversion data is a block that just includes a configuration for transferring data from the ADC into memory. So what's its destination, and how many words, et cetera, et cetera. And conversion is a mixture of both of those two. So it configures the device and transfers the data. So if we were to look at config, I don't actually, I don't want to actually add it, but it combines both of them. Now, in this particular case, our queue only needs the data version because it's being configured in another set of settings that we'll come on to later when we come on to the pinout configuration. So you should have two tabs here, timer with three elements, start PWM two and three. And on the ADC tab, we should have one element, which is the ADC conversion data. So now we actually want to configure these two individual DMA queues. So let's go to the timer tab. Okay. And we need to select, we need to make sure that we click on the first block in the timer queue, the start function. And we need to change the start mode from single to continuous. If we don't do that, you'll get one conversion and that will be it basically, or one set of conversions. Okay. Then we go to the PWM configuration and we want to set up here. We want to set up the period and the pulse width. But first of all, we need to enable those settings. So for period update state, we select enabled. Same for pulse update and repetition state. Okay. Now, we need to set the period value, pulse value and repetition value. And in the cheat sheet, we actually explain where those figures come from. And the key thing is that in the next few steps, we will configure the timer clock to be LSI, which is 32 kilohertz with a prescalar of one. So if we then go through and work out what these period values should be, we come to the figure of 127 for the period value. The pulse value is 63 and the repetition counter is 255. So I'll go and fill those values in. So period value is 127. So that needs to go here. Pulse value is 63 and repetition value is 255. Okay. So that's the first counter and that was 256 hertz. Then we want to sample at 64 hertz. So we go to the second PWM block. And we need to enable the period update, pulse update and repetition update. The values this time, it's 511 for the period value. It's 255 for the pulse value and it's 63 for the repetition value. And just to show you again that the working is there, be a little bit careful because if you look at the animation, if I recall correctly, in the animation, the values used are wrong, but use these values in the cheat sheet here. So we've configured the timer settings. Now we need to go to the ADC queue. Okay. And we need to enable the transfer complete interrupt. So this one here. So once it's completed, it's transferred, it raises an interrupt. And this is when you have the ADC selected. Okay. If you can't see it, it's probably because you've selected the actual block itself, but we're talking about the overall queue setting. So here we have transfer complete interrupt specified. So then go to the actual conversion data block itself and this is where we need to actually control how the ADC is, where it's transferring data from and to. So we need to know the buffer name that we're transferring into. So this is the data buffer name and we've called it, let me just delete it all, and in code we're using the variable name data sequence. So we use that. The data buffer offset. So where do we want to start writing into it? Well, we want to start to address zero or location zero. So let's put that in there. And then the size. If you remember, we were having 256 samples followed by another 64 samples. So that makes 320 samples in total. And that'll give us two seconds worth of sampling. So everything else can be left at it is. Now, what we've been doing here is we've been setting up our individual queues. We also can configure how these individual peripherals are configured in terms of which channels we're using and what pins they're using, et cetera. So we go next to the Pinout and Configuration tab. But this is a Pinout and Configuration tab that's part of the LP BAM scenario wizard. It has a potential to be confusing because you're used to a Pinout and Configuration wizard that's part of CubumX. But this is Pinout and Configuration tab within this LP BAM tool. So we click on it. And it looks just like the Pinout and Configuration tab within CubumX. And it is, but it's a subversion of it, a subset of it because it's only giving us the peripherals that we can use in this mode. Let me just extend that tab. So first thing we need to go to is the ADC channel and make sure that's configured correctly. So we go to ADC4 and we want to monitor the internal VREF. So we're just using one channel of ADC to monitor the internal voltage reference. So now we can go to the settings for this ADC mode. We go to parameter settings here a little bit bigger and we want to change a few settings. So we want to change the sequencer setting. So it's sequencer is here. Okay, under ADC settings, sequencer and it's currently set to sequencer set to fully configurable. Now, we need to set it to not fully configurable, which sounds a little strange, but this is essentially using the ADC in a legacy mode that's compatible with the subset of features that are available in LPBAM. So we need to set this to be able to modify some of the other settings. Okay, we need to generate or specify that we're using DMA Continuous Requests. So here they're setting here DMA Continuous Requests. We need to enable that. And just like we did with Jeff, so we don't get overflows, we want low power auto weight enabled. We can leave the sampling time at one and a half cycles. Nothing needs to be changed there. But we do need to enable the interrupt from the ADC for. So if we go to the Envig tab here, you can click on enabled and this turns on the interrupt for the ADC channel. Now, you may have noticed there's a check LPBAM design button here and this allows us to run some checks and basic sanity checks to make sure our configuration is okay. So we can click on it, but we should get some errors. We can see those. We've got some pink or red text and it's complaining because I haven't configured the LP timer. So we've specified the configuration for the peripheral itself. What we're doing here is specifying the configuration of the peripheral. What we did in the previous step was configure the queue. Okay, so now we're configuring the peripheral itself. We've only done the ADC. We have not done the timer yet. So we need to go to the timer and to configure that. So we select under the timers LP timer one and we need to enable it for a start. So we select it to count internal clocks. Okay, we need to set channel one active. And we want to set it to no IO used only internal input output connections. And if we scroll further down, we need to specify how the counter is being used. So under the compare option, capture compare selection here. We need to, at the moment it's configured by default to capture and we want to configure it to compare because we're setting a time period that we want to trigger on. So we set that to compare. And then although we've done it in the queue itself, we need to set a default initial configuration for the period and pulse width. So we go and we go to period and we use the same values as before. So it's 63 and then the pulse value down here is sorry, I used the wrong. So it should be 127 for period and pulse value should be 63. If we go into LP stop to mode, then we want to configure as many of the peripherals as possible. And then also the memory and flash blocks to be disabled so that we're saving power. So we would go down to the power and thermal tab. Go to the power block. And here, first of all, we need to double check that it's got SNPS selected and it should do. Now what we want to do is essentially turn off or power down all of the SRAM pages other than SRAM 4 and iCash. And let me just extend this box a little bit. So what we need to do is change these settings here. So we want to change all of them except SRAM 4 and iCash power down. And basically turn power them down in stop mode. What this means is that we get this slight inversion of the name because currently the feature is disabled and the feature is to power down in stop mode. And we want to power down in stop mode so we enable the feature. Very strange English, but that's the way it's been set up in the tool. So unfortunately there is no group select so we have to do these individually one by one. I'm afraid it's very tedious, but that's the way it is in the tool right now. So we go through each one and enable the power off function. The way to look at it. Go down all of them. Turning everything off so it's not going to get used. Now we leave SRAM 4 enabled because that's where we want to store our linked list configuration. We use iCash as well again because when we do boot the processor up we want it to be running from cache. But decache can go off. These settings can be off. And SRAM 4 fast wake up will leave this disabled because we're going for the ultimate in low power so we can leave that disabled. Just before I leave this tab, if I go to the further up this screen, we can look at the debug pins. So if you remember I mentioned that with three signals that could be mapped to GPIO pins. And these can be enabled for you to monitor these signals. And we do talk about that in the debug section in the cheat sheet. But we don't have time to run through that today and we don't have logic analyzers either to compare it against. So we'll leave that as it is, but I just wanted to highlight to you that they were there. So now we do need to make sure that we are configuring the clocks correctly for this DMA queue. So again, we have a tab that's very, very similar to the standard QMX tab for clock configuration. But again, it's the tab you want is part of this LP BAM scenario configuration tool. So if you click on that, you should know that you're in the right tool because the background to the tab is still is pinky red color. Don't go back to the pin out and configuration tab up here because you'll be editing the wrong information. This is part of the LP BAM tool. So for the low power timer, if you remember I mentioned that we were going to use LSI. So we need to select LSI for the low power timer because currently it's set to MSI K. So let's select LSI and it's a 32 K clock. So that's where we got our values for the counter timer periods, etc. Now the ADC 4, we want to clock that one. So this is ADC 4 clock MUX. We want to select MSI K for that one, which sets it at 4 MHz. This is the rate that the peripheral is being driven at. Its core clock is 4 MHz. If we go up to the top of the screen, we just verify that the wake up clock, so the clock we use to wake up from stop mode is configured for MSI. Because we're using this tool as part of the LP BAM setup, it's assuming that we're running in the stop modes. And in the stop modes, you don't have access to the PLLs, you don't have access to many of the other clocks. So everything that you don't have access to is grayed out. And this is to give a clue to you that actually you're in LP BAM mode and that we shouldn't be using these components. So that's why we still get the full clock tree, but you can't configure most of the options. Now, if we now click on the check LP BAM design, we shouldn't get any pink or red warnings or errors anymore because we've configured the timer, we've configured the ADC. Now, we've done in the LP BAM tool, so we go and click back on the standard.ioc tab up here, which brings us back to the standard CubeMX perspective that we're familiar with. So if we click on that, it will change the focus back to the CubeMX standard tool, eventually. Oh, sorry. Basically, you can't see it because it's off-screen, but it gave me a little dialogue that it's checking the data and building the interface to GUI. So now we're back to what we understand as CubeMX perspective. There is one thing that we need to do to change in the project manager code generation setting. So we go to project manager and go to code generator. We want to set in the how. We want to set all three pins and log. Okay. This is just to, again, to reduce power consumption. So any pins are not using. Rather than having them floating around, we'd set them to analog and that reduces power consumption. We don't need to set any of the project settings up because we did this when we created the CubeID project right from the start. So this is the different way of getting into CubeID. It was just doing everything from within CubeID. So it saves you having to specify the project location, et cetera, because you've done that in the project creation wizard. So if we now save this configuration by hitting the save button or we can click on the generate code button. It doesn't matter which one we use, but if I hit save, it will ask me, do I want to generate code? Yes, we do. And this will now swap the configuration perspective back to the code editing configuration and generate the code. So I click yes to this and we come back to the standard CubeID configuration and it generates code.