Skip to content

piolib/i2s: fix the left and right channel comments - #63

Open
deadprogram wants to merge 1 commit into
mainfrom
i2s-channel-comments
Open

deadprogram wants to merge 1 commit into
mainfrom
i2s-channel-comments

Conversation

@deadprogram

Copy link
Copy Markdown
Member

This PR fixes the comments in the I2S program. They said LRCLK=1 is the left channel, but in the Philips I2S bus specification LRCLK=0 is the left channel and LRCLK=1 is the right channel.

The code does not change. The program shifts MSB first and starts at the entry point with LRCLK=1. So bits 31 to 16 of each frame go out while LRCLK=1, which is the right channel, and bits 15 to 0 go out while LRCLK=0, which is the left channel. Each loop sends its last bit one clock after LRCLK changes, as I2S requires.

This PR also documents that WriteStereo takes the left sample in the low half of each frame. The new I2S drivers for nRF52 (tinygo-org/tinygo#5786) and esp32xx (tinygo-org/tinygo#5787) use the same layout, and both were checked by ear on a PCM5102 DAC.

The pio I2S example builds for the pico. I did not test this change on RP2040 hardware, because only comments change.

The comments said LRCLK=1 is the left channel. In the Philips I2S bus
specification LRCLK=0 is the left channel. The program sends bits 31 to
16 while LRCLK=1, so the low half of each WriteStereo frame is the left
sample. The code does not change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant