- int main(void)
- {
- __IO uint32_t index = 0;
- __IO uint32_t systick_index = 0;
-
- /* enable pwc clock */
- crm_periph_clock_enable(CRM_PWC_PERIPH_CLOCK, TRUE);
- /* congfig the system clock */
- system_clock_config();
- /* init at start board */
- at32_board_init();
- /* turn on the led light */
- at32_led_on(LED2);
- at32_led_on(LED3);
- at32_led_on(LED4);
-
- delay_ms(300);
- /* config usart1 */
- usart1_config(2400);
- usart1_wakeup_config();
- printf("exit deepsleep mode by usart1 rdbf interrupt \r\n");
- while(1)
- {
- at32_led_off(LED2);
- printf("now enter deepsleep mode \r\n");
- /* make sure that no usart receiver is ongoing */
- while(usart_flag_get(USART1, USART_OCCUPY_FLAG) == SET)
- {
- }
-
- /* select system clock source as hick before ldo set */
- crm_sysclk_switch(CRM_SCLK_HICK);
- /* wait till hick is used as system clock source */
- while(crm_sysclk_switch_status_get() != CRM_SCLK_HICK)
- {
- }
-
- /* reduce ldo before enter deepsleep mode */
- pwc_ldo_output_voltage_set(PWC_LDO_OUTPUT_1V0);
- while(usart_flag_get(USART1, USART_TDC_FLAG) == RESET)
- {
- }
-
- /* congfig the voltage regulator mode.only used with deep sleep mode */
- pwc_voltage_regulate_set(PWC_REGULATOR_LOW_POWER);
-
- /* enter deep sleep mode */
- pwc_deep_sleep_mode_enter(PWC_DEEP_SLEEP_ENTER_WFI);
- /* turn on the led light */
- at32_led_on(LED2);
-
- /* resume ldo before system clock source enhance */
- pwc_ldo_output_voltage_set(PWC_LDO_OUTPUT_1V2);
-
- /* wake up from deep sleep mode, congfig the system clock */
- system_clock_recover();
-
- /* wake up from sleep mode */
- printf("\r\nnow exit deepsleep mode by usart1 rdbf interrupt \r\n");
- printf("usart1_rdne_data = 0x%x\r\n", usart1_index);
- delay_ms(300);
- }
- }
该例程实测进入低功耗时的功耗如图,电流是258uA,远远大于手册中描述的8.54uA
于是我查看手册
MCU进入低功耗深度睡眠模式时,手册描述了LDO、PLL、内部和外部时钟源都会关闭,但是GPIO的模式保持进入深度睡眠模式之前不变,
而且258uA远小于运行模式时和睡眠模式PLL开启时的电流,所以可以确定MCU已经进入低功耗深度睡眠模式了,那么只剩下GPIO配置的原因导致功耗偏高。
运行模式时的电流
睡眠模式PLL开启时的电流
3、修改官方例程
在进入深度睡眠模式之前,把GPIO配置为模拟输入可以最省电,这里我直接把GPIO和串口配置的代码都屏蔽了
重新烧录,1.8V供电测试,测试功耗已经和手册描述的8.54uA十分接近
至此,测评结束。