当前位置:网站首页>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
边栏推荐
- 中国技术出海,TiDB 数据库海外探索之路 | 卓越技术团队访谈录
- The server prevents repeated payment of orders
- Recyclerview usage record
- China's technology goes to sea, tidb database's overseas exploration road | interview with excellent technical team
- A brief talk on the feelings after working at home | community essay solicitation
- 2022质量员-市政方向-岗位技能(质量员)考试模拟100题及模拟考试
- [SystemVerilog interface] ~ interface
- 百度某离职员工跳槽字节被判赔107万元;苹果谷歌微软拟“干掉”密码;传吉利已收购魅族|Q资讯
- Anaconda delete virtual environment
- [mysql_11] addition, deletion and modification of data processing
猜你喜欢
![[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

Individual income tax rate table

Mysql(九)Your password has expired. To log in you must change it using a client that supports expired

uniapp开发微信小程序,从构建到上线

C language simple webserver

Illustration of tiger international quarterly report: revenue of USD 52.63 million continued to be internationalized

清北力压耶鲁,MIT蝉联第一,2023QS世界大学排名最新发布

Understanding of oauth2

Did you break the rules?
![[process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle](/img/c7/ff28df36b8d5dda704aa829dd5264f.png)
[process blocks and methods of SystemVerilog] ~ domain, always process block, initial process block, function, task, life cycle
随机推荐
Hashicopy之nomad应用编排方案03(运行一个job)
回溯法/解空间树 排列树
深度剖析「圈组」关系系统设计 | 「圈组」技术系列文章
数字化转型项目做了多年,主架构师都绝望了:当初就不应该用外包!
Ali, tell me about the application scenarios of message oriented middleware?
Safepoint explanation and analysis of its placement ideas
详解 Kubernetes 包管理工具 Helm
Summary of some classic embedded C interview questions
Leetcode daily question - Search insertion position
数据分析系统的设计与实现
Raspberry pie obtains the function of network installation system without the help of other devices
Qcustomplot 1.0.1 learning (1) - Download and use qcustomplot
数据库“百亿蓝海”中,每位玩家都能找到一叶扁舟 | C位面对面
111. minimum depth of binary tree
在微服务架构中管理技术债务
Qualcomm WLAN framework learning (29) -- 6GHz overview
Why do I need the public static void main (string[] args) method?
A brief talk on the feelings after working at home | community essay solicitation
Individual income tax rate table
Elk log analysis system