|
|
发表于 2014-11-18 11:54:15
|
显示全部楼层
官網清楚說明, ISR 中不應該用 delay() 及 millis() 的.
Generally, an ISR should be as short and fast as possible. If your sketch uses multiple ISRs, only one can run at a time, other interrupts will be ignored (turned off) until the current one is finished. as delay() and millis() both rely on interrupts, they will not work while an ISR is running. delayMicroseconds(), which does not rely on interrupts, will work as expected.
此外, 應該習慣把 ISR 簡化, 不要比太多工作放在 ISR 中.
嘗試在 ISR 中只設定一些變數, 再在主程式中檢測逐變數, 執行有關工作. |
|