Convert hello_interp.c:times_table to µPython#58
Open
graeme-winter wants to merge 3 commits intoraspberrypi:masterfrom
Open
Convert hello_interp.c:times_table to µPython#58graeme-winter wants to merge 3 commits intoraspberrypi:masterfrom
graeme-winter wants to merge 3 commits intoraspberrypi:masterfrom
Conversation
Not useful for efficient calculation of times-tables (it is not) but a nice way to show accessing hardware registers in the rp2040 from µPython
Author
|
Not sure how useful this would be, but I thought it would be nice to show that you can access a lot of what is written in the data sheets from micropython without too much hassle. |
lurch
reviewed
Jan 6, 2023
interp/interp.py
Outdated
| from machine import mem32 | ||
|
|
||
| # initialise lane 0 on interp: set that we are using all 32 bits | ||
| mem32[0xD0000000 | 0xAC] = 0x1F << 10 |
Contributor
There was a problem hiding this comment.
It's not up to me whether this PR gets merged or not, but IMHO it'd be much easier to read if you had
SIO_BASE = 0xD0000000
INTERP0_ACCUM0 = 0x80
INTERP0_BASE0 = 0x88
INTERP0_POP_LANE0 = 0x94
INTERP0_CTRL_LANE0 = 0xACat the top of the file, and then this line could become:
mem32[SIO_BASE + INTERP0_CTRL_LANE0] = 0x1F << 10(note that I've also changed the | to a +, which is probably more readable to most Python programmers?)
EDIT: I lifted those names directly from https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
Author
There was a problem hiding this comment.
Excellent suggestion, thank you. Done.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Not useful for efficient calculation of times-tables (it is not) but a nice way to show accessing hardware registers in the rp2040 from µPython.