Settle clock source before tuning, not after#1793
Closed
munzzyy wants to merge 1 commit into
Closed
Conversation
If CLKIN was in use but the external clock disappeared since the last transceiver operation, transceiver_startup() would tune the RFFC5071/MAX283x first and only call activate_best_clock_source() afterward. The Si5351C fallback to XTAL disables outputs, changes the PLL feedback divider, and resets the PLL, so tuning that ran before the fallback was relocking against a reference that was about to glitch out from under it. Move the clock source check to the front of transceiver_startup() so the reference is stable by the time radio_switch_opmode() tunes. Fixes greatscottgadgets#1719.
Member
|
We do not accept LLM-generated contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1785.
The regression is a variable mix-up in
radio_update_frequency()infirmware/common/radio.c. When an explicit LO is requested, the code is supposed to pass that requested value intomixer_set_frequency(), but it actually passesfreq_lo, which at that point still holds the previously applied LO:Right after a device reset there is no previously applied LO, so
freq_lois stillRADIO_UNSET(all ones), and that huge sentinel gets fed to the mixer as if it were a real target frequency.rffc5071_config_synth()doesn't reject it, it just crunches the math and comes out with some in-range but meaningless divider/register values, which is exactly the bogusFREQUENCY_LO/FREQUENCY_RF(and derivedROTATION/LPF settings) shown in the register dumps on the issue. Once one auto-tune has happened,freq_loholds a sane prior value, so the same bug quietly does nothing useful (it just re-tunes to the old LO before the later "compute precise LO" logic corrects it), which is why "explicit tune after auto-tune" looks fine and only "explicit tune right after reset" breaks.The IF branch just above already handles this correctly:
This change makes the LO branch consistent with that, passing
requested_loinstead offreq_lo. One-line fix, nothing else touched.I checked the two in-flight PRs that also touch tuning code (#1772, #1774) in case this was already covered there - neither modifies
radio_update_frequency,mixer_set_frequency, or anything aroundrequested_lo/freq_lo, so this is independent of that series and doesn't conflict with it.I don't have a HackRF on hand to flash right now, so this is reasoned from the code path and the register dumps already in the issue, not verified on hardware. To confirm: reset the device, then set center frequency with explicit IF/LO (
hackrf_transfer -i ... -o ... -m 1) and check thatFREQUENCY_LO/FREQUENCY_RF/ROTATIONcome out matching an auto-tune to the same frequency, instead of the ~160 MHz garbage currently seen on that path. Also worth re-running the "auto-tune" and "explicit after auto-tune" cases from the issue to make sure they're unaffected. I also don't have the ARM toolchain set up here (no arm-none-eabi-gcc/cmake), so this hasn't been compiled either, just read through carefully against both call sites and the register dumps.