Search code examples
esp32arduino-idearduino-c++arduino-esp32

getting 'I2S_MODE_DAC_BUILT_IN' was not declared in this scope error when compiling for ESP32S3


i am trying to make an AM transmitter keeping this github repo as reference

void setup() 
{
  Serial.begin(115200);
  setCpuFrequencyMhz(240);                              //highest cpu frequency
  i2s_driver_install(i2s_num, &i2s_config, 0, NULL);    //start i2s driver
  i2s_set_pin(i2s_num, NULL);                           //use internal DAC
  i2s_set_sample_rates(i2s_num, 1000000);               //dummy sample rate, since the function fails at high values

  //this is the hack that enables the highest sampling rate possible ~13MHz
  SET_PERI_REG_BITS(I2S_CLKM_CONF_REG(0), I2S_CLKM_DIV_A_V, 1, I2S_CLKM_DIV_A_S);
  SET_PERI_REG_BITS(I2S_CLKM_CONF_REG(0), I2S_CLKM_DIV_B_V, 1, I2S_CLKM_DIV_B_S);
  SET_PERI_REG_BITS(I2S_CLKM_CONF_REG(0), I2S_CLKM_DIV_NUM_V, 2, I2S_CLKM_DIV_NUM_S); 
  SET_PERI_REG_BITS(I2S_SAMPLE_RATE_CONF_REG(0), I2S_TX_BCK_DIV_NUM_V, 2, I2S_TX_BCK_DIV_NUM_S); 
}

Got compiling error for ESP32-S3 but it did pass compiling for ESP32. I am using Arduino-IDE.


Solution

  • I2S_MODE_DAC_BUILT_IN is not defined for the ESP32-S3 because the ESP32-S3 does not have a DAC. The original ESP32 does. You can verify this by reading the ESP32-S3 datasheet - while data sheets don't call out what hardware devices don't have you'll see that there's no mention of a DAC.

    You'll need to use a different CPU that does have a DAC or rework how you're doing your I2S output.