input_tdm: every odd channel had every other sample swapped
The TDM input and TDM2 Input modules have samples swapped on every other frame. So for example, assume the following 6 frames of 16 channels from TDM: The first digits are the channel, the last digit is the frame number:
input_tdm: every odd channel had every other sample swapped
The TDM input and TDM2 Input modules have samples swapped on every other frame. So for example, assume the following 6 frames of 16 channels from TDM: The first digits are the channel, the last digit is the frame number:
Here's what's on the TDM bus:
But here's what gets copied into the TDM buffers
Steps To Reproduce Problem
It's pretty easy to reproduce
Take a teensy 4.0 or 4.1, and connect pins 7 and 8 together. (i.e. send SAI TX to SAI RX, no audio actual card required)
Create a sketch with a TDM object, USB object, and a codec object (the codec object is solely to get the TDM going).
connect USB input -> TDM output
connect TDM input -> USB output
play and record simultaneously on your PC
Witness that every other sample of the recorded sample for the right channel is swapped. This is true for all odd TDM channels.
Hardware & Software
Teensy 4.0/4.1
No shield required
Platformio
Teensyduino 1.155
ubuntu 20.04
Arduino Sketch
Errors or Incorrect Output
You can play and record simulataneously from the host. Samples are swapped on all odd TDM channels as seen in this picture:
Top: played out to left and right. Middle: recorded USB left Bottom: recorded USB right, with swapped samples.
Bug fixed with pull request
Here's the fix for the problem:
https://github.com/PaulStoffregen/Audio/pull/428/commits/2021426cbb8233aa946a2d0f9bd0609e2c0e65e6
Here are the results after the fix: