Skip to content

i2s audio test fails on Raspberry Pi Pico and PCM5102A DAC #9910

@stanelie

Description

@stanelie

CircuitPython version

Adafruit CircuitPython 9.2.1 on 2024-11-20; Raspberry Pi Pico with rp2040

Code/REPL

import audiobusio
import audiocore
import board
import array
import time
import math

I2S_CLK = board.GP2
I2S_WS = board.GP3
I2S_DATA = board.GP4

# Generate one period of sine wave.
length = 8000 // 440
sine_wave = array.array("H", [0] * length)
for i in range(length):
    sine_wave[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15)

sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000)
i2s = audiobusio.I2SOut(I2S_CLK, I2S_WS, I2S_DATA)
i2s.play(sine_wave, loop=True)
time.sleep(1)
i2s.stop()

Behavior

This sounds like the busy tone on a phone in north america, not the pure sine wave I should be getting.

I've used this DAC on a ESP32-C3 chip with no issue, I know it works fine. There have been other issues a bit similar to this in the past with the Pi Pico, not sure if it's related. Should I be using those pins?

Description

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions