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

Reset UART on deinit, reduces power consumption on nRF #8089

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

furbrain
Copy link

light sleep currently uses about 3-90 uA on nRF (depending on board). However, if you create a busio.UART and then deinit it, the light sleep uses about 1 mA.

This change fixes that by as per this post.

It works by using an undocumented register to power cycle the UART peripheral.

@dhalbert
Copy link
Collaborator

The DevZone post you link to says:

Just adding that the UARTE TX has to be stopped explicitly when it's finished. If you just close the UART without stopping the transactions the UART will continue to keep the clocks running, as described above.

This can be done through the nrfx_uarte_tx/rx_abort() functions, or the TASKS_STOPRX/TX registers directly.

If you do this before disabling the UART the above workaround is not needed.

Could we do the _abort or use the TASKS_STOP registers instead? I'd kind of rather use a documented method than rely on something undocumented whose behavior might change in a future chip rev.

@tannewt tannewt requested a review from dhalbert June 20, 2023 19:59
@furbrain
Copy link
Author

I absolutely agree and also feel uncomfortable using undocumented registers. However:
I did add the _abort calls but these don't seem to actually reduce current consumption on my chip - only the peripheral reset code seemed to work. I've therefore included both strategies in the PR. The RADIO peripheral on nRF52840 does also use a (documented) register at offset 0xffc for power cycling the device, so I would hope that this is in fact a general architecture decision.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback about the change. You've included a pointer to the undocumented fix, so that's the best we can do for now.

@dhalbert dhalbert merged commit 60adfa4 into adafruit:main Jun 20, 2023
dhalbert added a commit to dhalbert/circuitpython that referenced this pull request Sep 12, 2023
dhalbert added a commit to dhalbert/circuitpython that referenced this pull request Sep 12, 2023
tannewt added a commit that referenced this pull request Sep 12, 2023
…er-saving

8.2.x revert #8089 nrf uart power saving
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

Successfully merging this pull request may close these issues.

2 participants