jung6717 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

Don't disable interrupts in delayMicroseconds(). #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?

The delayMicroseconds() function should not disable interrupts.  If 
precise timing is needed, the user should disable microseconds outside of 
the call to delayMicrosconds().

Why?

Having the disabling of interrupts inside the function limits the 
flexibility of the function.  It would be good to be able to leave 
interrupts enabled if desired.  For example, the LiquidCrystal library has 
lots of calls to delayMicroseconds(), but doesn't need very precise 
timings.  It would be better not to disable interrupts here, because it 
can interfere with millis(), etc.

Further, as BenF points out on the forum, disabling interrupts doesn't 
help anyway, because interrupts can be called after SREG is restored and 
before delayMicroseconds() returns: http://www.arduino.cc/cgi-
bin/yabb2/YaBB.pl?num=1248706486

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?

Not really, since the interrupts can still be triggered, causing delays.

Original issue reported on code.google.com by dmel...@gmail.com on 31 Jul 2009 at 10:41

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 15 Aug 2009 at 8:47

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 18 Dec 2009 at 5:05