Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[DO NOT MERGE] Update for forthcoming beta MicroPython #97
base: main
Are you sure you want to change the base?
[DO NOT MERGE] Update for forthcoming beta MicroPython #97
Changes from 17 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
There are no files selected for viewing
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 is an update based on recently merged micropython doc PR.
f5ca4aa - I copied
set_threshold
doc from the PR936b172 - my update of it to make the tenses match the rest of the docs and to make it clearer (maybe)?
Looks quite verbose, so I am tempted to cut it down, but am not sure how
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.
Hi @microbit-carlos, this is the best guess we made for
ticks_cpu
because we couldn't find micropython docs on it. Is this right and are there any more specific information we can add about this? Thanks!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.
Hi Grace,
I wasn't aware that the
ticks_cpu
function was enabled in the V2 MicroPython port, do you know when it was added? Has it been added only in the latest release?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 comment
The 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 comment
The 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 comment
The 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
It uses low level Arm register to count cycles, so this should be correct (of course, there will be a bit of overhead by calling and returning from a Python function but that's the same for every other time.ticks_xx function):
https://github.com/microbit-foundation/micropython-microbit-v2/blob/8d9067d91bcfe316cd3aea5af1a873a37ca23d13/src/codal_port/mphalport.h#L48-L55
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 comment
The 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 comment
The 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.