当前位置:网站首页>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();
}
边栏推荐
- AI金榜题名时,MLPerf榜单的份量究竟有多重?
- Wasserstein slim gain with gradient poverty (wsgain-gp) introduction and code implementation -- missing data filling based on generated countermeasure network
- ArrayExpress数据库里的细胞只有两个txt是不是只能根据Line到ENA下载测序跑矩阵?
- Up to 5million per person per year! Choose people instead of projects, focus on basic scientific research, and scientists dominate the "new cornerstone" funded by Tencent to start the application
- Entropy information entropy cross entropy
- 人均瑞数系列,瑞数 4 代 JS 逆向分析
- 吴恩达2022机器学习课程评测来了!
- 内网穿透zerotier 外网(手机、电脑等)访问内网设备(树莓派、NAS、电脑等)
- The "white paper on the panorama of the digital economy" has been released with great emphasis on the digitalization of insurance
- 求帮助xampp做sqlilab是一片黑
猜你喜欢
The programmer said, "I'm 36 years old, and I don't want to be rolled, let alone cut."
Up to 5million per person per year! Choose people instead of projects, focus on basic scientific research, and scientists dominate the "new cornerstone" funded by Tencent to start the application
电脑重装系统u盘文件被隐藏要怎么找出来
The worse the AI performance, the higher the bonus? Doctor of New York University offered a reward for the task of making the big model perform poorly
Efficient ETL Testing
PDF批量拆分、合并、书签提取、书签写入小工具
Gold three silver four, don't change jobs
英国都在试行4天工作制了,为什么BAT还对996上瘾?
Nftscan Developer Platform launches Pro API commercial services
koa2对Json数组增删改查
随机推荐
浅谈现在的弊端与未来的发展
食品里的添加剂品种越多,越不安全吗?
Isomorphism + cross end, knowing applet +kbone+finclip is enough!
MySQL implementation of field segmentation from one line to multiple lines of example code
公链与私链在数据隐私和吞吐量上的竞争
每日刷题记录 (十五)
快讯 l Huobi Ventures与Genesis公链深入接洽中
Master binary tree in one article
Detailed explanation of regular expression (regexp) in MySQL
Résumé des connaissances de gradle
Gpt-3 is a peer review online when it has been submitted for its own research
Without CD, I'll teach you a trick to restore the factory settings of win10 system
PDF批量拆分、合并、书签提取、书签写入小工具
达晨史上最大单笔投资,今天IPO了
Entropy information entropy cross entropy
不要再说微服务可以解决一切问题了
Today, I met a senior test developer from Tencent and saw the ceiling of the foundation
资产安全问题或制约加密行业发展 风控+合规成为平台破局关键
How much does the mlperf list weigh when AI is named?
AI表现越差,获得奖金越高?纽约大学博士拿出百万重金,悬赏让大模型表现差劲的任务...