noInterrupts()
描述
关闭所有中断 (可以使用 Interrupts()
重启所有中断),中断让一些重要的任务可以在背景下执行,而它预设是开启的;当中断被关闭的时候,可能会造成一些函式不能正确运行,或者漏收的传进来的资料。由于中断会稍微断开主程式执行的时间,所以在主程式的临界区间中应该要关闭中断。
参数
回传
无回传值
范例
void setup() {} void loop() { noInterrupts(); // 临界区间,对时间敏感的程式码放这边 (不应被打断执行的) interrupts(); // 其他程式码放这边 }
See also
- Interrupts()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.