|
发表于 2015-2-26 14:24:09
|
显示全部楼层
laofuz1024 发表于 2015-2-26 13:30
这个是什么意思呢?
AtMega328(Arduino UNO)外部触发中断只有两个,就是D2和D3。
这里列出不同的Arduino使用不同的引脚触发中断
http://arduino.cc/en/Reference/AttachInterrupt
它提到:
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.
意思是:
delay()与millis()都依靠中断,如果启动了AttachInterrupt,这两个功能也许会出现错误,但delayMicroseconds()就没有这问题。
另外Timer触发中断有三个:Timer0, Timer1, Timer2。
当这些中断操作时,相对的工能就不能使用了。
例:
Timer0 (8bits): delay(), millis() and micros(), PWM5 & PWM6
Timer1 (16bits): Servo library, PWM9 & PWM10
Timer2 (8bits): tone() , PWM11& PWM3, SPI(MOSI)
如果Timer0置成中断,那么就不能用delay()、millis() 、 PWM5、PWM6等等
如果Timer2置成中断,那么就不能用tone()、PWM11(指D11的PWM功能)、PWM3(指D3的PWM功能)等等 |
|