最近这几天一直在做L151芯片的低功耗,想用RTC wakeup唤醒。具体思路是这样子的,设置2S定时器,定时器到了之后进入低功耗模式(sleep,standby,stop模式),串口一用来指示作用。RTCwakeup时间到之后进行唤醒,重复这样的工作。现在进入不了低功耗,只有在stop模式下能进去,但是测得电流200-300uA太大了,不正常,所以请教各位。有之前做过的可以加我QQ1056750949,交流一下,感激不尽。这部分是主函数 int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* 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...\r\n"); 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...\r\n"); } if(Wakeup_Set()) { Clear_Wakeup(); SystemClock_Config(); // ÖØÐÂÅäÖÃϵͳʱÖÓ MX_USART1_UART_Init(); printf("Exit from SLEEP Mode...\r\n"); } } |
STM32L151RDT6 SDIO读写SD卡 FIFO下溢错误,不知是什么原因
STM32L152 RTC唤醒STOP mode问题
STM32L152系列自带LCD驱动段码液晶屏,怎么驱动想要亮的段亮
STM32L151为何FLASH擦除后全是是0x00?
求助!!STM32L151中的RTC唤醒(wake up)中断问题
STM32L152普通I/O模拟SPI驱动W25Q16问题
STM32L152开发板原理图及说明文档
STM32L1系列,如何释放PA15为普通GPIO端口
STM32L151读取W25Q16的ID错误,请帮忙看看是什么原因
STM32L151 STOP模式唤醒程序跑哪儿了
void MX_RTC_Init(void)
{
RTC_TimeTypeDef sTime;
RTC_DateTypeDef sDate;
/**Initialize RTC Only
*/
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 99;
hrtc.Init.SynchPrediv = 369;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
/**Initialize RTC and set the Time and Date
*/
if(HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR0) != 0x32F2){
sTime.Hours = 0x9;
sTime.Minutes = 0x30;
sTime.Seconds = 0x30;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
sDate.WeekDay = RTC_WEEKDAY_MONDAY;
sDate.Month = RTC_MONTH_JANUARY;
sDate.Date = 0x1;
sDate.Year = 0x0;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR0,0x32F2);
}
/**Enable the WakeUp
*/
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 8200, RTC_WAKEUPCLOCK_RTCCLK_DIV16) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
评分
查看全部评分
楼主怎么解决的,我最近也碰到了这个问题,端脚的模式也模拟输入了。。。