Skip to content

I2sMode.AdcBuiltIn does not work on ESP32 #1222

Open
@MarP13

Description

@MarP13

Target name(s)

ESP32

Firmware version

1.8.0.964

Was working before? On which version?

No response

Device capabilities

No response

Description

When ADC mode is used, I2S library gets stuck on reading, most likely because this mode requires additional configuration methods (i2s_set_adc_mode, i2s_adc_enable, i2s_adc_enable) to be called prior reading.
See example here.

Repro code:

using System;
using System.Device.I2s;
using System.Diagnostics;
using System.Threading;
using nanoFramework.Hardware.Esp32;

namespace NanoFrameworkTest
{
    public class Program
    {
        public static void Main()
        {
            Configuration.SetPinFunction(34, DeviceFunction.I2S1_MDATA_IN);

            I2sDevice i2s = new(new I2sConnectionSettings(1)
            {
                BitsPerSample = I2sBitsPerSample.Bit16,
                ChannelFormat = I2sChannelFormat.AllRight,
                Mode = I2sMode.Master | I2sMode.Rx | I2sMode.AdcBuiltIn,
                CommunicationFormat = I2sCommunicationFormat.I2S,
                SampleRate = 200_000
            });

            SpanByte buff = new byte[1024];
            var data = i2s.Read(buff).ToArray();

            Thread.Sleep(Timeout.Infinite);
        }
    }
}

How to reproduce

No response

Expected behaviour

Data should be read at configured sampling rate and resolution.

Screenshots

No response

Aditional information

As per documentation, this is supported only on ESP32 and I2S0 and not on target targets like ESP32_S2, etc:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2s.html#i2s-communication-mode

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions