AT32 进入深度睡眠模式(Deepsleep Mode)前需要关闭 SysTick 定时器,否则会导致进入 Deepsleep 模式后再次被 SysTick 定时器唤醒的现象。 AT32F403A 代码示例如下,其他型号请参考对应 BSP 路径\examples\pwc 下 Deepsleep 例程。
/* clear second flag */
rtc_flag_clear(RTC_TS_FLAG);
/* wait for the second flag to be set */
while(rtc_flag_get(RTC_TS_FLAG) == RESET);
/* set the wakeup time to 3 seconds */
rtc_alarm_set(rtc_counter_get() + 3);
/* wait for the register write to complete */
rtc_wait_config_finish();
at32_led_off(LED2);
/* save systick register configuration */
systick_index = SysTick->CTRL;
systick_index &= ~((uint32_t)0xFFFFFFFE);
/* disable systick */
SysTick->CTRL &= (uint32_t)0xFFFFFFFE;
/* congfig the voltage regulator mode */
pwc_voltage_regulate_set(PWC_REGULATOR_LOW_POWER);
/* enter deep sleep mode */
pwc_deep_sleep_mode_enter(PWC_DEEP_SLEEP_ENTER_WFI);
/* restore systick register configuration */
SysTick->CTRL |= systick_index;
/* wake up from deep sleep mode, congfig the system clock */
system_clock_recover();
at32_led_on(LED2);
for(index = 0; index < 500000; index++);
|