Closed terrillmoore closed 6 years ago
With the 1.0.6 BSP, this suffices to make the OneWire library work (along with the other speedups for direct I/O). Can we please update the delayMicroseconds()
in the core?
If we get the BSP repo forked and posted, I will send a pull request with this change.
Now that we have the STM32 repo forked and posted, I've moved this issue there. Closing this. Replaced by https://github.com/mcci-catena/Arduino_Core_STM32/issues/8.
Although the code looks right, empirical measurements show that delayMicroseconds() is wrong for values in the sub 1ms range (much too long).
The following routine, if substituted in the OneWire library, makes the OneWire library work better -- but short delays (at least with 1.0.5) are still too long. [Anything less than 30 us is too long, and the OneWire protocol requires that we be accurate for 16 us (max) delays.]
A key difference is that this routine converts usec to ticks, and then counts ticks. It assumes that interrupts don't take longer than 1ms, but that doesn't seem to be an issue in practice -- if interrupted for longer than a millisecond, it will wait too long, but the delay will be too long anyway.