Sharing thoughts and experience (not a question).
How to configure a PLL - the Multiplier and Divider values?
The "question" come from: dealing with audio, setting a "perfect" clock for audio (e.g. 48 KHz).
I see multipliers and divider values on PLL config - but how to choose the right combination?
There are different pairs of values to get 48 KHz - but which one is the "best"?
Overview about PLL:
- PLL gets a clock from system input (can be a multiplied XTAL clock, let's say any system clock comes to a PLL
- a PLL, e.g. needed to clock a peripheral/device, e.g. SAI, SPDIF, has a pair of a multiplier and a divider (for one output)
- this combinations sets the PLL out clock speed, e.g. 48 KHz - exactly 48 KHz or a bit off
- I want to make it perfect for 48 KHz - but I have different combinations of multiplier and divider value pairs possible
- which one is the best?
So, my conclusion:
I want to trim the PLL later a little bit: instead of exactly 48 KHz - I want to run with 47.9 or 48.1 KHz. What does give me the most "fine-tunable" value pair?
It turns out as:
- if multiplier value is the largest value possible (in valid range!)
- and divider is the largest possible to provide the required output clock
it gives me the most "fine-tunable" clock: the multiplier can be changed now to a plus/minus value with the smallest change in speed: the "clock resolution" is better, more fine granular.
I can now trim the PLL by adjusting the multiplier by just few KHz difference.
If I would chose the opposite: a small multiplier but also a small divider:
- the clock frequency step (when changing multiplier) is much larger (resolution smaller)
It covers now a larger range to change the frequency but with less resolution (steps).
Larger range with less resolution vs. smaller range but finer resolution.
So, I use this approach:
- find a setting with largest multiplier and largest divider to get my nominal frequency
- it gives me more fine tuning steps on multiplier to adjust the frequency
On the Portenta H7 there is the "beauty" to have also fractional part of multiplier. It let's you even more fine tune the frequency, e.g. for my nominal audio clock I need to be in sync with the sender. The "free running audio clocks" is a separate issue, just my goal: tweak the clock frequency to stay in sync with incoming audio (e.g. SPDIF) for the longest period "possible".
When using fractional divider - you will realize that the "range" how they can vary the clock speed depends on the main integer multiplier (and associated divider):
the larger the multiplier (and divider) - the smaller the fine tuning range with fractional, but now much more fine granular.
Assuming you know, that PLL parameters such as multiplier and divider depend on the input frequency, also the voltage range selector for the PLL - you can choose PPL config with different pairs of multiplier and divider (depending on your "resolution" to trim a clock frequency).
Just use the right pair (combination) for your goal.
BTW:
The Portenta H7 with the fractional multiplier value is pretty cool: it allows to adjust the clock via this fractional multiplier "on the fly": no need to stop PLL (no need to stall the audio), just to set a new value, e.g. for "adaptive clock recovery".
Also good approach: make the audio buffers as largest as possible (based on available memory). The larger the buffers, assuming audio runs in DMA mode - the less sensitive for "clock jitter":
If the audio clock is not very stable, it changes up and down in frequency ("jitter") - a larger buffer makes it less sensitive for this issue. But it creates also latency: now the audio is a bit behind, not "lip sync" anymore.
If you have a clock difference - now with larger buffers the audible "clicks" come more spread apart (not so often).
Smaller buffers, worst case: an audio frame for 48 KHz, with 48 stereo samples only, every 1 ms - is more sensitive for clock drifts, jitte, clock speed difference. This makes the fine tuning of PLL (or even using "adaptive clock recovery") more challenging.
Larger buffers are better sound but also much more delay (not "lip sync" anymore).\
Have fun with PLLs and Audio Applications.