(First, if this isn't the appropriate category in which to post, please feel free to relocate this thread!)
I've posted previously about my networked/distributed audio experiments, and I'm looking again at synchronising audio across a network of Teensy 4.1s as best I can.
I know I can start and stop PLL4 while Teensy is running, and adjust the rate of the SAI1 clock. What I would like, is a way to derive a high-resolution clock from the audio subsystem.
Imagine for a moment that my Teensy is receiving a really accurate 1 PPS signal*. I would like to measure, the number of cycles of the SAI1 clock between two pulses. I know that, ideally, in one second, that clock should cycle 11,289,600 (44100 * 256) times per second; if I detect more cycles than that, then I should adjust PLL4 to generate a lower frequency; fewer cycles, higher frequency. The aim is to condition SAI1 to run at the rate indicated by the 1 PPS source.
My suspicion is there's no equivalent to the cycle count register (
Any advice or suggestions very gratefully received.
* In practice I want to attempt a software PTP implementation, which jitter on the network may render completely unfeasible. In any case, I have to at least give it a try.
I've posted previously about my networked/distributed audio experiments, and I'm looking again at synchronising audio across a network of Teensy 4.1s as best I can.
I know I can start and stop PLL4 while Teensy is running, and adjust the rate of the SAI1 clock. What I would like, is a way to derive a high-resolution clock from the audio subsystem.
Imagine for a moment that my Teensy is receiving a really accurate 1 PPS signal*. I would like to measure, the number of cycles of the SAI1 clock between two pulses. I know that, ideally, in one second, that clock should cycle 11,289,600 (44100 * 256) times per second; if I detect more cycles than that, then I should adjust PLL4 to generate a lower frequency; fewer cycles, higher frequency. The aim is to condition SAI1 to run at the rate indicated by the 1 PPS source.
My suspicion is there's no equivalent to the cycle count register (
ARM_DWT_CYCCNT
, 0xE0001004
) for PLL4. I tried duplicating and modifying AudioOutputI2S
and counting calls to MyOutputI2S::isr()
, but that's only called twice per buffer, when DMA requests one half or the other of it, so, at AUDIO_BLOCK_SAMPLES=32
, resolution is only ~2.756 kHz. Can anyone suggest a more accurate/higher-resolution approach? Is such a thing possible?Any advice or suggestions very gratefully received.
* In practice I want to attempt a software PTP implementation, which jitter on the network may render completely unfeasible. In any case, I have to at least give it a try.