![shequ.stmicroelectronics.cn](./template/st_v1/static/img/logo2.png)
如题,使用stm8L101调用halt()进入低功耗,外部中断唤醒,测试功耗达到40uA,和手册上0.4uA相去甚远。查找网上资料,需要调用 PWR_FastWakeUpCmd(DISABLE)![]() 这两个函数,然而调用编译出错:没有找到这两个函数的定义。如果我调用PWR->CSR2 = 0x02;也同样报错。 使用的库是官网下载的:STM8L10X-en.stsw-stm8012; This mode is entered by executing the following software sequence: 1. Switch off all unused peripherals, oscillators (except LSI or LSE) and analog blocks 2. Mask all interrupts 3. Jump to RAM 4. Switch system clock to LSI or LSE clock sources 5. Configure the Flash memory in IDDQ mode by setting the EEPM bit in the FLASH_CR1 register 6. Add a software delay loop to make sure the Flash/Data EEPROM are off 7. Configure the ultralow power mode for the regulator by setting the REGOFF bit in the CLK_REGCSR register (do not confuse with the ULP bit in the PWR_CSR2 which configures the behavior of the internal reference voltage). 手册中对于PWR只有一处解释,实在找不到解决的办法,求大神解释!!! |
void main(void)
{
GPIO_Init(GPIOA, GPIO_Pin_All, GPIO_Mode_Out_PP_High_Slow);//所有不使用的IO输出低电平
GPIO_Init(GPIOB, GPIO_Pin_All, GPIO_Mode_Out_PP_High_Slow);
GPIO_Init(GPIOC, GPIO_Pin_All, GPIO_Mode_Out_PP_High_Slow);
GPIO_Init(GPIOD, GPIO_Pin_All, GPIO_Mode_Out_PP_High_Slow);
GPIO_Init(LED_GPIO_PORT, LED_GPIO_PINS, GPIO_Mode_Out_PP_Low_Slow);//GPIO初始化
GPIO_Init(KEY_GPIO_PORT, KEY_GPIO_PINS, GPIO_Mode_In_PU_IT);//初始化按键,GPB1带上拉带中断输入
EXTI_DeInit (); //恢复中断的所有设置
EXTI_SetPinSensitivity (EXTI_Pin_1,EXTI_Trigger_Falling);//外部中断1,下降沿触发,向量号9
enableInterrupts();//使能中断
// PWR_FastWakeUpCmd(DISABLE);
// PWR_UltraLowPowerCmd(ENABLE);
while(1)
{
Delay(0xFFFF);
GPIO_SetBits (GPIOD,GPIO_Pin_0);
EXTI_DeInit();
CLK_DeInit();
// PWR->CSR2 = 0x02;
halt();//挂起,最低功耗
EXTI_SetPinSensitivity (EXTI_Pin_1,EXTI_Trigger_Falling);
}
}
1.关闭所有未使用的外设,振荡器(LSI或LSE除外)和模拟模块
2.屏蔽所有中断
3.跳转到RAM
4.将系统时钟切换到LSI或LSE时钟源
5.通过将FLASH_CR1中的EEPM位置1,来配置闪存的IDDQ模式寄存器
6.添加软件延迟循环以确保Flash /Data EEPROM 已关闭
7.通过设置CLK_REGCSR寄存器的REGOFF位来配置稳压器的超低功耗模式
(不要与PWR_CSR2中的ULP位混淆,它是配置内部参考电压的)。
评分
查看全部评分