8000 Initializing ESP_SPIcontrol after I2S DAC results in audio not playing (Fruit Jam) · Issue #10461 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
Initializing ESP_SPIcontrol after I2S DAC results in audio not playing (Fruit Jam) #10461
Open
@FoamyGuy

Description

@FoamyGuy

When using both DAC and ESP32SPI it seems that the order the objects are initialized causes the DAC to work or not. If ESP_SPIControl is initialized before the DAC then audio play back works successfully. But if the DAC is initialized before ESP_SPIControl then audio playback does not work. audio.playing property is true and the while loop finishes after the length of the audio file, but no audio comes out of the speaker.

Adafruit CircuitPython 10.0.0-alpha.7-7-g363be5fe80 on 2025-07-01; Adafruit Fruit Jam with rp2350b

This reproducer script illustrates the issue. Swapping between the two commented ESP init lines causes the audio playback to work or not work consistently for me on Fruit Jam revC hardware.


from audiocore import WaveFile
import time
import gc
import board
import busio
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
from os import getenv
import adafruit_tlv320
import audiobusio


ssid = getenv("CIRCUITPY_WIFI_SSID")
password = getenv("CIRCUITPY_WIFI_PASSWORD")
esp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)

# Init ESP_SPIControl here and the audio beep plays successfully
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)


i2c = board.I2C()
dac = adafruit_tlv320.TLV320DAC3100(i2c)
dac.headphone_output = True
dac.configure_clocks(sample_rate=16000, bit_depth=16)
audio = audiobusio.I2SOut(board.I2S_BCLK, board.I2S_MCLK, board.I2S_DIN)
wave_file = open("/beep.wav", "rb")
beep_wave = WaveFile(wave_file)

# Init ESP_SPIControl here and the audio beep does not play
# esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

time.sleep(2)

audio.play(beep_wave)
while audio.playing:
    pass

print("Audio playback complete")

This audio file is used: beep.wav.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0