2017.11.27 stm8 low power-consumption debugging

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();
}
}

转载于:https://www.cnblogs.com/huangbaobaoi/p/7903415.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值