-
Notifications
You must be signed in to change notification settings - Fork 918
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
[WIP] Separate system clock config for rp2xxx devices #4674
base: dev
Are you sure you want to change the base?
Conversation
Thank you for the PR @cibomahto Can you please run /bin/sh: 1: node: not found
Unformatted:
src/machine/machine_rp2_2040.go
src/machine/machine_rp2_2350.go
make: *** [GNUmakefile:185: fmt-check] Error 1 |
src/machine/machine_rp2_2040.go
Outdated
@@ -113,6 +113,19 @@ const ( | |||
fnXIP pinFunc = 0 | |||
) | |||
|
|||
// System clock configuration | |||
const ( | |||
pllSysFreq uint32 = 125 * MHz |
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.
The rp2040 datasheet says that its cores are capable of 133 MHz. A cursory glance at the datasheet didn't mention any downside to that speed, so why is TinyGo running at 125 MHz? Perhaps it's because of non-integer periods that you mention in the PR description for rp2350? If so, this PR might consider rp2040 at 133 MHz for the same reasons you chose 150 MHz for rp2350.
Failing all that, a comment would be nice.
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.
That's a good point, I don't know why it was running at 125 either, but this seems plausible.
* Addresses tinygo-org#4673: input oscillator frequency can be changed for an individual board by filling in a custom PLL configuration
Changing out the xoscFreq constant for a package level variable feels off. I also don't understand what we gained from switching out the constant for a xoscFreq field on clockCfg. In any case the constants could remain in each board-level file and the variable be set in a single package level file. |
As is, the xoscFreq constant doesn't work- you need to configure the PLLs to match the xoscFreq setting, and they were hard-coded in the clock configuration routine. Otherwise, you won't get the correct CPU clock speed, or the PLL might not actually start. I guess some other options are:
In C-style apis, it's a common pattern to have default tables that you can pass to init routines, but I haven't been able to find something similar in TinyGo. The closest so far is for instance the SPI or I2C configuration objects (for example), but in this case the defaults are 'secret', and applied when fields are left at 0, which seems a little weird to me. |
Here is a first pass at separating the PLL configuration options for the rp2xxx devices, to allow the rp2350 to be configured for 150MHz. I tested (using a logic analyzer) that the UART, USB, I2C, and SPI generate roughly correct speeds.
I moved the configuration into the machine files, but it could be nice to allow a board to override them. If you have a suggestion for how to do that, please let me know.
I know of three issues that should be fixed before submitting the pull request:
cc @soypat @deadprogram