Skip to content
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

Husky: potentially incorrect ADC sampling rate phase when using external clock #499

Open
jpcrypt opened this issue Nov 1, 2024 · 0 comments
Assignees
Labels

Comments

@jpcrypt
Copy link
Contributor

jpcrypt commented Nov 1, 2024

When scope.clock.clkgen_src = 'extclk', then when setting scope.clock.clkgen_freq = X, we calculate Husky's PLL parameters to generate an ADC sampling clock as close as possible to scope.clock.adc_mul times the observed (measured by Husky) external clock frequency (let's call that X'), instead of scope.clock.adc_mul times the specified external clock frequency X.

If X' is not exactly X (which is possible and commonly occurs), then potentially there will not be a constant adc_mul samples per target clock cycle: once in a while there will be one extra or one less ADC sample in one clock cycle; also the phase relationship between the target and ADC clocks will not be constant: it will be slowly shifting forwards or backwards.

Usually, even if X' is not exactly X, then the "as close as possible" part mentioned above means we actually end up getting an ADC sampling clock of exactly adc_mul times the target clock (i.e. there is no problem).

But in theory that's not always the case, and exceptions have been observed: they are rare, but possible. They are more likely to occur with large adc_mul values.

A fix is forthcoming as part of wider fixes and improvements to the Husky clock management code. In the meantime, if:
1 / scope.clock.pll.get_input_div() * scope.clock.pll.get_pll_mul() * 5 / scope.clock.pll.get_prescale() / scope.clock.pll.get_outdiv(1) == 1

then you're ok. If not, you can try a different adc_mul.

@jpcrypt jpcrypt added the bug label Nov 1, 2024
@jpcrypt jpcrypt self-assigned this Nov 1, 2024
jpcrypt added a commit that referenced this issue Nov 25, 2024
Covers #490,
#499,
#501, and
#448.

Not added to test_husky.py because it's useful to be able to plot and
interact with failing cases.
alex-dewar pushed a commit to alex-dewar/chipwhisperer that referenced this issue Jan 8, 2025
Covers newaetech#490,
newaetech#499,
newaetech#501, and
newaetech#448.

Not added to test_husky.py because it's useful to be able to plot and
interact with failing cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant