Skip to content
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

nRF52 OneWire unreliable #1831

Closed
gfwilliams opened this issue May 29, 2020 · 4 comments
Closed

nRF52 OneWire unreliable #1831

gfwilliams opened this issue May 29, 2020 · 4 comments

Comments

@gfwilliams
Copy link
Member

This has been known for a while - basically the softdevice can jump in via an IRQ to do BLE stuff and screw up timing whenever it wants to. It means that OneWire while BLE is active can be unreliable.

It seems there's not really a great way of using any hardware to do OneWire - it needs to be bit-banged. And disabling IRQs during OneWire activity can make the device unstable.

However it looks like we can actually use the timeslot API to request a period of time where the softdevice won't interfere:

https://devzone.nordicsemi.com/nordic/short-range-guides/b/software-development-kit/posts/setting-up-the-timeslot-api

@hyhkjiy
Copy link

hyhkjiy commented Aug 27, 2021

It seems that not only SoftDevice will interrupt the OneWire timing, but all interrupt signals will interfere with it, such as PWM or timer.

@gfwilliams
Copy link
Member Author

Yes, it's in the main thread. I believe normally (eg STM32) we'd stop interrupts but we can't because if we inadvertently stop the softdevice it causes big issues.

It's frustrating that there doesn't really appear to be a good solution at the moment. I guess using Timeslot API (as above) would be best though. Since it's then called from an IRQ it would likely have priority over other IRQs so PWM/etc would no longer be a problem.

@hyhkjiy
Copy link

hyhkjiy commented Sep 8, 2021

You are right, maybe it can be done with nRF5 SDK, but I haven't found an example of running one wire and BLE on nRF52 at the same time. I want to try it but I can't get started. Would you like to provide more reference information for this?

@gfwilliams
Copy link
Member Author

Forum thread on this too: https://forum.espruino.com/conversations/331390

Now fixed using the timeslot API. We could probably extend this to perform the entire transaction in one timeslot (instead of just individual writes) but it works for now (albeit slightly more slowly)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants