STM8L RTC唤醒 功耗
时间:10-02
整理:3721RD
点击:
STM8L RTC唤醒 功耗远远高于 1uA 求大神 指导
- <font size="4">void sleep(void)
- {
- GPIOA->DDR=0xFF;
- GPIOA->CR1=0xFF;
- GPIOA->CR2=0x00;
- GPIOA->ODR=0X00;
-
- GPIOB->DDR=0xFF;
- GPIOB->CR1=0xFF;
- GPIOB->CR2=0x00;
- GPIOB->ODR=0X00;
-
- GPIOC->DDR=0XFF;
- GPIOC->CR1=0XFF;
- GPIOC->CR2=0X00;
- GPIOC->ODR=0X04;//休眠前 应置F113的ASK脚为高电平 以降低功耗
-
- GPIOD->DDR=0XFF;
- GPIOD->CR1=0XFF;
- GPIOD->CR2=0X00;
- GPIOD->ODR=0X00;
-
- CLK->PCKENR1=0x00;
- CLK->PCKENR2=0x00;
-
- WWDG->CR=0Xfe;
- PWR->CSR2=0X03;//内部参考电压 关闭 以降低功耗0X03
- }
- void RTC_init(void)
- {
- CLK->PCKENR2 |= 0x04; //外设RTC时钟允许
- CLK->CRTCR |= 0X04;
- while( (CLK->CRTCR&0x01) == 0x1 );//CLK_CRTCR[0]=1为忙
-
- RTC->WPR = 0xCA;
- RTC->WPR = 0x53;
- RTC->CR2 &=~0X04;
- RTC->CR1 &=~0X07;
-
- while(( RTC->ISR1&0x04) == 0 );
-
- RTC->CR1 |= 0X02;
- RTC->WUTRH = 0xf0;//50
- RTC->WUTRL = 40;//40
- RTC->CR2 |= 0X04;
- RTC->CR2 |= 0X40;
- RTC->WPR = 0xFF;
-
- _asm("rim");
- }</font>