1、进入睡眠的关键语句 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); 2、进入低功耗需要的配置,GPIO配置原则:不回路,不悬空输入。下面是将所有IO输出为0 //输出
GPIOA->MODER = 0x55555555;
GPIOB->MODER = 0x55555555;
GPIOC->MODER = 0x55555555;
GPIOD->MODER = 0x55555555;
GPIOF->MODER = 0x55555555;
//即不上拉,也不下拉
GPIOA->PUPDR = 0x00000000;
GPIOB->PUPDR = 0x00000000;
GPIOC->PUPDR = 0x00000000;
GPIOD->PUPDR = 0x00000000;
GPIOF->PUPDR = 0x00000000;
//输出0
GPIOA->ODR=0x00000000;
GPIOB->ODR=0x00000000;
GPIOC->ODR=0x00000000;
GPIOD->ODR=0x00000000;
GPIOF->ODR=0x00000000;
3、非常重要:在配置IO之前,一定要先开启GPIO时钟 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
好了,以上三点在程序中的顺序是反的,配置好之后,11uA! 如果第2点之前没有第3点,则2.6mA。
|