Skip to content

extmod/modonewire: Adjust timing within "onewire_bus_reset" #5290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

amotl
Copy link
Contributor

@amotl amotl commented Nov 4, 2019

Dear George and the MicroPython community,

while working on [1,2], we just added #5289 and also stumbled on #4647. While we can't say for sure, we might have spotted a minor glitch which could possibly have negative impact on the correct timing of things.

So, maybe adjusting two function calls within onewire_bus_reset to mp_hal_delay_us_fast() instead of mp_hal_delay_us() could make things work for @kevinkk525 on the ESP32 platform.

Please correct me if I am wrong on that and feel free to close this PR right away if this is going into the wrong direction.

With kind regards,
Andreas.

[1] https://community.hiveeyes.org/t/untersuchung-und-verbesserung-des-timings-bei-der-ansteuerung-der-ds18b20-sensoren-unter-micropython/2309
[2] pycom/pycom-micropython-sigfox#356

@kevinkk525
Copy link
Contributor

kevinkk525 commented Nov 4, 2019

It would be interesting if that fixes the problem.
As of now I don't think anyone knows why there is a different behaviour between different esp32 builds.
The changes don't make sense to me in the context of one build working and the next one not but if it works, that'd be great :D

Edit: Ah I see that complete module will be new to esp32 as your 2nd PR removes the esp32 specific onewire library. That makes more sense to me, hopefully it'll work reliable.

@amotl
Copy link
Contributor Author

amotl commented Nov 4, 2019

The changes don't make sense to me in the context of one build working and the next one not.

That might be true when looking at it from one perspective. But if in between ESP32 switched from unicore to dual-core mode, that could well change some subtle details on its runtime behavior.

Also, Espressif Systems are still working on mitigating silicon bugs on their rev.1 and rev.2 revisions through compiler workarounds. Some bad cache coherency issues have been fixed lately, which also can contribute to different timing behavior. All that will also depend on which compiler/toolchain has been used for creating the builds.

In that light, depending on how solid the timing of mp_hal_delay_us_fast actually is, that adjustment could well help - or not at all ;].

your 2nd PR removes the esp32 specific onewire library

As far as I could see, esponewire.c hasn't been used at all within the ESP32 port and might have slipped in when copying files over from the ESP8266 port. So, its removal through #5289 was really just for cosmetic purposes.

@dpgeorge
Copy link
Member

dpgeorge commented Nov 5, 2019

Thanks for the patch.

Did you have a problem with reading onewire sensors on the esp32, and then after applying this patch it worked?

I'm really not sure this would fix anything because for these two delays they only require a minimum delay to work. So they could in principle be much longer delays and it should still work correctly.

The main use of mp_hal _delay_us_fast() is for when interrupts are disabled and it needs accurate timing, which is why this fast function was not used for the two delays here.

@amotl
Copy link
Contributor Author

amotl commented Nov 5, 2019

Did you have a problem with reading onewire sensors on the esp32, and then after applying this patch it worked?

Not quite, I just though I might have spotted something which missed to be adjusted accordingly with respect to the timing problems @kevinkk525 outlined above.

Unfortunately, we are stuck on Pycom MicroPython right now and our real problem is pycom/pycom-micropython-sigfox#356.

So, feel free to close this right away, sorry for the noise and keep up the spirit!

@dpgeorge
Copy link
Member

dpgeorge commented Nov 5, 2019

Not quite, I just though I might have spotted something which missed to be adjusted accordingly with respect to the timing problems

Ok, in that case I'll close this issue. If testing shows that this change fixes things then it can be reopened.

@dpgeorge dpgeorge closed this Nov 5, 2019
kamtom480 pushed a commit to kamtom480/micropython that referenced this pull request Sep 3, 2021
Document missing 'frequency' parameter on ParallelBus.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants