Skip to content

Conversation

@andygpz11
Copy link
Contributor

Improve the current hardcoded PLL and clock set-up

@andygpz11
Copy link
Contributor Author

andygpz11 commented Feb 21, 2023

I have just pushed some changes for comment which I think address the XOSC and system frequency related hard-codings in the SDK.
Making set_sys_clock_pll() and check_sys_clock_khz() properly general purpose wasn’t possible without changing their APIs so, for now, I left them: This is because neither of them currently support ’refdiv’ setting other than 1. I have coned a new #define to keep things in step along with a tripwire to enforce this.
Having used vcocalc.py it is not clear to me that refdiv settings other than 1 can sensibly be used anyway.
A few ‘pico-examples’ will need updating to use the definitions I have added to platform_defs.h

I expect some review changes but I'd like to do some more testing of this before it is merged anyway.

Copy link
Contributor Author

@andygpz11 andygpz11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest version. I think I have addressed all comments.
I also found that one of the asserts in pll_init() was non-functional due to an error of scaling and also that check_sys_clock_khz() should not use clock_get_hz() but the XOSC_MHZ define instead.
Apparently the PLL ref divs inputs are always connected to the output of the XOSC cell and therefore the (possible) multiplexing and division present in the clock switching is not applicable to them.

@liamfraser
Copy link
Contributor

This looks good to me, apart from the btstack related commit

@andygpz11
Copy link
Contributor Author

andygpz11 commented Feb 23, 2023

This looks good to me, apart from the btstack related commit

Thanks and agreed. I found I could not push to my branch because there was another push that I hadn't got locally.
So I did a 'git pull --rebase' and then a push. It was not enough for me to rebase my local branch from develop which is what I also tried.

@kilograham
Copy link
Contributor

This looks good to me, apart from the btstack related commit

Thanks and agreed. I found I could not push to my branch because there was another push that I hadn't got locally. So I did a 'git pull --rebase' and then a push. It was not enough for me to rebase my local branch from develop which is what I also tried.

well you have picked up some other stuff it seems (bt license)

Copy link
Contributor

@kilograham kilograham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please read thru all pre-existing review comments, and issue comments - they keep getting ignored

@andygpz11 andygpz11 self-assigned this Mar 2, 2023
Copy link
Contributor

@kilograham kilograham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note all the new user overridable defines should also have PICO_CONFIG comments

@kilograham kilograham assigned kilograham and unassigned andygpz11 Mar 3, 2023
@lurch
Copy link
Contributor

lurch commented Mar 5, 2023

The tag::pll_settings block has now been totally removed - could it (or something very similar) be restored please? As a reminder, it gets auto-included into Section 2.18.3. of https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf

@kilograham kilograham requested a review from liamfraser March 19, 2023 23:47
liamfraser
liamfraser previously approved these changes Mar 20, 2023
Copy link
Contributor

@liamfraser liamfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good

//
// The two PLLs use the crystal oscillator output directly as their reference frequency input; the PLLs reference
// frequency cannot be reduced by the dividers present in the clocks block. The crystal frequency is defined by `XOSC_KHZ` or
// `XOSC_MKHZ`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MKHZ? 🤔

@kilograham kilograham self-requested a review March 21, 2023 17:08
@kilograham kilograham merged commit a42564b into raspberrypi:develop Mar 21, 2023
@kilograham
Copy link
Contributor

fixes #1024

andygpz11 added a commit to andygpz11/pico-sdk that referenced this pull request May 31, 2023
…rrypi#1272)

* Allow pre-processor overrides for Clock/PLL setup
* Use `_KHZ` rather than `_MHZ` for `XOSC_` `SYS_CLOCK_` etc definitions (`_MHZ` versions are provided for compatibility when `_KHZ` is a multiple of 1000)

Co-authored-by: graham sanderson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants