Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
digitalPulse() not working for very short pulse lengths #1749
I made a later comment post 9 at:
regarding non whole numbers within an array. I was working with the MDBT42Q breakout board and ran into a simmilar issue. While still unresolved and not fully researched at 'C' code level, I seem to run into issues when pulses got down to around the 200usec range, approx 8000Hz. The docs really don't explain the limits here, and I still can't locate (just haven't put in the time) where the under the hood timing stuff takes place.
Simple math 1 / 8000 = 125usec
As an observation, if the divisor is from a (not chceked) 16MHz clock crystal, this might explain things.
Working on a project/tutorial to replace an Arduino interrupt driven frequency counter example, but need pulses around 1usec width and detection around 10usec duration. Would this be possible?
Will continue to gather test data to determine current limits with 2v04 and when sufficient data has been gathered, start a forum post.
I think the issue you're hitting here is that the timings on ESP8266 are most likely done with the 32kHz RTC. Same thing happens on the NRF52, however STM32 based boards do some crazy stuff to allow them to use a much more accurate timer.
While the high speed timer used for digitalPulse is more accurate, it uses the RTC to re-sync itself, and that means that the actual pulse accuracy for long trains of pulses is pretty limited.
Basically this is the last bullet point on #1444
We could switch to not using the RTC, but that would mean that if for instance you did a 4000Hz waveform capture of 4000 samples, then a