Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use DAC play audio not work (IDFGH-5999) #7684

Closed
xiaowei809362674 opened this issue Oct 13, 2021 · 7 comments
Closed

use DAC play audio not work (IDFGH-5999) #7684

xiaowei809362674 opened this issue Oct 13, 2021 · 7 comments
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@xiaowei809362674
Copy link

Environment

  • Development Kit: ESP32_DevKitc
  • Kit version v4
  • Module or chip used: ESP32-WROOM-32D
  • IDF version (run git describe --tags to find it):
    v4.4-dev-3235-g3e370c4296
  • Build System: idf.py
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it):
    xtensa-esp32-elf-gcc (crosstool-NG esp-2021r1) 8.4.0
    Copyright (C) 2018 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • Operating System: [Linux]
  • Using an IDE?: [No]
  • Power Supply: [USB]

Problem Description

//Detailed problem description goes here.

build and flash example : esp-idf/examples/peripherals/i2s/i2s_adc_dac, and use a speaker connect GPIO25/GPIO26 and GND,

change code
#define RECORD_IN_FLASH_EN (0)
#define REPLAY_FROM_FLASH_EN (0)

Actual Behavior

speaker no voice out

Steps to reproduce

  1. connect speaker to GPIO25/GPIO26 and GND
  2. build and flash

Debug Logs

I (29) boot: ESP-IDF v4.4-dev-3235-g3e370c4296-dirty 2nd stage bootloader
I (29) boot: compile time 19:00:02
I (30) boot: chip revision: 1
I (34) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (41) boot.esp32: SPI Speed : 40MHz
I (45) boot.esp32: SPI Mode : DIO
I (50) boot.esp32: SPI Flash Size : 4MB
I (54) boot: Enabling RNG early entropy source...
I (60) boot: Partition Table:
I (63) boot: ## Label Usage Type ST Offset Length
I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (78) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (86) boot: 2 factory factory app 00 00 00010000 00100000
I (93) boot: 3 storage Unknown data 01 81 00110000 00200000
I (101) boot: End of partition table
I (105) boot_comm: chip revision: 1, min. application chip revision: 0
I (112) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1c67ch (116348) map
I (163) esp_image: segment 1: paddr=0002c6a4 vaddr=3ffb0000 size=02374h ( 9076) load
I (167) esp_image: segment 2: paddr=0002ea20 vaddr=40080000 size=015f8h ( 5624) load
I (171) esp_image: segment 3: paddr=00030020 vaddr=400d0020 size=18700h (100096) map
I (213) esp_image: segment 4: paddr=00048728 vaddr=400815f8 size=09fd4h ( 40916) load
I (230) esp_image: segment 5: paddr=00052704 vaddr=50000000 size=00010h ( 16) load
I (236) boot: Loaded app from partition at offset 0x10000
I (236) boot: Disabling RNG early entropy source...
I (250) cpu_start: Pro cpu up.
I (251) cpu_start: Starting app cpu, entry point is 0x40081008
0x40081008: call_start_cpu1 at /home/xw/esp/esp-idf/components/esp_system/port/cpu_start.c:155

I (0) cpu_start: App cpu up.
I (265) cpu_start: Pro cpu start user code
I (265) cpu_start: cpu freq: 160000000
I (265) cpu_start: Application information:
I (269) cpu_start: Project name: i2s-adc-dac
I (275) cpu_start: App version: v4.4-dev-3235-g3e370c4296-dirty
I (282) cpu_start: Compile time: Oct 4 2021 18:59:52
I (288) cpu_start: ELF file SHA256: 5a160f3f46c28ca1...
I (294) cpu_start: ESP-IDF: v4.4-dev-3235-g3e370c4296-dirty
I (301) heap_init: Initializing. RAM available for dynamic allocation:
I (308) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (314) heap_init: At 3FFB2C60 len 0002D3A0 (180 KiB): DRAM
I (320) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (327) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (333) heap_init: At 4008B5CC len 00014A34 (82 KiB): IRAM
I (340) spi_flash: detected chip: generic
I (344) spi_flash: flash io: dio
I (349) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
E (364) I2S: mclk is too small
I (368) I2S: DMA Malloc info, datalen=blocksize=4092, dma_buf_count=2
I (375) I2S: DMA Malloc info, datalen=blocksize=4092, dma_buf_count=2
partiton addr: 0x00110000; size: 2097152; label: storage
Skip flash erasing...
Playing file example:
E (391) I2S: mclk is too small
E (519) I2S: mclk is too small
Playing file example:
E (520) I2S: mclk is too small
E (644) I2S: mclk is too small
Playing file example:
E (645) I2S: mclk is too small
E (769) I2S: mclk is too small
Playing file example:
E (770) I2S: mclk is too small
E (894) I2S: mclk is too small
Playing file example:
E (895) I2S: mclk is too small
E (1019) I2S: mclk is too small
Playing file example:
E (1020) I2S: mclk is too small
E (1144) I2S: mclk is too small
Playing file example:
E (1145) I2S: mclk is too small
E (1269) I2S: mclk is too small
Playing file example:
E (1270) I2S: mclk is too small
E (1394) I2S: mclk is too small
Playing file example:
E (1395) I2S: mclk is too small
E (1519) I2S: mclk is too small
done

@espressif-bot espressif-bot added the Status: Opened Issue is new label Oct 13, 2021
@github-actions github-actions bot changed the title use DAC play audio not work use DAC play audio not work (IDFGH-5999) Oct 13, 2021
@xiaowei809362674
Copy link
Author

just branch master have this problem

@cicciocb
Copy link

This issue is still present in the build that is included in the latest arduino-esp32 sdk 2.0.1 so it should be reopen

@PilnyTomas
Copy link

I just tested it and it seems to be working:
ESP32-WROOM-32D; tested on IDF release/v4.4 and master and both produce the pre-recorded audio file. I can hear it from speakers and see it on an oscilloscope.
Can you guys provide more info to reproduce your issue? What amplifier and what speakers are you using? Do you have an oscilloscope to check the signals?
@cicciocb, @xiaowei809362674

@PilnyTomas
Copy link

PilnyTomas commented Nov 9, 2022

@realfast digitalWrite does not use DAC. To test the I2S module in DAC mode use

I2S.begin(ADC_DAC_MODE,  sampleRate, bitsPerSample);
I2S.write(sample);

EDIT: the previous comment was deleted by the author.

@MartinNohr
Copy link

MartinNohr commented Feb 19, 2024

I cannot get the DAC to work on TTGO T-Display ESP32. Could it be related to this issue?
I'm using the i2s driver. It does work in PDM, it is just the DAC mode that doesn't work.
I can supply more information, I don't know what might be needed. Here is the driver values.
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN), // Only TX
.sample_rate = (uint32_t)SAMPLE_RATE,
.bits_per_sample = (i2s_bits_per_sample_t)16,
.channel_format = I2S_CHANNEL_FMT_ONLY_RIGHT,
.communication_format = (i2s_comm_format_t)(/I2S_COMM_FORMAT_I2S |/ I2S_COMM_FORMAT_I2S_MSB),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, //Interrupt level 1
.dma_buf_count = 6,
.dma_buf_len = 60,
.use_apll = false,
};
i2s_pin_config_t pin_config = {
.mck_io_num = I2S_MCK_IO,
.bck_io_num = I2S_BCK_IO,
.ws_io_num = I2S_WS_IO,
.data_out_num = I2S_DO_IO,
.data_in_num = I2S_DI_IO //Not used
};
i2s_driver_install((i2s_port_t)I2S_NUM, &i2s_config, 0, NULL);
i2s_set_pin((i2s_port_t)I2S_NUM, &pin_config);
i2s_set_dac_mode(I2S_DAC_CHANNEL_RIGHT_EN);

i2s_write((i2s_port_t)I2S_NUM, samples_data, ((bits + 8) / 16) * SAMPLE_PER_CYCLE * 4, &i2s_bytes_write, 100);

I connected an oscilloscope the GPIO25, there is no signal.
Turning off the DAC mode results in proper PDM output on pin 25.

@FedericoBusero
Copy link

FedericoBusero commented Feb 19, 2024

In which Arduino ESP32 core / IDF version are you working? Are you working in Arduino IDE or PlatformIO?

@MartinNohr
Copy link

I'm using Microsoft Visual Studio with the Arduino Visual Micro extension. I am not sure how to check which IDF version I'm using.
I've actually given up on using it and am adding a sound chip to my PCB board. I'm also starting to use the ESP32-S3 which doesn't support the DAC output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

6 participants