[STM32L4]

STM32应用:简介STM32L4 SMPS功能

[复制链接]
1003|16
手机看帖
扫描二维码
随时随地手机跟帖
wangjiahao88|  楼主 | 2021-11-16 11:51 | 显示全部楼层 |阅读模式
STM32L4系列为一低功耗,高效能的MCU,其具备有ARM Cortex-M4核心,在电源部分,除了传统内建LDO外,STMicroelectronics在以此为基础上另外提供了可外挂SMPS的型号,在Run mode可以更进一步的改善功耗表现。大大购相关商品 以STM32L452RET6﹝一般版本﹞和STM32L452RET6 红圈标示起来的部分,STM32L452RET6

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 11:52 | 显示全部楼层
9341761932ad5d7402.png

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 11:55 | 显示全部楼层
6860861932b9c19691.png

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 12:15 | 显示全部楼层
8379461933045e1cd1.png

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 12:18 | 显示全部楼层
SYSCLK低于26MHz时,V
SYSCLK高于26MHz时,V
在power up或是非同步reset之类的情况下,V
从SMPS连接到断开的期间,SYSCLK必须要低于26MHz
SMPS只能在Run mode、Sleep mode和Stop 0 mode下,且VDD12的电压大于内建main LDO 50mV时才能连接,在其他的电源模式下,SMPS必须被断开,避免损坏内建的LDO。
**附件提供了三个测试程式,分别在Run mode、STOP 0 mode

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 12:19 | 显示全部楼层
例程如下:1

PWR_RUN_SMPS.zip

43.02 KB

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 12:20 | 显示全部楼层
例程如下:2

PWR_STANDBY_SMPS.zip

42.98 KB

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 12:22 | 显示全部楼层
例程如下:3

PWR_STOP0_SMPS.zip

43.38 KB

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 12:28 | 显示全部楼层
int main(void)
{

  GPIO_InitTypeDef  GPIO_InitStruct;

  /* STM32L4xx HAL library initialization:
       - Configure the Flash prefetch
       - Systick timer is configured by default as source of time base, but user
         can eventually implement his proper time base source (a general purpose
         timer for example or other time source), keeping in mind that Time base
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure LED4 */
  BSP_LED_Init(LED4);

  /* Configure the system clock to 80 MHz */
  SystemClock_80MHz();
  
  

  /* User push-button (External line 13) will be used to enable or not the SMPS mode */
  BSP_PB_Init(BUTTON_USER, BUTTON_MODE_EXTI);

  /* ------------------------------------------ */

    /* Insert 5 seconds delay */
     HAL_Delay(5000);
  
  /********************************/
  /* 80 MHZ                       */               
  /* PWR_REGULATOR_VOLTAGE_SCALE1 */
  /* SMPS IS OFF                  */
  /********************************/
  
  /* ------------------ GPIO ------------------ */
  BSP_LED_Off(LED4);
  
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Pin = GPIO_PIN_All;

  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

  HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

   
  __HAL_RCC_GPIOA_CLK_DISABLE();
  __HAL_RCC_GPIOB_CLK_DISABLE();
  __HAL_RCC_GPIOC_CLK_DISABLE();
  __HAL_RCC_GPIOD_CLK_DISABLE();
  __HAL_RCC_GPIOE_CLK_DISABLE();

  __HAL_RCC_GPIOH_CLK_DISABLE();
   
  if (button_pressed == 1)
  {   
    test_run_range2_80mhz_SMPS();
  }
  else
  {
   
  }
   
  whileloop1();  
}

使用特权

评论回复
wangjiahao88|  楼主 | 2021-11-16 12:29 | 显示全部楼层
/**
  * @brief  Move to Run SMPS mode
  * @NOTE   Manage all the required transitions to move from 80 MHz, SMPS off,
           voltage scale range 1 to 80 MHz, SMPS on, voltage scale range 2.
  * @param  None
  * @retval None
  */
static void test_run_range2_80mhz_SMPS(void)
{
  GPIO_InitTypeDef GPIO_InitStruct;       

  uint32_t SMPS_status_local = 0;
  
  SMPS_status_local = BSP_SMPS_DeInit();
  if (SMPS_status_local != SMPS_OK)
    {
    Error_Handler();
    }
  SMPS_status_local = BSP_SMPS_Init(PWR_REGULATOR_VOLTAGE_SCALE2);
  if (SMPS_status_local != SMPS_OK)
  {
    Error_Handler();
  }

  /* ------------------------------------------ */

  
  __HAL_FLASH_PREFETCH_BUFFER_DISABLE();
  /* Set the System clock to 24 MHz */
  /* so that SMPS can be enabled */
  SystemClock_24MHz();

  /* Insert 1 second delay */
  HAL_Delay(1000);
     
  /********************************/
  /* 24 MHZ                       */               
  /* PWR_REGULATOR_VOLTAGE_SCALE1 */
  /* SMPS IS OFF                  */
  /********************************/

  /* ------------------------------------------ */
  
  /* PWR_REGULATOR_VOLTAGE_SCALE2 only with AD SMPS */               
  HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE2);
  if (SMPS_status_local != SMPS_OK)
    {
    Error_Handler();
    }

  /* Insert 1 second delay */
  HAL_Delay(1000);
     
  /********************************/
  /* 24 MHZ                       */               
  /* PWR_REGULATOR_VOLTAGE_SCALE2 */
  /* SMPS IS OFF                  */
  /********************************/
  
  /* ------------------------------------------ */
  
  /* Enable SMPS */

  /* Check of PG but not blocking */
  SMPS_status_local = BSP_SMPS_Enable (0 , 1);  

  /* Check of PG */
  SMPS_status_local = BSP_SMPS_Supply_Enable (4 , 1);
   
  if (SMPS_status_local != SMPS_OK)
  {
    Error_Handler();
  }
  
  /* Insert 2 seconds delay */
  HAL_Delay(2000);
  
  /********************************/
  /* 24 MHZ                       */               
  /* PWR_REGULATOR_VOLTAGE_SCALE2 */
  /* SMPS IS ON                  */
  /********************************/
  
  /* ------------------------------------------ */
  
  /* Set System clock to 80 MHz (MSI) */
  SystemClock_80MHz();
  
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Pin = GPIO_PIN_All;
  GPIO_InitStruct.Pin ^= (PIN_SMPS_ENABLE | PIN_SMPS_SWITCH_ENABLE | PIN_SMPS_POWERGOOD);
  
  HAL_GPIO_Init(PORT_SMPS, &GPIO_InitStruct);
  
  NUCLEO_SMPS_GPIO_CLK_DISABLE();

}

使用特权

评论回复
tail066| | 2021-11-17 15:41 | 显示全部楼层
我是奔着SMPS进来的,发现还是要自己去百度

使用特权

评论回复
kxsi| | 2021-12-9 21:06 | 显示全部楼层
第一次看到这个功能

使用特权

评论回复
nawu| | 2021-12-9 21:08 | 显示全部楼层
不错 还有完整的工程

使用特权

评论回复
qcliu| | 2021-12-9 21:11 | 显示全部楼层
我需要了解一下这个功能是什么用的

使用特权

评论回复
tfqi| | 2021-12-9 21:12 | 显示全部楼层
是独有的模块吗

使用特权

评论回复
wiba| | 2021-12-9 21:13 | 显示全部楼层
这个功能非常不错 很有实用性

使用特权

评论回复
sadicy| | 2021-12-10 11:17 | 显示全部楼层
下例程瞅瞅,
看看smps是个啥

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

461

主题

7476

帖子

29

粉丝