Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

ESP32 I2S breaks I2C, need I2S.start/stop #28

@jetpax

Description

@jetpax

There's a long standing unresolved issue with I2C failing when running at the same time as I2S on the ESP32.

eg https://esp32.com/viewtopic.php?t=5563 and several others over the years

Admittedly this is an esp-idf issue, but I've found it can be worked around by turning off the I2S clocks while accessing I2C, which may not sound like a great general workaround, but works in my application.

These functions are available in esp-idf, but not exposed in the MP I2S driver.

Doing so is just a matter of adding a couple of stanzas, and modifying the machine_i2s_locals_dict_table eg

STATIC mp_obj_t machine_i2s_start(mp_obj_t self_in) {
    machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
    i2s_start(self->port);
    return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_i2s_start_obj, machine_i2s_start);

STATIC mp_obj_t machine_i2s_stop(mp_obj_t self_in) {
    machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
    i2s_stop(self->port);
    return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_i2s_stop_obj, machine_i2s_stop);

Would be great if this could be added to main library (would add this to MP issues, but Damien always seems so busy...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions