Repository navigation
Add opt-in exact PLL3 audio clock - #733
Open
Ninety-Days wants to merge 1 commit into
Open
Ninety-Days wants to merge 1 commit into
Ninety-Days wants to merge 1 commit into
Conversation
System::Config::exact_audio_clock (and DaisySeed::exact_audio_clock, read by DaisySeed::Init()) sets PLL3 to M=5, N=192, P=25, R=25 for an exact 24.576 MHz SAI kernel clock, so 8-96 kHz run at their nominal rates instead of ~298 ppm fast. The default PLL3 setting is unchanged. SAI_192KHZ cannot be reached from that clock. SaiHandle::Init() now returns an error, before changing any state, when the kernel clock is too slow for the requested rate, instead of letting the HAL run it at a lower rate. Refs daisyaudio#731
Test Results167 tests ±0 164 ✅ - 3 0s ⏱️ ±0s For more details on these failures, see this check. Results for commit 48f24c5. ± Comparison against base commit 1289a00. |
Author
|
CI note: the failing checks look unrelated to this change. The 3 util_WavWriter tests fail the same way on clean master when built with -D_GLIBCXX_ASSERTIONS (f_write() in tests/FatFsMock.cpp indexes file_data at size() for a 0-byte write), and build-makefile stops at "Setup python" because Python 3.8 is no longer available for ubuntu-latest. |
This branch has not been deployed
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.
Stop gap for #731, as discussed there.
Adds an opt-in
exact_audio_clockflag. When it is set,System::ConfigureClocks()uses PLL3 M=5, N=192, P=25, R=25 (614.4 MHz VCO, 24.576 MHz SAI and ADC kernel clocks) instead of M=6, N=295, P=16, R=32, so 8, 16, 32, 48 and 96 kHz run at their nominal rates. The default is unchanged.Code that calls
System::Init()directly can set the same flag onSystem::Config.192 kHz: from a 24.576 MHz kernel clock,
SAI_192KHZwould need MCKDIV below 1, and the HAL would run it at 96 kHz without an error.SaiHandle::Init()now checks this first, with the same rounding asHAL_SAI_Init(), and returnsResult::ERRbefore changing any state, so the previous rate keeps running andGetSampleRate()keeps reporting it. The check only applies when a block is master; with the default clock every rate passes it.Open points:
DaisySeedmember read byInit(), because the board classes only passboostthrough toDaisySeed::Init(). Happy to expose it another way if you prefer.DaisyPatchSMbuilds its ownSystem::Configand is not covered here; it would be a one-line addition.skip_clocksis set (bootloader older than v6, running from QSPI), since the clocks then come from the bootloader.Tested on a Daisy Pod (Seed rev7, PCM3060, STM32H750 rev V) at 48 kHz, reading the registers over USB:
PLL3DIVR = 0x1F031F26, MCKDIV = 4, 48014.32 Hz, as beforePLL3DIVR = 0x180330BF, MCKDIV = 2, 48000.0000 HzThe 192 kHz error path is not tested on hardware.