完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
是这样的,我用STOP模式外部中断唤醒,在唤醒后再次进入STOP模式后发现功耗比第一次开机直接进入STOP模式高了300uA,所有IO口都配置了,外设也都关闭了,就是找不到原因第二次增加的功耗哪来的,求大神赐教,问题解决后有偿,谢谢!
代码如下: int main(void) { delay(2000); INT16U wReadTemp; HAL_Init(); SystemClock_Config(); MX_GPIO_Init(); // VDD1_ON(); // VDD2_ON(); // VDD3_ON(); RTC_Init(); ADC_Init(); sEepromGPIOInit(); //MX_IWDG_Init(); // 打开看门狗 UART_Init(); ADXL355_Init(); // ADXL355SPI配置初始化 SX1278_LoraInit(); while(1) { if(i == 1) { i = 0; printf("Enter STOP Modern"); LowPower_enter_stop(10); //Enter STOP } if(Incl_Data_Ready == 1) { Incl_Data_Ready = 0; i = 1; Get_WakeUp(); //初始化外设 // XL355_Temp_Calc(); // // XL355_Accel_Read(); // printf("Accl: X=%f Y=%f Z=%frn",sIncl_Data.f32_Accl_Xaxis,sIncl_Data.f32_Accl_Yaxis,sIncl_Data.f32_Accl_Zaxis); // // tilt_Angle_Calc(&sIncl_Data); // printf("Angle: X=%f Y=%f Z=%frn",sIncl_Data.f32_shunxian_Angle_arc_o,sIncl_Data.f32_hengxian_Angle_arc_o,sIncl_Data.f32_zonghe_Angle_arc_o); } } } void LowPower_enter_stop(uint32_t stoptime) { uint32_t i; SX1278_SetSleepMode(); // LORA模块休眠 HAL_TIM_Base_Stop_IT(&htim2); //VDD1_OFF(); //VDD2_OFF(); //关闭ADXL355 PA3 //VDD3_OFF(); // SPI_ADXL355_S_WRITE(XL355_RESET,0x52); //重启ADXL355 // SPI_ADXL355_S_WRITE(XL355_POWER_CTL, 0x01); //配置寄存器为StandBy模式 待机 //读1278每个IO口状态 printf("SX1278: %d",HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_12)); //1 CS printf("%d",HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_13)); //0 SCLK printf("%d",HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_14));//0 MISO printf("%d",HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_15));//1 MOSI printf("%d",HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_12));//1 RST printf("%d",HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_7)); //0 printf("%d",HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_8));//0 printf("%d",HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_11));//0 printf("%d",HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_6));//0 printf("%d",HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_8));//0 printf("%drn",HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_9));//0 //读355每个IO口状态 printf("ADXL:%d",HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_7));//0 printf("%d",HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_6));//0 printf("%d",HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_5));//0 printf("%d",HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_4));//1 printf("%d",HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_2));//0 INT2 printf("%drn",HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_8));//0或1 DataReady单独判断 已断开 //读EEPROM IO口 原理图为上拉 printf("EEPROM: %d",HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_11)); // printf("%d",HAL_GPIO_ReadPin(GPIOD,GPIO_PIN_2)); // printf("%drn",HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_3));// /* Enable Power Control clock */ __HAL_RCC_PWR_CLK_ENABLE(); /* Enable Ultra low power mode */ HAL_PWREx_EnableUltraLowPower(); /* Enable the fast wake up from Ultra low power mode */ //HAL_PWREx_EnableFastWakeUp(); GPIO_InitTypeDef GPIO_InitStructure = {0}; __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); //EEPROM GPIO_InitStructure.Pin = GPIO_PIN_11; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_2; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_3; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); //SX1278 PB12,15 GPIO_InitStructure.Pin = GPIO_PIN_12 | GPIO_PIN_15; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); //SX1278 PB13 14 GPIO_InitStructure.Pin = GPIO_PIN_13 |GPIO_PIN_14; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); //SX1278 RESET GPIO_InitStructure.Pin = GPIO_PIN_4 | GPIO_PIN_12; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); //sx1278 IO口 DIO0-5 GPIO_InitStructure.Pin = GPIO_PIN_2 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); // A7 6 5 A8 11 GPIO_InitStructure.Pin = GPIO_PIN_7 |GPIO_PIN_6 | GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_11; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_PULLDOWN; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); //对剩余所有IO口进行配置 留PA3 PA15 PB4通断开关 PA12 sx1278 GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_13 | GPIO_PIN_14| GPIO_PIN_15; GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); // GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11; GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_All; GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStructure); //留PC3外部中断 GPIO_InitStructure.Pin = GPIO_PIN_0 |GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_10 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15 ; GPIO_InitStructure.Mode = GPIO_MODE_ANALOG; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOD, &GPIO_InitStructure); __HAL_RCC_GPIOA_CLK_DISABLE(); __HAL_RCC_GPIOB_CLK_DISABLE(); __HAL_RCC_GPIOC_CLK_DISABLE(); __HAL_RCC_GPIOD_CLK_DISABLE(); __HAL_RCC_GPIOH_CLK_DISABLE(); //关闭所有外设 功耗降低30uA HAL_UART_MspDeInit(&USART4_Handler); HAL_UART_MspDeInit(&USART1_Handler); HAL_ADC_Stop(&hadc); //关闭ADC HAL_ADC_MspDeInit(&hadc); HAL_SPI_MspDeInit(&Hspi);//SX1278 HAL_I2C_MspDeInit(&hi2c1);//MPU6050 HAL_TIM_Base_MspDeInit(&htim2); HAL_RTC_MspDeInit(&RTCHandle); HAL_SPI_MspDeInit(&hspi1); //ADXL355 // 禁用/启用调试端口,先打开时钟,下面2句函数功能一样! // __HAL_RCC_DBGMCU_CLK_ENABLE(); // HAL_DBGMCU_EnableDBGStopMode(); //// //HAL_DBGMCU_DBG_DisableLowPowerConfig(DBGMCU_STOP); //// // __HAL_RCC_DBGMCU_CLK_DISABLE(); //RTCHandle.Instance = RTC; //MX_RTC_Init(); // 若需要在低功耗模式下调试程序,可以打开此函数 //HAL_DBGMCU_DBG_EnableLowPowerConfig(DBGMCU_SLEEP | DBGMCU_STOP | DBGMCU_STANDBY); __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); // 清除唤醒标志 //__HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();//清除标志,否则第二次以后无法进入休眠 /*## Setting the RTC Wake up time ########################################*/ /* RTC Wakeup Interrupt Generation: Wakeup Time Base = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) Wakeup Time = Wakeup Time Base * WakeUpCounter = (RTC_WAKEUPCLOCK_RTCCLK_DIV /(LSE or LSI)) * WakeUpCounter ==> WakeUpCounter = Wakeup Time / Wakeup Time Base To configure the wake up timer to 4s the WakeUpCounter is: RTC_WAKEUPCLOCK_RTCCLK_DIV = RTCCLK_Div16 = 16 Wakeup Time Base = 16 /(~32768Hz) = ~488.3us Wakeup Time = ~4s = 0,410ms * WakeUpCounter ==> WakeUpCounter = 4s/488.3us = 8192 */ i = stoptime * 2048; // // // rtc 唤醒采用LSE时钟,第一参数,计数溢出唤醒;第二参数:进行16分频 // HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, i, RTC_WAKEUPCLOCK_RTCCLK_DIV16); // /* Enter Stop Mode */ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // // HAL_IWDG_Refresh(&hiwdg); //喂狗 // dogtimes++; //喂狗计数 // dogtimes2++; } |
|
相关推荐
1个回答
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
STM32F405驱动DS1302时钟模块,输出时间错乱该怎么排查?
2810 浏览 2 评论
stm32f405rgt6驱动DS1302ZN出现时间错乱问题
2420 浏览 1 评论
stm32用fsmc读取ad7606采集数据,数据不变,只有开发版复位才更新数据
2288 浏览 0 评论
2404 浏览 1 评论
1643 浏览 1 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 07:08 , Processed in 0.792212 second(s), Total 77, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4207