ESP32 Feather V2 & Ide Arduino & I2S

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Enrique_Aguado
 
Posts: 3
Joined: Mon Sep 12, 2022 8:46 am

ESP32 Feather V2 & Ide Arduino & I2S

Post by Enrique_Aguado »

Dear Sirs,

I have two sketches to generate sine waves (included bellow).

The first one writes directly to the DAC, the other one uses I2S and the internal converter of the ESP32.
With Arduino IDE and the ESP32 Feather board and the ESP32 board-Manager version 2.0.0
Both sketches work perfectly.

If I update the ESP32 board-Manager to version 2.0.4, I can now work with the Adafruit ESP32 Feather V2.
The Sketch that writes directly to the DAC 2 works perfectly on both the Adafruit ESP32 Feather and the Adafruit ESP32 Feather V2.
But the sketch with I2S, compiles without problems but does NOT work on either the Adafruit ESP32 Feather or Adafruit ESP32 Feather V2. Pin 26 remains at 0v without generating the expected signal.
Evidently the problem is in the Arduino IDE, but there may be a work-around, you could share

On the other hand, I'm sure they have access to the Arduino to escalate the problem.


/*
* Firsy SKETCH Writing directly in the DAC
* Tested on Adafruit ESP32 Feather V2 y Adafruit ESP32 Feather 11-09-2022
*/


#define Num_Samples 112


int i = 0;

// Sin wave
static byte WaveFormTable[Num_Samples] =

{
0x80, 0x83, 0x87, 0x8A, 0x8E, 0x91, 0x95, 0x98, 0x9B, 0x9E, 0xA2, 0xA5, 0xA7, 0xAA, 0xAD, 0xAF,
0xB2, 0xB4, 0xB6, 0xB8, 0xB9, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xBF, 0xBF, 0xC0, 0xBF, 0xBF, 0xBF,
0xBE, 0xBD, 0xBC, 0xBB, 0xB9, 0xB8, 0xB6, 0xB4, 0xB2, 0xAF, 0xAD, 0xAA, 0xA7, 0xA5, 0xA2, 0x9E,
0x9B, 0x98, 0x95, 0x91, 0x8E, 0x8A, 0x87, 0x83, 0x80, 0x7C, 0x78, 0x75, 0x71, 0x6E, 0x6A, 0x67,
0x64, 0x61, 0x5D, 0x5A, 0x58, 0x55, 0x52, 0x50, 0x4D, 0x4B, 0x49, 0x47, 0x46, 0x44, 0x43, 0x42,
0x41, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x49, 0x4B,
0x4D, 0x50, 0x52, 0x55, 0x58, 0x5A, 0x5D, 0x61, 0x64, 0x67, 0x6A, 0x6E, 0x71, 0x75, 0x78, 0x7C
};


void setup()
{

}



void loop()
{

byte wave_type = 0; // Sine

dacWrite(26, WaveFormTable); //25 ou 26
i++;

if (i >= Num_Samples)
i = 0;

}

==============================================================================

/*
* Second SKETCH
* This is an example to write DAC at high frequency using the I2S peripheral
*/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>


#include "soc/rtc_io_reg.h"
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_reg.h"
#include "soc/rtc.h"

#include <Arduino.h>

#include <driver/i2s.h>
#include <driver/dac.h> // libreria necesaria para definir DAC_CHANNEL_1 no es necesaria para DMA DAC
#include "freertos/queue.h"




#define I2S_SAMPLE_RATE 426595
#define Num_Samples 256

int i = 0;

static byte WaveFormTable[Num_Samples] =
// Sin wave con 256 samples.

{
0x80, 0x83, 0x86, 0x89, 0x8C, 0x8F, 0x92, 0x95, 0x98, 0x9B, 0x9E, 0xA1, 0xA4, 0xA7, 0xAA, 0xAD, 0xB0, 0xB3, 0xB6, 0xB9,
0xBB, 0xBE, 0xC1, 0xC3, 0xC6, 0xC9, 0xCB, 0xCE, 0xD0, 0xD2, 0xD5, 0xD7, 0xD9, 0xDB, 0xDE, 0xE0, 0xE2, 0xE4, 0xE6, 0xE7,
0xE9, 0xEB, 0xEC, 0xEE, 0xF0, 0xF1, 0xF2, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFB, 0xFC, 0xFD, 0xFD, 0xFE,
0xFE, 0xFE, 0xFE, 0xFE, 0xFF, 0xFE, 0xFE, 0x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7C
};



void i2sInit()
{
i2s_config_t i2s_config = {
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN),
.sample_rate = I2S_SAMPLE_RATE, // The format of the signal using ADC_BUILT_IN
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT, // is fixed at 12bit, stereo, MSB
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // I2S_CHANNEL_FMT_ONLY_LEFT I2S_CHANNEL_FMT_RIGHT_LEFT ****************************************
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_STAND_I2S | 0x01),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 64,
.use_apll = false,
.tx_desc_auto_clear = false,
.fixed_mclk = 0
};

i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL); //install and start i2s driver
i2s_set_pin(I2S_NUM_0,NULL); // for internal DAC


i2s_set_dac_mode(I2S_DAC_CHANNEL_DISABLE); // disable ambos canales este si funciona
//i2s_set_dac_mode(I2S_DAC_CHANNEL_RIGHT_EN); // DAC_1 RIGHT es el DAC_1
i2s_set_dac_mode(I2S_DAC_CHANNEL_LEFT_EN); // de esta forma tengo solo salida en el DAC_2


}





void setup() {

// Initialize the I2S peripheral
i2sInit();

}



void loop() {

// i2s bytes-written variable
size_t bytesOut;


// output the buffer
while( true )
{
i2s_write( I2S_NUM_0, WaveFormTable, Num_Samples, &bytesOut, portMAX_DELAY );

}

}

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: ESP32 Feather V2 & Ide Arduino & I2S

Post by mikeysklar »

It looks like others have opened issues regarding the ESP32 Arduino Board Manager v2.0.4 and i2s. You can tag your code examples onto one of those or open a fresh issue it seems different in behavior.

https://github.com/espressif/arduino-es ... 3Aopen+i2s

User avatar
Enrique_Aguado
 
Posts: 3
Joined: Mon Sep 12, 2022 8:46 am

Re: ESP32 Feather V2 & Ide Arduino & I2S

Post by Enrique_Aguado »

Hello

I enjoy working with the Adafruit feather ESP32, but I am having a lot of issues when trying to evaluate the Adafruit feather ESP32 V2.
I have reported de issue with Arduino IDE and I2S
Now I have discovered a new bug with the I2C. In this case working with Visual Studio plus PlatformIO and Adafruit feather ESP32 V2
Same program (with the I2C pins adapted) runs perfect with the Adafruit feather ESP32 board.

I have no doubt about HW Adafruit feather ESP32 V2 but the SW tools are not madure from my experience.
Do you know about any activity running to evalate SW tools.
How long will be the Adafruit ESP32 feather still in production?
When is planned to be substitute the Adafruit ESP32 featherby the Adafruit feather ESP32 V2?

Thanks in advance for your comments

User avatar
Enrique_Aguado
 
Posts: 3
Joined: Mon Sep 12, 2022 8:46 am

Re: ESP32 Feather V2 & Ide Arduino & I2S

Post by Enrique_Aguado »

Related the problem I have describe ESP32 FEATHER V2 & IDE ARDUINO & I2S

I have found an open escalation opened on 28 Nov 2021
The esp32 i2s internal DAC output is not working with the release 2.0.1
https://github.com/espressif/arduino-esp32/issues/5938


What's has made me to be high worried!!!

Conclusion:
espressif SW tools needed for ESP32 FEATHER V2 project development are not madure
As aI have found bugs in Arduino and PlatformIO

Any action plan from Adafruit to push solving this situation ?

Thanks in advance for any comment.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”