当前位置:网站首页>External interrupts cannot be accessed. Just delete the code and restore it Record this unexpected bug
External interrupts cannot be accessed. Just delete the code and restore it Record this unexpected bug
2022-07-02 05:55:00 【I don't know who】
51 SCM configuration external interrupt 0/1 Nothing more than the following lines of code .
IT0=1; // External interrupt 0 Falling edge trigger
EX0=1; // Allow the interrupt 0
IT1=1; // External interrupt 1 Falling edge trigger
EX1=1;// Allow the interrupt 1
EA=1; // Open total interrupt
But I spent the whole night debugging , Still can't press the key ( External interrupt 0/1 The buttons INT0/INT1) Enter external interrupt 0/1.
Finally, I put the main function and external interrupt 0/1 All codes in are deleted , Only the lighting code is left in the interrupt , then ctrl+z Undo delete , After restoring all , recompile , Not a single line of code has been changed , But I found the key ( External interrupt 0/1 The buttons INT0/INT1) It can trigger an external interrupt .
I have met this situation once before , But I don't know what the problem is , Change it the next day and you can use it , Meet again today , Got my attention .
I guess it's because keil of use C, Every time you compile C There are some differences in language optimization , Resulting in this inexplicable bug, If you use assembly or add volatile Keywords should not encounter this situation .
volatile keyword , Because the speed of memory access is far less than CPU Of , To speed up , By default , The compiler will optimize for you , For example, the data that should be fetched from the memory unit ,for Recycle 10 Time , For convenience , It will be optimized into registers , You can get the register every time , No need to access memory units again and again . And such optimization sometimes makes unexpected mistakes .
边栏推荐
猜你喜欢
500. 键盘行
【论文翻译】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
MySQL transaction and isolation level
Software testing - concept
Unity Shader 学习笔记(3)URP渲染管线带阴影PBR-Shader模板(ASE优化版本)
Can't the dist packaged by vite be opened directly in the browser
How to write good code - Defensive Programming Guide
死磕大屏UI,FineReport开发日记
keepalived安装使用与快速入门
Vscode paste image plugin saves image path settings
随机推荐
php内类名称与类内方法名相同
15 C language advanced dynamic memory management
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
Common protocols and download paths of NR
1035 Password
Redis Key-Value数据库 【秒杀】
Zzuli:1067 faulty odometer
GRBL 软件:简单解释的基础知识
[PHP是否安装了 SOAP 扩]对于php实现soap代理的一个常见问题:Class ‘SoapClient‘ not found in PHP的处理方法
使用sha256文件验证下载的文件
Reading notes of cgnf: conditional graph neural fields
Yyds dry inventory what is test driven development
PHP 开发与测试 Webservice(SOAP)-Win
JS determines whether the mobile terminal or the PC terminal
php读文件(读取json文件,转换为数组)
Redis Key-Value数据库 【高级】
如何写出好代码 — 防御式编程指南
Stick to the big screen UI, finereport development diary
Redis key value database [primary]
【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond