当前位置:网站首页>The reason why it is easy to let the single chip computer program fly
The reason why it is easy to let the single chip computer program fly
2022-06-11 15:11:00 【A Fujii tree】
1、 Unexpected interruption
Whether an interrupt is turned on , But there is no response and no clear middle end flag , Causes the program to enter the interrupt all the time , Cause a crash .
2、 Improper handling of interrupt variables
If you define some global variables that will be modified in the interrupt , At this time, we should pay attention to two problems : First of all, to prevent the compiler from optimizing the interrupt variables , Before the definition of these variables volatile; Secondly, before reading the interrupt variables in the main loop, the global interrupt should be closed first , Prevent half of the read from being interrupted for modification , Turn on global interrupt after reading , Otherwise, the data will be distorted .
3、 Address overflow , Common errors are pointer operation errors
The key point is that the array subscript uses the loop variable in the loop function , If the loop variable is not well controlled, the array subscript will be out of bounds , An unexpected modification of the system register caused a crash , In this case, if the plane crashes, it means good luck , Otherwise, I don't know what's going on .
4、 An unconditional dead cycle
For example, use while(x), Wait for the level to change , Under normal circumstances x Will become 0, And they were afraid of one thousand , So it's best to add a time limit .
5、 The watchdog is not closed
Some single-chip computers may accidentally open the watchdog with the minimum cycle automatically even when the watchdog is not used , Cause software to reset constantly , Cause a crash . See the chip manual , It is better to clear the watchdog explicitly before closing the watchdog after program reset .
6、 stack overflow
The most difficult problem to find , For the small capacity of the single chip microcomputer , Minimize function call levels , Reduce local variables , This reduces the amount of space needed to stack . When you try all the above, you can't solve the problem , Try to build your less called function directly into the place of call and use it RAM Big local variable to global variable , Give it a try. Maybe it'll do .
Pay more attention to these aspects when programming
边栏推荐
- Small open source projects based on stm32f1
- 2021 go developer survey
- How can local retail release the "imprisoned value" and make physical stores grow again?
- Riskscanner of multi Cloud Security compliance scanning platform
- 2022 Hunan Provincial Safety officer-c certificate examination practice questions and online simulation examination
- uniapp开发微信小程序,从构建到上线
- 数据库“百亿蓝海”中,每位玩家都能找到一叶扁舟 | C位面对面
- Hamad application layout scheme 03 of hashicopy (run a job)
- Uniapp développe des applets Wechat, de la construction à la mise en ligne
- 19. 二叉搜索树的插入删除修剪
猜你喜欢

Did you break the rules?

Summary of some classic embedded C interview questions

浅析分布式系统之体系结构-事务与隔离级别(多对象、多操作)下篇

Backtracking / solution space tree permutation tree

With a loss of 13.6 billion yuan in three years, can listing revive Weima?

Qualcomm WLAN framework learning (29) -- 6GHz overview
![[verification of SystemVerilog] ~ test platform, hardware design description, excitation generator, monitor and comparator](/img/3a/0cc26400eeb4b388face09b9a10f27.png)
[verification of SystemVerilog] ~ test platform, hardware design description, excitation generator, monitor and comparator

19. Insertion et suppression d'un arbre de recherche binaire
![[multi thread performance tuning] what operations cause context switching?](/img/a6/5d82c81dba546092447debebf7fc3e.jpg)
[multi thread performance tuning] what operations cause context switching?

【SystemVerilog 之 接口】~ Interface
随机推荐
Avenue to simplicity | how to configure self attention for vit is the most reasonable?
C # - how to add and read appsetting in the console application JSON file
Basic configuration command of Xinhua 3 switch system
Analyse approfondie de la conception du système relationnel du Groupe de cercles
China's technology goes to sea, tidb database's overseas exploration road | interview with excellent technical team
Tangzhengrong: CTO is the intersection of business thinking and technical thinking
2021 年度 Go 开发者调查
Nexus of repository manager
uniapp開發微信小程序,從構建到上線
LoveLive! Published an AI paper: generating models to write music scores automatically
多云安全合规扫描平台之RiskScanner
大道至簡 | 設計 ViT 到底怎麼配置Self-Attention才是最合理的?
Uniapp développe des applets Wechat, de la construction à la mise en ligne
[azure application service] nodejs express + msal realizes the authentication experiment of API Application token authentication (AAD oauth2 idtoken) -- passport authenticate()
Repository Manager之Nexus配置yum仓库
Hamad application layout scheme 03 of hashicopy (run a job)
HMS core shows the latest open capabilities in mwc2022, helping developers build high-quality applications
19. 二叉搜索树的插入删除修剪
B站高管解读财报:疫情对公司长期发展无影响 视频化趋势不可阻挡
Talk about the principle of QR code scanning login