当前位置:网站首页>STM32 enters and wakes up the stop mode through the serial port
STM32 enters and wakes up the stop mode through the serial port
2022-07-06 23:42:00 【Kay Note】
STM32 Have run 、 sleep 、 Stop and standby four working modes . After power on reset STM32 In operation , When the kernel doesn't need to continue running , You can choose to enter the following three low-power modes to reduce power consumption , Of the three models , Different power consumption 、 Wake up time is different 、 Different wake-up sources , We can according to different application requirements , Choose the best low-power mode .

Sleep mode :CM3 Kernel stop , The peripheral is still running , This power consumption is the highest .
Stop mode : All clocks stop , This power consumption is low , Typical is probably 20uA about .
Standby mode :1.8V Kernel power off , This power consumption is the lowest , Typical is probably 2uA about .
In the actual development and Application , Our commonly used low-power mode is stop mode , The wake-up mode is any external interrupt . This article mainly talks about waking up and entering the stop mode through the serial port , To realize the wake-up stop mode through the serial port , External interrupts are needed . Put the serial port Rx The pin is set to external interrupt , Rising edge trigger , In this way, the external interrupt will be triggered when the serial port receives data , This wakes up the stop mode . The relevant code is as follows
First, configure the serial port receiving end as an external interrupt :
/*************************************************
Function: void EXIT_UART_Init(void)
Description: External interrupt initialization
Calls:
Called By:
Input: nothing
Output: nothing
Return:
Others:
*************************************************/
void EXIT_UART_Init(void)
{
LL_EXTI_InitTypeDef EXTI_InitStruct = {0};
/* GPIO Portd Clock Enable */
LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA);
/**/
LL_EXTI_SetEXTISource(LL_EXTI_CONFIG_PORTA, LL_EXTI_CONFIG_LINE3);
/**/
EXTI_InitStruct.Line_0_31 = LL_EXTI_LINE_3;
EXTI_InitStruct.LineCommand = ENABLE;
EXTI_InitStruct.Mode = LL_EXTI_MODE_IT;
EXTI_InitStruct.Trigger = LL_EXTI_TRIGGER_RISING;
LL_EXTI_Init(&EXTI_InitStruct);
/**/
LL_GPIO_SetPinPull(GPIOA, LL_GPIO_PIN_3, LL_GPIO_PULL_DOWN);
/**/
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_3, LL_GPIO_MODE_INPUT);
/* EXTI interrupt init*/
NVIC_SetPriority(EXTI2_3_IRQn, 1);
NVIC_EnableIRQ(EXTI2_3_IRQn);
}Then enable the relevant clock , Enter stop mode .
/*************************************************
Function: void enter_stop_mode(void)
Description: Enter stop mode
Calls:
Called By:
Input: nothing
Output: nothing
Return:
Others:
*************************************************/
void enter_stop_mode(void)
{
EXIT_UART_Init(); // Configure the serial port pin as an external interrupt
__HAL_RCC_PWR_CLK_ENABLE(); // Can make PER The clock
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI); // Get into stop Pattern
}After wakeup in low power mode , The default system clock is HSI, So you need to reconfigure the system clock . For convenience, the operation of the reset system is directly used here , If you need to keep external in the actual project IO Port state unchanged , You cannot use the system reset command , You need to reconfigure the system clock and other peripheral clocks .
/*
************************************************************
* The name of the function : void exit_stop_mode(void)
*
* The functionality : System reset
*
* Entrance parameters : nothing
*
* Returns the parameter : nothing
*
* explain :
************************************************************
*/
void exit_stop_mode(void)
{
__set_FAULTMASK(1); // Turn off all interrupts
NVIC_SystemReset();
}边栏推荐
- js對JSON數組的增删改查
- Entropy information entropy cross entropy
- Can online reload system software be used safely? Test use experience to share with you
- Isomorphism + cross end, knowing applet +kbone+finclip is enough!
- js导入excel&导出excel
- Leetcode problem solving - 889 Construct binary tree according to preorder and postorder traversal
- The best sister won the big factory offer of 8 test posts at one go, which made me very proud
- Coscon'22 community convening order is coming! Open the world, invite all communities to embrace open source and open a new world~
- The intranet penetrates the zerotier extranet (mobile phone, computer, etc.) to access intranet devices (raspberry pie, NAS, computer, etc.)
- matplotlib画柱状图并添加数值到图中
猜你喜欢

每日刷题记录 (十五)

Gradle knowledge generalization

What should I do if the USB flash disk data is formatted and how can I recover the formatted USB flash disk data?

资产安全问题或制约加密行业发展 风控+合规成为平台破局关键

MATLIB从excel表中读取数据并画出函数图像

Ajout, suppression et modification d'un tableau json par JS
![[unmanned aerial vehicle] multi unmanned cooperative task allocation program platform, including Matlab code](/img/4c/5d867437aac5faa299817e187602e1.png)
[unmanned aerial vehicle] multi unmanned cooperative task allocation program platform, including Matlab code

Efficient ETL Testing

英国都在试行4天工作制了,为什么BAT还对996上瘾?

How to implement Lua entry of API gateway
随机推荐
What should I do if the USB flash disk data is formatted and how can I recover the formatted USB flash disk data?
今日睡眠质量记录78分
Devsecops software R & D security practice - release
B站大佬用我的世界搞出卷积神经网络,LeCun转发!爆肝6个月,播放破百万
Basic chart interpretation of "Oriental selection" hot out of circle data
Zero code and high return. How to use 40 sets of templates to meet 95% of the reporting needs in the work
【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
《数字经济全景白皮书》保险数字化篇 重磅发布
Wasserstein slim gain with gradient poverty (wsgain-gp) introduction and code implementation -- missing data filling based on generated countermeasure network
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
Newsletter L Huobi ventures is in-depth contact with genesis public chain
A few suggestions for making rust library more beautiful! Have you learned?
设计一个抢红包系统
Today, I met a senior test developer from Tencent and saw the ceiling of the foundation
Win11怎么恢复传统右键菜单?Win11右键改回传统模式的方法
使用MitmProxy离线缓存360度全景网页
docker mysql5.7如何设置不区分大小写
Master binary tree in one article
Per capita Swiss number series, Swiss number 4 generation JS reverse analysis