打印

stm8l 怎么进入到低功耗....

[复制链接]
1357|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ackermander|  楼主 | 2017-7-27 11:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
自己按着 reference 就是进不去功耗还是有100多uA
/**
* 1. Jump to RAM √
* 2. Switch system clock to LSI or LSE clock sources √
* 3. Switch off the high speed oscillators, the ADC and all unused peripherals --
* 4. Mask all interrupts √
* 5. Switch off the Flash/Data EEPROM by setting EEPM bit in FLASH_CR1 register √
* 6. Add a software delay loop to ensure Flash/Data EEPROM off status
* 7. Configure the ultra-low-power mode for the regulator by setting the REGOFF bit in the CLK_REGCSR registe
*/

void switchoff_flash(void)
{
        FLASH->CR1 |= 0x08;
        while(((CLK->REGCSR)&0x80)==0x80);
       
        CLK->REGCSR |= 0X02;
        while(((CLK->REGCSR)&0x01)==0x01);
       
}
void mask_it(void)
{
        sim();
}
void switch_sysclk_lowpower(void)
{
                /* Select LSE as system clock source */
                CLK_SYSCLKSourceSwitchCmd(ENABLE);
                CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_LSE);
                /* system clock prescaler: 1*/
                CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
                while (CLK_GetSYSCLKSource() != CLK_SYSCLKSource_LSE)
                {}
}
void switchoff_peripherals_oscillators(void)
{
        CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, DISABLE);  
        CLK_PeripheralClockConfig(CLK_Peripheral_DAC, DISABLE);   
        CLK_PeripheralClockConfig(CLK_Peripheral_TIM3, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_TIM5, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_I2C1, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_SPI1, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_USART1, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_BEEP, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_TIM1, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_LCD, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_DMA1, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_RTC, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_COMP, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_BOOTROM, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_AES, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_TIM5, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_SPI2, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_USART2, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_USART3, DISABLE);
        CLK_PeripheralClockConfig(CLK_Peripheral_CSSLSE, DISABLE);
       
        // 失能 ADC
        ADC_Cmd(ADC1, DISABLE);
}

相关帖子

沙发
ackermander|  楼主 | 2017-7-27 11:05 | 只看该作者
特别是加了
CLK->REGCSR |= 0X02;
        while(((CLK->REGCSR)&0x01)==0x01);
之后 电流直接到了 6mA

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

3

帖子

0

粉丝