最近使用STM32G070实验的时候发现G070的RTC无法唤醒进入SLEEP模式下的CPU,不知道什么原因。
void PWR_Enter_Sleep(void)
{
/* Enable PWR clock */
__HAL_RCC_PWR_CLK_ENABLE();
/* Disable Prefetch Buffer */
__HAL_FLASH_PREFETCH_BUFFER_DISABLE();
RCC->IOPSMENR = 0x00u;
RCC->AHBSMENR = 0x00u;
RCC->APBSMENR1 = 0x00u;
RCC->APBSMENR2 = 0x00u;
/*Suspend Tick increment to prevent wakeup by Systick interrupt.
Otherwise the Systick interrupt will wake up the device within 1ms (HAL time base)*/
HAL_SuspendTick();
/* Enter Sleep Mode , wake up is done once User push-button is pressed */
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
HAL_ResumeTick();
}
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtc)
{
LCD_ON();
LCD_HZ_1616(16*numbx,32,1,BLUE,WHITE);
numbx++;
}
运行中发现每次必须使用按键才能唤醒CPU,同时显示的字符会更新。 |