2019-03-15 04:21 AM
Hi, I am not sleeping this microcontroller. I search example code but I couldnt find it please help me. Thanks.
2019-03-15 08:39 AM
/*
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
*/
2019-03-18 01:37 AM
2019-03-18 08:43 AM
Hello, have you looked at AN3147?
2019-03-26 12:07 AM
2019-03-31 06:11 AM
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.