-
Notifications
You must be signed in to change notification settings - Fork 8.1k
drivers: clock_control: nrf2: improve audiopll clock calculations #97735
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?
Conversation
Improve the Audio PLL clock frequency calculations to provide a more accurate clock frequency. Signed-off-by: Victor Brzeski <[email protected]>
563f97a
to
768819d
Compare
|
I'm actually unsure if this formula in the source code is correct. The standard div value overflows for 48k |
case 8: | ||
return AUDIOPLL_DIV_8; | ||
case 12: | ||
return AUDIOPLL_DIV_12; |
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.
Prescaler div 12 was the only used and valid prescaler when this driver was written, has that changed?
@tmon-nordic any input? |
Where do you see overflow? Code uses
It is important to note that while the comment |
switch (divider) { | ||
case 0: | ||
return AUDIOPLL_DIV_DISABLED; | ||
case 6: | ||
return AUDIOPLL_DIV_6; | ||
case 8: | ||
return AUDIOPLL_DIV_8; | ||
case 12: | ||
return AUDIOPLL_DIV_12; | ||
case 16: | ||
return AUDIOPLL_DIV_16; | ||
default: | ||
__ASSERT(divider <= 4, "invalid audiopll divider"); | ||
return (enum audiopll_prescaler_div)divider; | ||
} |
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 values seem to originate from nrfs header, but I have no idea why nrfs makes them available. I would prefer if AudioPLL just continues to use hardcoded AUDIOPLL_DIV_12
which is known to work.
With corrected comparison script, the results are as follows:
Therefore new formula is slightly better on accuracy. |
Improve the Audio PLL clock frequency calculations to provide a more accurate clock frequency.
These formulas were derived with a Wolfram Alpha query using the long-form formula in the source comments.