Skip to main content
Graduate
June 18, 2024
Solved

Stop/Sleep mode for Low Layer lib

  • June 18, 2024
  • 2 replies
  • 2458 views

i am using STM32C011F6P6 and try to enter stop mode by

LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);

LL_LPM_EnableDeepSleep();

__WFE();

the current is little bit more than not entering the shutdown mode
and the clock is not stopping

is there any thing I should do first?

 

and i want to monitor the adc input for wake from sleep mode 

is that possible?
i search for some example on web, most of them are using __WFI  and use GPIO or TIMER to wake up

i think it maybe possible on __WFE? but i can't find much example on web

    This topic has been closed for replies.
    Best answer by Sarra.S

    Hello again @uveuvenouve

    To enter shutdown mode, you can follow this sequence 

    LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN;
    LL_LPM_EnableDeepSleep();
    LL_PWR_ClearFlag_WU(); //clear any pending wake-up flags that might inadvertently wake up the MCU immediately after entering shutdown mode
    __WFI(); // In shutdown mode, the __WFE(); instruction is typically not used because most peripherals, including the event system, are powered down.

     You can use either the __WFE(); or __WFI(); instruction to enter sleep mode

    the note "Unchanged" in Sleep mode means that the peripheral retains its state or configuration and continues to operate as it did before entering Sleep mode so it is possible to use it.

    You can find low-layer power examples here: STM32CubeC0/Projects/STM32C0116-DK/Examples_LL/PWR at main · STMicroelectronics/STM32CubeC0 · GitHub

    Unfortunately, there is no ready-to-use example using ADC, you'll need to configure it, but you can always ask separate questions while doing it! 

    2 replies

    ST Employee
    June 18, 2024

    Hello @uveuvenouve

    Waking up from shutdown mode using ADC events is not typically supported because the ADC is already powered down in shutdown mode, Please check this table in RM0490: 

     

    SarraS_0-1718696506359.png

     

    Graduate
    June 18, 2024

    Hi Sarra,

    Thanks for your information.

    The problem is i cannot enter shutdown mode with that 3 line of code.

    I saw some information for shutdown mode and I know the clock will be suspended which mean ADC will not be able to work
    So I wonder whether sleep mode can do such a thing

    On the table ,it state "U" in sleep mode for ADC, which is unchanged.

    The point is i want to deploy a function that adc wake the mcu from sleep mode with low layer lib, but I can't find examples.

    1. enter sleep mode and shutdown mode

    2. set up WFE/WFI with ADC

    Sarra.SAnswer
    ST Employee
    June 20, 2024

    Hello again @uveuvenouve

    To enter shutdown mode, you can follow this sequence 

    LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN;
    LL_LPM_EnableDeepSleep();
    LL_PWR_ClearFlag_WU(); //clear any pending wake-up flags that might inadvertently wake up the MCU immediately after entering shutdown mode
    __WFI(); // In shutdown mode, the __WFE(); instruction is typically not used because most peripherals, including the event system, are powered down.

     You can use either the __WFE(); or __WFI(); instruction to enter sleep mode

    the note "Unchanged" in Sleep mode means that the peripheral retains its state or configuration and continues to operate as it did before entering Sleep mode so it is possible to use it.

    You can find low-layer power examples here: STM32CubeC0/Projects/STM32C0116-DK/Examples_LL/PWR at main · STMicroelectronics/STM32CubeC0 · GitHub

    Unfortunately, there is no ready-to-use example using ADC, you'll need to configure it, but you can always ask separate questions while doing it!