You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @earlephilhower,
I have found a way to improve the sample rate from 48.046 kHz to 48.0000 kHz, and this is really important in my SDR application. It might be useful to others, and it involves modifying your I2S.cpp and I2S.h. The changes I made to I2S.cpp were:
void I2S::MCLKbegin() {
int off = 0;
_i2sMCLK = new PIOProgram(&pio_i2s_mclk_program);
_i2sMCLK->prepare(&_pioMCLK, &_smMCLK, &off, _pinMCLK, 1); // not sure how to use the same PIO
pio_i2s_MCLK_program_init(_pioMCLK, _smMCLK, off, _pinMCLK);
// Use fractional divider for accurate MCLK: desired edges/sec = mult * fs * 2
float mClkEdges = (float)_multMCLK * (float)_freq * 2.0f;
pio_sm_set_clkdiv(_pioMCLK, _smMCLK, (float)clock_get_hz(clk_sys) / mClkEdges);
pio_sm_set_enabled(_pioMCLK, _smMCLK, true);
}
// ...existing code...
I could have used 115200 for I2SSYSCLK_8, too.
I am using the PCM1808 ADC and measuring the frequency of LRCK and SCKI. SCKI should be 12.288 MHz, and I get 12.2879 MHz for it. It might create a bit more jitter, but I don't have the problem requiring me to discard samples regularly, which is probably worse.
I measured three more Chinese Pico clones. The other one was a real Pico W. For SCKI, the frequencies were 12.2885, 12.2886, and 12.2887 MHz, and the clones are all more than an order of magnitude better than the old result. The real Pico W is at least two orders of magnitude better, and its error is on the verge of not being measurable by my humble oscilloscope.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @earlephilhower,
I have found a way to improve the sample rate from 48.046 kHz to 48.0000 kHz, and this is really important in my SDR application. It might be useful to others, and it involves modifying your I2S.cpp and I2S.h. The changes I made to I2S.cpp were:
and to I2S.h
I could have used 115200 for I2SSYSCLK_8, too.
I am using the PCM1808 ADC and measuring the frequency of LRCK and SCKI. SCKI should be 12.288 MHz, and I get 12.2879 MHz for it. It might create a bit more jitter, but I don't have the problem requiring me to discard samples regularly, which is probably worse.
I measured three more Chinese Pico clones. The other one was a real Pico W. For SCKI, the frequencies were 12.2885, 12.2886, and 12.2887 MHz, and the clones are all more than an order of magnitude better than the old result. The real Pico W is at least two orders of magnitude better, and its error is on the verge of not being measurable by my humble oscilloscope.
Do you see anything wrong with this?
Rob
Beta Was this translation helpful? Give feedback.
All reactions