自己按着 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);
}
|