Skip to main content
MAndr.7
Associate II
May 18, 2023
Question

Power Optimization with STM32L4: Sleep Mode during SDMMC DMA Interrupts

  • May 18, 2023
  • 1 reply
  • 1811 views

Hello, fellow forum members,

I'm acquiring data from an ADC using DMA, and writing the filled buffer in SDCard, using SDMMC, also with DMA, on an STM32L452RC.

I recently came across an interesting challenge involving power optimization while waiting for an SDMMC DMA interrupt. I wanted to inquire if it is possible to put the device into a low-power sleep mode, or any other suitable, during this waiting period. My goal is to maximize power savings by allowing the device to enter a low-power state during periods of inactivity and only wake it up when the SDMMC DMA or ADC interrupts are triggered. There's any technical limitation to achieving it?

I also have been looking at the `sd_diskio.c` generated code and in the write and read methods there's a blocking condition which is released on the DMA callback is triggered:

timeout = HAL_GetTick();
while((WriteStatus == 0) && ((HAL_GetTick() - timeout) < SD_TIMEOUT)){}

So what's the point of using DMA if it's blocking the main loop?

Best regards

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
May 18, 2023

>>So what's the point of using DMA if it's blocking the main loop?

That perhaps you have multiple threads, or do things in interrupt context?

You could presumably put a __WFI() in the loop so the MCU wasn't grinding unnecessarily.

Most of the examples are "Hey Look it Works" not deliverable production code perfectly tailored to your application / use-case.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MAndr.7
MAndr.7Author
Associate II
May 18, 2023

Hi @Community member​ 

Can you give me some more context? So do you think that's possible to insert a _WFI() in the write operation loop? So any interrupt that occurs in every DMA will wake up the device?

By the way, can you tell me in which state will the device fall if I insert the _WFI instruction?

Regards