pico-extras icon indicating copy to clipboard operation
pico-extras copied to clipboard

audio_i2s.pio comment regarding FIFO word reverses channels

Open rde2 opened this issue 2 years ago • 1 comments

The comment in audio_i2s.pio explaining the word format reverses the 'ws' (LRCLK) value. The PIO sends the first (most significant) 16 bits with LRCLK = 1 and the second with LRCLK = 0. For stereo samples the second 16-bit half in memory corresponds to bits 31:16 and hence is the right channel (assuming I2S where LRCLK = 0 for left).

; Autopull must be enabled, with threshold set to 32.
; Since I2S is MSB-first, shift direction should be to left.
; Hence the format of the FIFO word is:
;
; | 31   :   16 | 15   :    0 |
; | sample ws=0 | sample ws=1 |

rde2 avatar Mar 04 '23 15:03 rde2

I believe that I2S requires the left channel to be sent before the right, so playback may be out of sync. See the thread https://forums.raspberrypi.com/viewtopic.php?p=2087056#p2087056 for a discussion.

rde2 avatar Mar 07 '23 17:03 rde2