cancel
Showing results for 
Search instead for 
Did you mean: 

STM8L051

KKURT
Associate II

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

5 REPLIES 5

/*

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

*/

[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

Hello, have you looked at AN3147?

KKURT
Associate II
I tried but not again. What else can I do?
Cristian Gyorgy
Senior III

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.