Bug: Audio board I2S input data randomly out of sync after program reload

DerekR

Well-known member
This is an issue originally raised by DD4WH here, and expanded by me in posts #30 and #31 of that thread. After spending several days analyzing the issue and trying to find a fix or work-around I want to elevate it to a formal bug report.

In Teensy SDR (software defined radio) using the audio library blocks, it is common to use the I2S inputs for the baseband quadrature signals. It is vital that the phase difference between the two channels is maintained at 90 deg - if not the whole signal processing chain is compromised. A phase error of only 2-3 deg can upset things! DD4WH and I have been independently working on phase (and amplitude) correction code to compensate for inherent errors in the SDR analog hardware. I have been frustrated by the fact that sometimes my code would work perfectly, but reload of the same code would produce "crappy" performance 40-50% of the time. If the Teensy power was cycled off and on the performance returned to "great"!

We have isolated the problem down to the fact that apparently the SGTL5000 codec is not being reset after a program reload, and the data streams from the I2S inputs somehow become out of sync with each other by one time-step (see my posts #30 and #31 in the link above) causing a time delay of 1/44100 sec between channels, resulting in a phase error that is proportional to the input frequency (8 deg/kHz) which drives the SDR software (and me) crazy!

I have spent many hours (as have DD4WH and bmillier) playing with the SGTL5000 control registers trying to force a reset, but without success.

I guess an alternative explanation might be that the SPI data transfer to the Teensy is getting out of sequence...

Code to demonstrate the problem is posted in #31. I have also uploaded the files in a zip file View attachment TestPhaseError.zip. Note however you need an external quadrature audio signal source to create the problem.

Any suggestions would be greatly appreciated.
 
Last edited:
Back
Top