启用和禁用 Arduino 中的干扰
如果你想禁用干扰(在执行某些关键代码时,尤其是应该在给定时段内完成的代码),可以使用 noInterrupts() 函数来实现。
关键代码执行完毕后,如果你想重新启用干扰,可以使用 interrupts() 函数来实现。请注意,Arduino 中默认启用干扰,因此,在没有初始调用 noInterrupts() 的情况下调用 interrupts() 是没有必要的。
示例
包含 noInterrupts() 和 interrupts() 的代码的一般结构如下 −
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
noInterrupts();
//Add critical code that needs to be completed in a specific time below
interrupts();
//Add non-critical code, that can tolerate interruptions, below
}
广告
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP