-
Notifications
You must be signed in to change notification settings - Fork 3
[DO NOT MERGE] Update for forthcoming beta MicroPython #97
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
base: main
Are you sure you want to change the base?
Changes from 13 commits
791689a
506c92f
9221520
12a25f1
d9b3ffb
44af467
5ff1eb7
6190ec7
9704523
e0a4593
b7f91ec
79b44b6
b90c486
609444f
7cb5277
f5ca4aa
936b172
7057837
f4c9898
263b689
3826bce
6dcc5ab
fc85377
69aaab7
91eb337
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,16 @@ def ticks_us() -> int: | |
""" | ||
... | ||
|
||
def ticks_cpu() -> int: | ||
""" | ||
Similar to ticks_ms and ticks_us, but with higher resolution in CPU cycles. | ||
|
||
Example: ``time.ticks_cpu()`` | ||
|
||
:return: The counter value in CPU cycles. | ||
""" | ||
... | ||
|
||
Comment on lines
+59
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @microbit-carlos, this is the best guess we made for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi Grace, I wasn't aware that the There is some upstream documentation here: https://docs.micropython.org/en/latest/library/time.html#time.ticks_cpu But it would be good to understand the exact implementation for micro:bit and to have that in the official micro:bit docs as well. I'll have a look. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upgraded here: microbit-foundation/micropython-microbit-v2@fdaf840 That diff contains the implementation that uses CYCCNT. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the moment we always return zero in the sim for ticks_cpu but we could return the same as ticks_us or a multiple. ticks_us is already a 1000 * multiple of ticks_ms which is our real resolution in the sim. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like it was added with the update to MicroPython 1.22.0 in January: microbit-foundation/micropython-microbit-v2#166 The thing to keep in mind is that this is register is 32 bits and we run at 64 MHz, so the register overflows every minute ish ( 2^32 / 64_000_000 = 67 seconds) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @microbit-carlos ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction, it's likely 30-bits due to small int size in MicroPython. |
||
def ticks_add(ticks: int, delta: int) -> int: | ||
""" | ||
Offset ticks value by a given number, which can be either positive or | ||
|
Uh oh!
There was an error while loading. Please reload this page.