当前位置:网站首页>Solution to the problem of closing the watchdog of STM32 in the sleep mode (stop/standby)
Solution to the problem of closing the watchdog of STM32 in the sleep mode (stop/standby)
2022-06-13 00:18:00 【csaaa2005】
It has long been believed that Stm32 To enable the IWDG After the watchdog , You can no longer use sleep to enter low power mode . Since the watchdog cannot stop after it is started , It has brought trouble to many people . There are many people who have given up using the watchdog , So as to bring certain uncertainty to the product .
In fact, there is a simple way to achieve reliable sleep with a watchdog . I named it “ two-step ”. seeing the name of a thing one thinks of its function :
First step : stay flash Or anywhere you can save it , Write an identifier , such as 1; Then execute the single-chip microcomputer restart , such as NVIC_SystemReset()
The second step : After restart main In the entrance , Before using the watchdog , Check the above marks first , If it is 1, Clear this first 1, Change it to 0, preservation , Then enter the real sleep process, such as Sys_Standby(){...}; If not 1, So clearly , This is the process of awakening . Just go straight to the next program .
//standby by flash A certain address in
// Perform identity setting and restart before hibernation
void Pre_Standby(void){
standby=1;
WriteParam2Flash();
NVIC_SystemReset();
}
// Perform a real sleep
void Sys_StandbyReal(void){
RCC_APB2PeriphResetCmd(0x01fc, DISABLE);// Close all pins
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); // Can make PWR Peripheral clock
PWR_WakeUpPinCmd(ENABLE); // Enable to wake up the pin function
PWR_EnterSTANDBYMode(); // On standby (STANDBY) Pattern
}
// entrance
void main(void){
// Various initializations
...
ReadParamFlash();// Read flash part
if(standby==1){// Really go into sleep Otherwise, it is the real boot
standby=0;
WriteParam2Flash();// Save again
Sys_StandbyReal();
}
IWDG_Config();// Set up a watchdog Put it behind the identification test
// The following is the main program
...
while(1){
...
IWDG_FEED();
}
}
// When calling sleep , perform Pre_Standby();Although I have to read and write 2 Time flash, But it is more cost-effective than the life of the product itself and the reliability of the program , Of course, it can also be saved externally eprom in , In this way, the life span is greatly increased . In addition, I think it can also be saved in a register that can still be saved after hibernation , I haven't studied yet , You can reply me if you know .
边栏推荐
- [matlab] polynomial calculation
- New blog address
- The whole process from entering URL to displaying page (interview)
- APISpace 空号检测API接口 免费好用
- [matlab] 3D curve and 3D surface
- KAUST:Deyao Zhu | 价值记忆图:基于离线强化学习的图结构世界模型
- [hcie discussion] STP-A
- [hcie discussion] rr-a
- PMP training organization
- Memory address mapping of u-boot
猜你喜欢

Pytorch loading model error resolution

Installation of IK word breaker

Will PM (Project Manager) take the PMP Exam?

Machining Industry MES system Mold Industry MES system CNCl Medium Industry MES System MES code scanning and reporting MES data collection

Interprocess communication - shared memory shmat

PMP test experience

How to gracefully solve the offset problem of Baidu and Gaode maps in leaflet

What occupation is suitable for PMP?

Video tracker error troubleshooting

Vscode实现PHP在浏览器实时预览
随机推荐
[LeetCode]7. Integer inversion thirty-nine
Tsinghua-Bosch Joint ML Center, THBI Lab:Chengyang Ying | 通过约束条件风险价值实现安全强化学习
Go custom collation
[hcie discussion] multicast igmp-a
63. different paths II
MySQL index
Five mock technologies of go
[LeetCode]20. Valid parentheses thirty-six
电商员工离职后将产品价格改为1折出售,已被刑拘
On the parameters of main function in C language
C language standard IO, for example: fread(), fwrite(), fgetc(), etc. (end)
Installation of IK word breaker
PMP test experience
MASA Auth - 从用户的角度看整体设计
ik分词器的安装
哲學和文學的區別
Context of go concurrency mode
2022施工員-設備方向-通用基礎(施工員)操作證考試題及模擬考試
APISpace 空号检测API接口 免费好用
MAYA建模六