1 STM8L+LCD

The STM8L-DISCOVERY helps you to discover the STM8L ultralow power features and to
develop and share your applications. It is based on an STM8L152C6T6 and includes an
ST-Link embedded debug tool interface, LCD (24 segments, 4 commons), LEDs and push
buttons.

Figure 1. Hardware block diagram

 

2 Sleep mode

 

3 I/O current injection susceptibility

 

4 Low-power coding

    The key is turn off I/O

void sleep_enter(void)
{
//off LCD
disableInterrupts();
prog_enter_sleep();
disp_enter_sleep();
LCD_Com_Page(0);
LCD_Cmd(DISABLE);
//disable 16Hz
RTC_WakeUpCmd(DISABLE);
GPIO_Init(POWER_12V_PORT,POWER_12V_PIN,GPIO_Mode_In_PU_IT);
//disable ADC Clock
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, DISABLE);
enableInterrupts();
}

void sleep_exit(void)
{
disableInterrupts();
key_init();
temper_init();
//disable 16Hz
RTC_WakeUpCmd(ENABLE);
//disable ADC Clock
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
//off LCD
LCD_Cmd(ENABLE);
GPIO_Init(POWER_12V_PORT,POWER_12V_PIN,GPIO_Mode_In_PU_No_IT);
enableInterrupts();
ADC_SoftwareStartConv(ADC1);
key_flag.f.disable=1; //clear the default key input
sys_time_load();
}


void sleep_func(void)
{
if((GPIO_ReadInputData(POWER_12V_PORT)&POWER_12V_PIN)==0){
sleep_enter();
_sleep_loop:
if((GPIO_ReadInputData(POWER_12V_PORT)&POWER_12V_PIN)!=0){
goto _sleep_exit;
}
halt();
if((GPIO_ReadInputData(POWER_12V_PORT)&POWER_12V_PIN)==0){
goto _sleep_loop;
}
_sleep_exit:
sleep_exit();
}
}