674 views|5 replies

126

Posts

1

Resources
The OP
 

【NUCLEO-U083RC】2.5 MSI usage and low power (STOP) mode [Copy link]

This post was last edited by Electronic Bad Guy on 2024-5-5 16:58

Recently, when I was working on RTC and LCD, I found that the MSI clock of U0 is very interesting, and it is worth writing a supplementary article separately:

1. Introduction of MSI:

MSI ( Multispeed internal RC oscillator ) is composed of an RC circuit, which consists of a resistor (R) and a capacitor (C) to generate a stable clock signal inside the microcontroller. The term "Multispeed " means that this oscillator can provide multiple different clock frequencies. This design is designed to allow the microcontroller to run in different operating modes to optimize power consumption and performance. The original intention of this design was to flexibly develop clock frequencies at a low cost, and to operate at different frequencies in low power mode and high speed mode.

A more complete composition can be seen in the system diagram in the U0 manual: (The picture is incomplete, the lower half is omitted)

In addition, there is a separate introduction in the RCC clock section of the manual:

The latest MSI application note is for the U5 series and can be used for reference: How to calibrate internal RC oscillators on STM32U5 Series - Application note

2. Configure MSI:

In the clock configuration interface of STM32U0, you can see that MSI can be used as a system clock multiplexer to configure the main frequency (the maximum frequency of U083 microcontroller is 48MHZ).

In addition, the frequency can be increased by passing through the PLL phase-locked loop:

Take the previous case as an example to generate a sample project.

3. Low power mode

STM32U0 has six modes: Sleep, Low-power run mode, Low-power sleep mode, stop, standby, and shutdown, which are sufficient to cope with various usage scenarios in actual development.

The only two modes mentioned are stop and shutdown, and MSI is disabled in both modes.

The stop mode is more diverse, with three sub-modes, corresponding to different situations:
In the actual development of this project, especially when running on battery, the STOP mode is more common. Compared with the standby and shutdown modes, it can retain key data while saving power, and the RTC continues to work, so the stop mode is used as an example for demonstration;
There are two wake-up methods for STOP mode: Interruption and Event. The corresponding parameters are in STM32u0xx_hal_pwr.h:
/** @defgroup PWR_STOP_mode_entry  PWR STOP mode entry
  * @{
  */
#define PWR_STOPENTRY_WFI ((uint8_t)0x01)/*!< Wait For Interruption instruction to enter Stop mode */
#define PWR_STOPENTRY_WFE ((uint8_t)0x02)/*!< Wait For Event instruction to enter Stop mode        */
/**
  * @}
  */

The APIs for the three stop modes are:
void HAL_PWREx_EnterSTOP0Mode(uint8_t STOPEntry)//STOP0
void HAL_PWREx_EnterSTOP1Mode(uint8_t STOPEntry)//STOP1
void HAL_PWREx_EnterSTOP2Mode(uint8_t STOPEntry)//STOP2
//注:STOP0模式没有找到该函数,暂不清楚原因,可能是调用与另外两种不同

Taking STOP1 mode as an example, the code definition is as follows: (from the file stm32u0xx hal_pwr_ex.c)

void HAL_PWREx_EnterSTOP1Mode(uint8_t STOPEntry)
{
  /* Check the parameters */
  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));

  /* Stop 1 mode with Low-Power Regulator */
  MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_CR1_LPMS_0);

  /* Set SLEEPDEEP bit of Cortex System Control Register */
  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));

  /* Select Stop mode entry --------------------------------------------------*/
  if (STOPEntry == PWR_STOPENTRY_WFI)
  {
    /* Request Wait For Interrupt */
    __WFI();
  }
  else
  {
    /* Request Wait For Event */
    __SEV();
    __WFE();
    __WFE();
  }

  /* Reset SLEEPDEEP bit of Cortex System Control Register */
  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
}

4. Write code and observe the phenomenon

Add the following code to the main function:

while (1)
  {
    /* USER CODE END WHILE */
    /* USER CODE BEGIN 3 */
	  for(i=0;;i++)
	  {
		  count=count+1;//设置一个计数器
		  HAL_Delay(1000);																											 
          BSP_LED_Toggle(LED_GREEN);
		  if(count==9)//计数器9秒后进入STOP模式
		  {
			  HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
		      HAL_Delay(10000);//停止10秒
			  SystemClock_Config();//重新配置时钟
			  break;//退出STOP模式,继续计数
		  }
	  }

The experimental phenomenon is: after the green light flashes for 9 seconds, it enters the stop mode, stops for 10 seconds and then exits the stop mode. The whole process uses MSI as the clock source.

meeting_01

This post is from stm32/stm8

Latest reply

After the green light flashes for 9 seconds, it enters the stop mode, stops for 10 seconds and then exits the stop mode. The whole process uses MSI as the clock source.   Details Published on 2024-5-22 11:16
Personal signature

没用比没有强

 

126

Posts

1

Resources
2
 

At the request of the management, the code and pictures are attached:

【NUCLEO-U083RC】2.5 MSI使用和低功耗(STOP)模式 .zip (10.59 MB, downloads: 1)
This post is from stm32/stm8
 
Personal signature

没用比没有强

 

6829

Posts

11

Resources
3
 
  • HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI);
  • HAL_Delay(10000); //Stop for 10 seconds

Did he wake up automatically?

This post is from stm32/stm8

Comments

I understand that there is a WFI event that automatically exits STOP mode. I don't know if this is reasonable.  Details Published on 2024-5-19 20:05
 
 

126

Posts

1

Resources
4
 
lugl4313820 posted on 2024-5-19 07:48 HAL_PWREx_EnterSTOP1Mode(PWR_STOPENTRY_WFI); HAL_Delay(10000);//Stop for 10 seconds Is this an automatic wake-up?

I understand that there is a WFI event that automatically exits STOP mode. I don't know if this is reasonable.

This post is from stm32/stm8

Comments

I still don't understand how to set its wakeup source. Have you tested whether the power consumption is really reduced?  Details Published on 2024-5-19 21:24
 
Personal signature

没用比没有强

 
 

6829

Posts

11

Resources
5
 
Electronic rotten man posted on 2024-5-19 20:05 I understand that there is a WFI event that automatically exits the STOP mode, I don't know if it is reasonable

I still don't understand how to set its wakeup source. Have you tested whether the power consumption is really reduced?

This post is from stm32/stm8
 
 
 

56

Posts

0

Resources
6
 

After the green light flashes for 9 seconds, it enters the stop mode, stops for 10 seconds and then exits the stop mode. The whole process uses MSI as the clock source.

This post is from stm32/stm8
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list