[STM32U3] 【STM32U385RG 测评】+不同低功耗模式测试

[复制链接]
 楼主| LiuDW091 发表于 2025-7-30 15:01 | 显示全部楼层 |阅读模式
本帖最后由 LiuDW091 于 2025-7-30 15:02 编辑

#有奖活动# #申请开发板# #申请原创#@21小跑堂

一、首先通原理图、数据手册,找到低功耗模式有关的介绍
559426889b12735d2d.png
56376889b137ed398.png
通过数据手册知道,低功耗模式分为这几种:sleep(睡眠)、stop(0/1/2/3)(停止),standby(待机)、shutdown(关机)。
通过串口选择不同的模式,然后进行此次低功耗模式测试实验。
二、IDE软件配置
PWR配置:
756536889b26833166.png

USART1配置:
16306889b29530b8a.png

ICACHE配置:
261186889b2ebb5c5e.png

NVIC配置:
14266889b31151340.png

RCC配置:
669806889b32e7b5e6.png

GPIO配置:
837776889b36608b53.png

三、代码调试
参考例程进行代码的添加、修改。
添加串口选择代码:
static const char limiter_lg[] = " *******************\r\n";
static const char start_lg[]   = " *      低功耗测试      * \r\n";

/* Configuration selection buffer */
static const char mode_select_lg[]    = "模式选择:                    \r\n";

/* Low power buffer */
static const char *const lowpower_mode_lg[] =
{
  "01    -->SLEEP mode     \r\n",
  " 02    -->STOP1 mode     \r\n",
  " 03    -->STOP2 mode     \r\n",
  " 04    -->STOP3 mode     \r\n",
  " 05    -->STANDBY mode   \r\n",
  " 06    -->SHUTDOWN mode  \r\n",
};

/* Footer buffer */
static const char system_lowpower_config_lg[] = " 选择的模式为: \r\n";
static const char start_measure_lg[]          = " 可以开始测试了 \r\n";





配置时钟,选择通道
System_StatusTypeDef system_ram_retention_config(System_LowPowerModeScenarioTypeDef scenario)
{
  System_StatusTypeDef status = SYSTEM_OK;

  /* Enable Power Clock */
  __HAL_RCC_PWR_CLK_ENABLE();

  /* Disable cache and clear flags for low power modes */
  if (scenario >= SYSTEM_LOWPOWER_S1)
  {
    HAL_ICACHE_Disable();
    HAL_ICACHE_DeInit();
    __HAL_ICACHE_CLEAR_FLAG(ICACHE_FLAG_BUSYEND | ICACHE_FLAG_ERROR);
  }

  HAL_PWREx_DisableSRAM2ContentStandbyRetention(PWR_SRAM2_FULL_STANDBY_RETENTION);
  HAL_PWREx_DisableRAMsContentStopRetention(PWR_SRAM1_FULL_STOP_RETENTION);
  HAL_PWREx_DisableRAMsContentStopRetention(PWR_SRAM2_FULL_STOP_RETENTION);
  HAL_PWREx_DisableRAMsContentStopRetention(PWR_FDCAN_USB_STOP_RETENTION);
  HAL_PWREx_DisableRAMsContentStopRetention(PWR_ICACHE_STOP_RETENTION);
  HAL_PWREx_DisableRAMsContentStopRetention(PWR_PKA_STOP_RETENTION);
  HAL_PWREx_DisableSRAMFastWakeUp();

  /* Wait that default config is effective */
  __DSB();

  /* Set specific configurations */
  switch (scenario)
  {
    /* Stop 1 - 8-Kbyte SRAM */
    case SYSTEM_LOWPOWER_S2:
    {
      HAL_PWREx_EnableRAMsContentStopRetention(PWR_SRAM2_PAGE3_STOP_RETENTION);
      break;
    }

    /* Stop 2 - 8-Kbyte SRAM */
    case SYSTEM_LOWPOWER_S3:
    {
      HAL_PWREx_EnableRAMsContentStopRetention(PWR_SRAM2_PAGE3_STOP_RETENTION);
      break;
    }

    /* Stop 3 - 8-Kbyte SRAM */
    case SYSTEM_LOWPOWER_S4:
    {
      HAL_PWREx_EnableRAMsContentStopRetention(PWR_SRAM2_PAGE3_STOP_RETENTION);
      break;
    }


    /* Standby - No retention */
    case SYSTEM_LOWPOWER_S5:
    {
      /* Do nothing */
      break;
    }


    /* Shutdown - No retention */
    case SYSTEM_LOWPOWER_S6:
    {
      /* Do Nothing */
      break;
    }
  }

  /* Wait that default config is effective */
  __DSB();

  return status;
}





主函数:
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ICACHE_Init();
  MX_USART1_UART_Init();



  /* Enable SMPS if required */
  if(USE_SMPS == 1U)
  {
    HAL_PWREx_ConfigSupply(PWR_SMPS_SUPPLY);
  }

  /* Print header hyper-terminal lg */
  if (lowpower_header_scenario(&LowPower_Scenario) != SCENARIO_OK)
  {
    Error_Handler();
  }

  /* Get system low power configuration */
  if (lowpower_get_scenario(&LowPower_Scenario) != SCENARIO_OK)
  {
    Error_Handler();
  }

  /* Print footer hyper-terminal lg */
  if (lowpower_footer_scenario(&LowPower_Scenario) != SCENARIO_OK)
  {
    Error_Handler();
  }

  /* DeInit UART before entering in the selected power mode */
  USART1_UART_DeInit();

  /* Configure system low power as selected */
  if (lowpower_config_scenario(&LowPower_Scenario) != SCENARIO_OK)
  {
    Error_Handler();
  }





四、实验效果

硬件连接:使用万用表,将表笔插在电流档,并调至电流测试档口,表笔另一头接入JP4两端。
88936889bb2c433b2.png
通过串口发送命令,测试不同低功耗模式下电流值。
sleep模式电流:126.3uA
stop1模式电流:57.9uA
stop2模式电流:4uA
stop3模式电流:1.6uA
standby模式电流:0.8uA
shutdown模式电流:0.7uA
视频如下:
真的是超低功耗,在手持设备上可以作为首选。





您需要登录后才可以回帖 登录 | 注册

本版积分规则

24

主题

178

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部