interrupts()
描述
重啟所有中斷 (例如:在 noInterrupts()
關閉所有中斷之後呼叫),中斷讓一些重要的任務可以在背景下執行,而它預設是開啟的;當中斷被關閉的時候,可能會造成一些函式不能正確運行,或者漏收的傳進來的資料。由於中斷會稍微斷開主程式執行的時間,所以在主程式的臨界區間中應該要關閉中斷。
參數
無
回傳
無回傳值
範例
void setup() {} void loop() { noInterrupts(); // 臨界區間,對時間敏感的程式碼放這邊 (不應被打斷執行的) interrupts(); // 其他程式碼放這邊 }
See also
- noInterrupts()
- attachInterrupt()
- detachInterrupt()
本頁由熱血青年 LBU 譯自英文版。
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.