[STM32U3] 【STM32U385RG 测评】+不同低功耗模式测试
一、首先通原理图、数据手册找到低功耗模式有关的介绍通过数据手册知道低功耗模式分为这几种sleep睡眠、stop0/1/2/3停止standby待机、shutdown关机。通过串口选择不同的模式然后进行此次低功耗模式测试实验。二、IDE软件配置PWR配置USART1配置ICACHE配置NVIC配置RCC配置GPIO配置三、代码调试参考例程进行代码的添加、修改。添加串口选择代码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_StatusTypeDefsystem_ram_retention_config(System_LowPowerModeScenarioTypeDefscenario){System_StatusTypeDefstatus 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 defaultconfigis effective */__DSB();/* Set specific configurations */switch(scenario){/* Stop 1 - 8-KbyteSRAM */caseSYSTEM_LOWPOWER_S2:{HAL_PWREx_EnableRAMsContentStopRetention(PWR_SRAM2_PAGE3_STOP_RETENTION);break;}/* Stop 2 - 8-KbyteSRAM */caseSYSTEM_LOWPOWER_S3:{HAL_PWREx_EnableRAMsContentStopRetention(PWR_SRAM2_PAGE3_STOP_RETENTION);break;}/* Stop 3 - 8-KbyteSRAM */caseSYSTEM_LOWPOWER_S4:{HAL_PWREx_EnableRAMsContentStopRetention(PWR_SRAM2_PAGE3_STOP_RETENTION);break;}/* Standby - No retention */caseSYSTEM_LOWPOWER_S5:{/* Do nothing */break;}/* Shutdown - No retention */caseSYSTEM_LOWPOWER_S6:{/* Do Nothing */break;}}/* Wait that defaultconfigis effective */__DSB();returnstatus;}主函数HAL_Init();/* USER CODE BEGINInit*//* USER CODE ENDInit*//* 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两端。通过串口发送命令测试不同低功耗模式下电流值。sleep模式电流126.3uAstop1模式电流57.9uAstop2模式电流4uAstop3模式电流1.6uAstandby模式电流0.8uAshutdown模式电流:0.7uA视频如下真的是超低功耗在手持设备上可以作为首选。---------------------作者LiuDW091链接https://bbs.21ic.com/icview-3474748-1-1.html?_dsign4e17725e来源21ic.com此文章已获得原创/原创奖标签著作权归21ic所有任何人未经允许禁止转载。