-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Circuitpython nickzoic 1046 nrf rtc #1534
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
Circuitpython nickzoic 1046 nrf rtc #1534
Conversation
I have been unable to get |
I'm very puzzled about the whole thing. I'm not, at this point, sure if it is a flaw in my understanding of I got as far as working out that if I removed the weak declarations, OR changed the error messages raised by the weak declarations to be different, then the problem goes away. 8a88a6f uses this workaround so at least I could make some progress on this issue, but I'm not real happy about it. |
(oh, and because I changed that error message it's upset the translations, which is what Travis is complaining about. I'm seeking a better way) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works great! Thanks! Please update your translations and it should be good to go.
Adafruit CircuitPython 4.0.0-beta.2-31-ga48d69501 on 2019-02-13; Adafruit Feather nRF52840 Express with nRF52840
>>> import rtc
>>> r = rtc.RTC()
>>> r.datetime
struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=29, tm_wday=5, tm_yday=1, tm_isdst=-1)
>>> import time
>>> time.time()
946684843
>>> time.localtime()
struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=57, tm_wday=5, tm_yday=1, tm_isdst=-1)
>>> r.datetime = time.struct_time((2019, 2, 14, 10, 20, 0, 3, 0, -1))
>>> time.localtime()
struct_time(tm_year=2019, tm_mon=2, tm_mday=14, tm_hour=10, tm_min=20, tm_sec=2, tm_wday=3, tm_yday=45, tm_isdst=-1)
>>> time.localtime()
struct_time(tm_year=2019, tm_mon=2, tm_mday=14, tm_hour=10, tm_min=20, tm_sec=10, tm_wday=3, tm_yday=45, tm_isdst=-1)
>>> time.localtime()
struct_time(tm_year=2019, tm_mon=2, tm_mday=14, tm_hour=10, tm_min=20, tm_sec=12, tm_wday=3, tm_yday=45, tm_isdst=-1)
>>>
Possibly this could be combined with deepsleep, which also needs an RTC timer as timeout and to advance the systick so time.monotonic() returns a reasonable result after sleep. This however would require a lower divide value (1024). My implementation of deepsleep is here: https://github.com/bboser/iotpython/blob/master/ports/nrf/common-hal/microcontroller/__init__.c. The other possible issue is that apparently the softdevices (BT?) also use RTC timers. Somewhere I read that RTC0 is used by the softdevice but I cannot locate the reference. |
@nickzoic Are you blocked by anything on this? |
Hi Scott! I got sidetracked trying to work out the weak reference thing. See comments at end of #1046. |
a48d695
to
f04294f
Compare
OK so I've rebased it and sadly, no change. I've just changed one of the messages for now and provided translations as best I can approximate for the new message. |
I think we should get this in once the translations are merged. It should be good to go otherwise. |
Did I get the push wrong again? I'm away for a few days but have laptop so can amend if necessary ...
…-----Nick
|
@nickzoic please take a look when you are back. There are files that need to be merged. |
(works if MP_WEAK common_hal_rtc_get_time is removed)
the __weak linking works fine so long as these functions are not identical. I have not yet worked out why.
The mysterious MP_WEAK linking bug still exists, thus the new message for 'set'.
c297266
to
a06ce33
Compare
OK @tannewt trying yet again to get this to pass CI checks ... |
@nickzoic Just saw this issue in micropython: micropython#4590. Is it relevant to your impl? |
@dhalbert you mean for the problems with the Ethernet wing like #1500, right? The Wiznet5K implementation for circuitpython doesn't use LWIP but it might be worth looking at the error handling in |
RIght - I didn't know how much of your code was common with the MPy code, if any. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tweaked one old comment and looks good otherwise. Will merge after Travis gives the ok. Thanks for your persistence on this!
On Fri, 29 Mar 2019, at 03:30, Scott Shawcroft wrote:
***@***.**** approved this pull request.
Tweaked one old comment and looks good otherwise. Will merge after Travis gives the ok. Thanks for your persistence on this!
Thanks Scott! Yeah, getting languages to merge is a bit of a bear, eh ... every time I think it's working they get out of date again!
(I do think multilingual support is a great feature though, I just wish it was easier to merge!)
|
Ya, I looked into having a smarter merge but didn't see any great options. |
@nickzoic Want to take a look at why this broke BLE? Totally ok if you don't have the time. |
The BLE soft device uses RTC 0. Just a hunch. See my earlier comment on
github.
Bernhard
…On Mon, Apr 1, 2019 at 3:03 PM Scott Shawcroft ***@***.***> wrote:
@nickzoic <https://github.com/nickzoic> Want to take a look at why this
broke BLE? Totally ok if you don't have the time.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1534 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC3bpHcPztJUsooH1cstE8bS48SNVuiXks5vcoIsgaJpZM4a1e93>
.
|
On Tue, 2 Apr 2019, at 09:13, Bernhard Boser wrote:
The BLE soft device uses RTC 0. Just a hunch. See my earlier comment on
github.
Yeah, I saw that one (thanks!) but didn't get around to following up (sorry!)
A quick google suggests you're correct ...
https://devzone.nordicsemi.com/f/nordic-q-a/5235/usage-of-rtc0-as-time-basis-system-time-possible
https://devzone.nordicsemi.com/f/nordic-q-a/305/rtc0-rtc1-and-the-app_timer-with-softdevice
https://devzone.nordicsemi.com/f/nordic-q-a/22941/how-to-enable-and-use-rtc0-rtc1-and-rtc2----nrf52832
Suggests RTC0 is used by the softdevice and RTC1 is used by the app_timer library which is used in other libraries.
So maybe, so long as we're no longer targeting the '32 revision A, we should move it to RTC2?
https://www.nordicsemi.com/DocLib/Content/Errata/nRF52832_EngA/latest/ERR/nRF52832/EngineeringA/latest/anomaly_832_10
I'll have to work out how BLE works so I can actually test this I suppose!
Re: your other comments about deepsleep, definitely yes, that'd be a good idea.
…-----N
|
(to avoid interference with Bluetooth Softdevice. See adafruit#1534 (comment) with thanks to @bboser for pointing it out)
See the example in #1726. Try that. If that doesn't cause an immediate error, then doing something like https://github.com/adafruit/Adafruit_CircuitPython_BLE/blob/master/examples/ble_uart_echo_test.py with the Adafruit Bluefruit LE Connect app on the other end would be a simple test. |
Also, take out the |
OK that UART example works with nickzoic/micropython@48f056647f which now uses RTC2. Thanks for the pointer, I hadn't tried using BLE for anything yet. I'll rebase onto master and make a new PR very soon |
(to avoid interference with Bluetooth Softdevice. See adafruit#1534 (comment) with thanks to @bboser for pointing it out)
Yes, we don't compile the source files for modules that are turned off. But Or maybe I am all wrong about this, but looking at the uses of RTC, it does not seem to need fallback routines. |
Yep, I've removed them altogether since both atmel-samd and nrf ports have RTC anyway. Thanks for your patience :-) #1736 should hopefully work out better! |
This is an implementation of #1046 , with a couple of things missing: