We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d2a38e4 commit c437761Copy full SHA for c437761
hardware/arduino/avr/cores/arduino/wiring_pulse.c
@@ -48,7 +48,12 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout)
48
unsigned long maxloops = microsecondsToClockCycles(timeout)/16;
49
50
width = countPulseASM(portInputRegister(port), bit, stateMask, maxloops);
51
- return clockCyclesToMicroseconds(width * 16 + 16);
+
52
+ //prevent clockCyclesToMicroseconds to return bogus values if countPulseASM timed out
53
+ if (width)
54
+ return clockCyclesToMicroseconds(width * 16 + 16);
55
+ else
56
+ return 0;
57
}
58
59
/* Measures the length (in microseconds) of a pulse on the pin; state is HIGH
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments