Skip to content

Instantly share code, notes, and snippets.

@relic-se
Last active January 22, 2025 22:15
I2S Loopback Test
import board
import pio_i2s
SIZE = 1024
# Bridge GP2 and GP3
i2s = pio_i2s.I2S(
bit_clock=board.GP0,
word_select=board.GP1,
data_out=board.GP2,
data_in=board.GP3,
buffer_size=SIZE,
)
buffer_out = [i for i in range(SIZE)]
i2s.write(buffer_out, loop=True) # Loop fills double-buffered output
buffer_in = i2s.read()
error = 0
for i in range(SIZE):
if buffer_out[i] != buffer_in[i]:
error += 1
print(error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment