啟用和停用 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