 So we go back to our IAR software where we left off and If we now scroll down to the app body task Which starts about line one seven five and just before the infinite loop We need to paste in our Commands for clock gating So if we go and copy Commands here, so if we highlight this and copy them and if we paste them into our code Like that Do a bit of tidying up and now we can build our project and We want to go project Download download active application again And that will put the latest version into our board We then reset our target board on my board now I am getting about six milliamps in stop mode and about eight milliamps in run mode so That gives us about another 15 percent Reduction slightly more on mine. I'm about 20 percent reduction in stop mode And I'm about 15 percent reduction in play mode there on mine So so you can see now the current consumption is slowly coming down steadily within our project So what else can we do inside the hardware to actually reduce the current consumption? so inside the GPIO cell of every pin on the device we have a a pair of protection diodes The to pull up and pull down resistors, and we have a Schmidt trigger So this Schmidt trigger is going to consume power So the best way to disable that is to enable the unused IO pins to go to analog So as you can see the analog line comes off before the smith trigger And this can be done inside the cuba mechs tool environment So there is an option here in to disable all unused gi pios and set them to be analog inputs On most devices that would save us some current consumption But as you can see from the snapshots here from the data sheets Analog mode is actually the reset state of all GPIO pins in the STM32 L4 device So we can still make the setting inside the cuba mechs tool which would normally make a current consumption saving for any other device So if you go into the project settings and code generator Inside the cube and x tool There is a tick box where you can set all three pins To be analog to optimize the power consumption of this device As all pins are already default. This is not actually going to make us any change on our Audio player application. So the current consumptions we have at the moment Are going to remain exactly the same on the STM32 L4 Any other device that would make a substantial difference as well Disabling all those extra components inside the GPIO peripherals So we can also let the peripherals do The job using the DMA and put the core into a sleep mode So if you look at a typical example there, the core would be asleep The ADC would be streaming data via the DMA into SRAM Then the core wakes up for a short period of time to process the data that you've just received And then the core goes back to sleep after starting the next process Which would to stream that process data out via the UART or an SPI we have a term inside the STM32 L4 which is called batch acquisition mode Which does exactly this type of process where the DMA and the SRAM are Powered and configured with the clock and the rest of the chip including the core are in sleep mode So you can optimize your power transfer of data that's been received from sensors as an Suggested application here on the screen and then processed and sent out to some sort of Low power UART or USART to the outside world If we look at our application we have here on our audio player We have the situation where the core is asleep The quad SPI is streaming information into a RAM block ready to be processed by the core in parallel a Second RAM block is being used with one of the other DMAs and streaming the audio signals out to our headphones Then our core wakes up Processes the batch of data that's just coming from the quad SPI ready to be sent out Then the core goes back to sleep As soon as DMA number two reaches the end of its area The buffers will switch around So that you get a seamless audio stream coming out of the SAI audio peripheral And then the quad SPI will then start filling the buffer be them with the next batch of data ready to be processed by the core And the cycle continues like that Going on inside the application