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

Built-In DAC does not work #1

Closed
MrBuddyCasino opened this Issue Jan 22, 2017 · 9 comments

Comments

Projects
None yet
4 participants
@MrBuddyCasino
Owner

MrBuddyCasino commented Jan 22, 2017

Running without the I2S codec can be activated by uncommenting "#define USE_DAC", but this does not currently work.

If anyone has experience using I2S_MODE_DAC_BUILT_IN, please have a look!

@negativekelvin

This comment has been minimized.

Show comment
Hide comment
@MrBuddyCasino

This comment has been minimized.

Show comment
Hide comment
@MrBuddyCasino

MrBuddyCasino Jan 23, 2017

Owner

Good catch! Will try that out.

Owner

MrBuddyCasino commented Jan 23, 2017

Good catch! Will try that out.

@MrBuddyCasino

This comment has been minimized.

Show comment
Hide comment
@MrBuddyCasino

MrBuddyCasino Jan 23, 2017

Owner

Makes a sound now, but nothing you'd want to listen to.

Owner

MrBuddyCasino commented Jan 23, 2017

Makes a sound now, but nothing you'd want to listen to.

@negativekelvin

This comment has been minimized.

Show comment
Hide comment
@negativekelvin

negativekelvin Jan 24, 2017

Hmm have you tried to use only I2S_MODE_DAC_BUILT_IN flag

negativekelvin commented Jan 24, 2017

Hmm have you tried to use only I2S_MODE_DAC_BUILT_IN flag

@MrBuddyCasino

This comment has been minimized.

Show comment
Hide comment
@MrBuddyCasino

MrBuddyCasino Jan 24, 2017

Owner

Yes, look at he init_i2s_dac() function in app_main.c. Its doing exactly what the sample code in i2s.h says we should do:

` * ----------------EXAMPLE USING I2S WITH DAC ---------------------

  • @code{c}
  • #include "freertos/queue.h"
  • #define I2S_INTR_NUM 17 //choose one interrupt number from soc.h
  • int i2s_num = 0; //i2s port number
  • i2s_config_t i2s_config = {
  • .mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
  • .sample_rate = 44100,
  • .bits_per_sample = 8, // Only 8-bit DAC support
  • .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //
  • .communication_format = I2S_COMM_FORMAT_I2S_MSB,
  • .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
  • .dma_buf_count = 8,
  • .dma_buf_len = 64
  • };
  • i2s_driver_install(i2s_num, &i2s_config, 0, NULL); //install and start i2s driver
  • i2s_set_pin(i2s_num, NULL); //for internal DAC
  • i2s_set_sample_rates(i2s_num, 22050); //set sample rates
  • i2s_driver_uninstall(i2s_num); //stop & destroy i2s driver
    *@Endcode`
Owner

MrBuddyCasino commented Jan 24, 2017

Yes, look at he init_i2s_dac() function in app_main.c. Its doing exactly what the sample code in i2s.h says we should do:

` * ----------------EXAMPLE USING I2S WITH DAC ---------------------

  • @code{c}
  • #include "freertos/queue.h"
  • #define I2S_INTR_NUM 17 //choose one interrupt number from soc.h
  • int i2s_num = 0; //i2s port number
  • i2s_config_t i2s_config = {
  • .mode = I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN,
  • .sample_rate = 44100,
  • .bits_per_sample = 8, // Only 8-bit DAC support
  • .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, //
  • .communication_format = I2S_COMM_FORMAT_I2S_MSB,
  • .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
  • .dma_buf_count = 8,
  • .dma_buf_len = 64
  • };
  • i2s_driver_install(i2s_num, &i2s_config, 0, NULL); //install and start i2s driver
  • i2s_set_pin(i2s_num, NULL); //for internal DAC
  • i2s_set_sample_rates(i2s_num, 22050); //set sample rates
  • i2s_driver_uninstall(i2s_num); //stop & destroy i2s driver
    *@Endcode`
@Spritetm

This comment has been minimized.

Show comment
Hide comment
@Spritetm

Spritetm Jan 29, 2017

Fyi, it seems the I2S driver has a bug in DAC mode: the sample rate it sets is actually 8 times the sample rate you tell it to use. I have a bug fix in the internal merge queue, it will probably be merged after the holidays.

Spritetm commented Jan 29, 2017

Fyi, it seems the I2S driver has a bug in DAC mode: the sample rate it sets is actually 8 times the sample rate you tell it to use. I have a bug fix in the internal merge queue, it will probably be merged after the holidays.

@glennhuber

This comment has been minimized.

Show comment
Hide comment
@glennhuber

glennhuber Feb 13, 2017

When will this bug fix be available?

glennhuber commented Feb 13, 2017

When will this bug fix be available?

@MrBuddyCasino

This comment has been minimized.

Show comment
Hide comment
@MrBuddyCasino

MrBuddyCasino Feb 14, 2017

Owner

The SDK fix hasn't landed yet, but in theory you can workaround the issue by modifying set_dac_sample_rate(int rate) and init_i2s_dac() to divide the sample rate by 8. Haven't tested that, though.

Owner

MrBuddyCasino commented Feb 14, 2017

The SDK fix hasn't landed yet, but in theory you can workaround the issue by modifying set_dac_sample_rate(int rate) and init_i2s_dac() to divide the sample rate by 8. Haven't tested that, though.

@MrBuddyCasino

This comment has been minimized.

Show comment
Hide comment
@MrBuddyCasino

MrBuddyCasino Apr 13, 2017

Owner

Supersat's changes indeed fix this issue. I2S codec no longer strictly required. :-)

Owner

MrBuddyCasino commented Apr 13, 2017

Supersat's changes indeed fix this issue. I2S codec no longer strictly required. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment