最近这几天一直在做L151
芯片的低功耗,想用RTC wakeup唤醒。具体思路是这样子的,设置2S定时器,定时器到了之后进入低功耗模式(sleep,standby,stop模式),串口一用来指示作用。RTCwakeup时间到之后进行唤醒,重复这样的工作。现在进入不了低功耗,只有在stop模式下能进去,但是测得电流200-300uA太大了,不正常,所以请教各位。有之前做过的可以加我QQ1056750949,交流一下,感激不尽。这部分是主函数
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configura
tion----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
__HAL_RCC_PWR_CLK_ENABLE();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_RTC_Init();
MX_USART1_UART_Init();
MX_TIM2_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim2);
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
if(ReadTimer() == 2)
{
Clear_Timer();
printf("Ready to Enter SLEEP Mode...
");
MX_GPIO_Init(); // °ÑËùÓÐÒý½Å¹Ø±Õ
HAL_PWREx_EnableUltraLowPower();
HAL_PWREx_EnableFastWakeUp();
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI); // ½øÈëµÍ¹¦ºÄÍ£»úģʽ
//HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
//HAL_PWR_EnterSTANDBYMode();
printf("Enter SLEEP Mode Failed...
");
}
if(Wakeup_Set())
{
Clear_Wakeup();
SystemClock_Config(); // ÖØÐÂÅäÖÃϵͳʱÖÓ
MX_USART1_UART_Init();
printf("Exit from SLEEP Mode...
");
}
}
一周热门 更多>