Skip to main content
KKURT
Associate
March 15, 2019
Question

STM8L051

  • March 15, 2019
  • 5 replies
  • 1602 views

Hi, I am not sleeping this microcontroller. I search example code but I couldnt find it please help me. Thanks.

    This topic has been closed for replies.

    5 replies

    Sisto Zànier
    Senior
    March 15, 2019

    /*

    hi, I don't know what you mean, but to sleep the micro you can use Halt mode.

    This can be a possible solution:

    To enter HALT mode:

    */

    void HALT_INIT (void)

    {

      ADC_Cmd (ADC1, DISABLE);

      PWR_PVDCmd (DISABLE);

      / * Switch to LSI as system clock source * /

      / * system clock prescaler: 1 * /

      CLK_SYSCLKDivConfig (CLK_SYSCLKDiv_1);

      CLK_SYSCLKSourceConfig (CLK_SYSCLKSource_LSI);

      CLK_SYSCLKSourceSwitchCmd (ENABLE);

      while (CLK_GetFlagStatus (CLK_FLAG_LSIRDY) == 0);

      CLK_HSICmd (DISABLE);

      CLK_HSEConfig (CLK_HSE_OFF);

    CLK_HaltConfig (CLK_Halt_SlowWakeup, ENABLE);

      / * Set STM8 in low power * /

      PWR_UltraLowPowerCmd (ENABLE);

    }

    .....

    void main ()

    {

    INIT_MICRO_PARAMS (); // Depending from your hardware and GPIO configurations

    INIT_ADC_PARAMS ();

    #if (_USE_RTC)

    INIT_RTC (); 

    CLK_HaltConfig (CLK_Halt_SlowWakeup, ENABLE);

    #endif

    enableInterrupts ();

    while (1)

    {

     // insert here Your code executed in run mode

     HALT_INIT (); // Switch oscillator from HSI to LSI

     halt (); // Enter "Active-Halt" mode for halt consumption of about 5uA. 

     // in debug mode with ST-LINK/V2, use wfe() instead of halt()

    }

    }

    /*

    To exit from HALT mode you can use a micro Reset, or a periodic interrupt from RTC properly configured to generate it, or a GPIO interrupt (see reference manual RM0031)

    I hope thi suggestion can help You

    */

    KKURT
    KKURTAuthor
    Associate
    March 18, 2019
    [cid:02918b84-722e-4abc-8254-4b0cc93952d5][cid:2443039c-cf3d-4f5d-8eaa-5f61e327cfc9]

    Thank you for your interest. Halt mode current normally 5uA but me 92uA this too much. I think I'm doing something wrong. Don't understand. Can you help me this topic?
    Max
    ST Employee
    March 18, 2019

    Hello, have you looked at AN3147?

    KKURT
    KKURTAuthor
    Associate
    March 26, 2019
    I tried but not again. What else can I do?
    Cristian Gyorgy
    Associate II
    March 31, 2019

    How do you measure the 92 µA? Does you MCU not wake up and do things between sleeping?

    Post your schematics. Active pull-ups, ports, or other consumers?

    You should post more info if you want help.