ESP32-Digital-RGB-LED-Drivers icon indicating copy to clipboard operation
ESP32-Digital-RGB-LED-Drivers copied to clipboard

RMT conflict with esp32-owb

Open lukecyca opened this issue 6 years ago • 11 comments

If I use this library in the same project as esp32-owb by @DavidAntliff, I get the following reboot loop as soon as a hit digitalLeds_initStrands.

Guru Meditation Error: Core  1 panic'ed (LoadProhibited)
. Exception was unhandled.
Core 1 register dump:
PC      : 0x40084c86  PS      : 0x00060033  A0      : 0x80081ab4  A1      : 0x3ffb0bc0
0x40084c86: rmt_driver_isr_default at /Users/luke/Code/esp32/esp-idf/components/driver/./rmt.c:769 (discriminator 1)

A2      : 0x0000001a  A3      : 0x04000000  A4      : 0x00000000  A5      : 0x00000002
A6      : 0x04000000  A7      : 0x3ffba450  A8      : 0x3ff56000  A9      : 0x00000001
A10     : 0x00000001  A11     : 0x00000000  A12     : 0x80085fb9  A13     : 0x00000001
A14     : 0x00060021  A15     : 0x00060f23  SAR     : 0x00000006  EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000010  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff
Core 1 was running in ISR context:
EPC1    : 0x40084c86  EPC2    : 0x00000000  EPC3    : 0x00000000  EPC4    : 0x400d2120
0x40084c86: rmt_driver_isr_default at /Users/luke/Code/esp32/esp-idf/components/driver/./rmt.c:769 (discriminator 1)

0x400d2120: esp_vApplicationIdleHook at /Users/luke/Code/esp32/esp-idf/components/esp32/./freertos_hooks.c:85


Backtrace: 0x40084c86:0x3ffb0bc0 0x40081ab1:0x3ffb0bf0 0x400824ad:0x3ffb0c10 0x400e4c60:0x00000000
0x40084c86: rmt_driver_isr_default at /Users/luke/Code/esp32/esp-idf/components/driver/./rmt.c:769 (discriminator 1)

0x40081ab1: shared_intr_isr at /Users/luke/Code/esp32/esp-idf/components/esp32/./intr_alloc.c:773

0x400824ad: _xt_lowint1 at /Users/luke/Code/esp32/esp-idf/components/freertos/./xtensa_vectors.S:1105

0x400e4c60: i2c_master_cmd_begin at /Users/luke/Code/esp32/esp-idf/components/driver/./i2c.c:1187


Rebooting...

The relevant sections of code are:

#define WS2812_PIN (27)
#define WS2812_PIN_MASK (1ULL<<WS2812_PIN)
void ws2812_task(void *pvParameter)
{

    gpio_config_t io_conf;
    io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
    io_conf.mode = GPIO_MODE_OUTPUT;
    io_conf.pin_bit_mask = GPIO_SEL_27;
    io_conf.pull_down_en = 0;
    io_conf.pull_up_en = 0;
    gpio_config(&io_conf);

    strand_t strands[] = {
        {.rmtChannel = RMT_CHANNEL_2, .gpioNum = WS2812_PIN, .ledType = LED_WS2812B_V3, .brightLimit = 255, .numPixels =  3,
        .pixels = NULL, ._stateVars = NULL}
    };

    if (digitalLeds_initStrands(strands, 1)) {
        ESP_LOGE(CM02_TAG, "Failed to initialize WS2812");
        vTaskDelete(NULL);
        return;
    }

    uint8_t x = 0;
    while (true) {
        strands[0].pixels[0] = pixelFromRGB(255-x, x, 0);
        strands[0].pixels[1] = pixelFromRGB(0, 255-x, x);
        strands[0].pixels[2] = pixelFromRGB(x, 0, 255-x);
        x++;
        digitalLeds_updatePixels(&strands[0]);
        vTaskDelay(30/portTICK_PERIOD_MS);
    }
}

#define DS18B20_PROBE_PIN 16
static float temp_probe_value = -1;
static void temp_probe_task(void *pvParameter) {
    DS18B20_ERROR err;

    OneWireBus * owb;
    owb_rmt_driver_info rmt_driver_info;
    owb = owb_rmt_initialize(&rmt_driver_info, DS18B20_PROBE_PIN, RMT_CHANNEL_1, RMT_CHANNEL_0);
    owb_use_crc(owb, true);

    DS18B20_Info * ds18b20_probe;
    ds18b20_probe = ds18b20_malloc();
    ds18b20_init_solo(ds18b20_probe, owb);
    ds18b20_use_crc(ds18b20_probe, true);
    ds18b20_set_resolution(ds18b20_probe, DS18B20_RESOLUTION_12_BIT);

    while (1) {
        ds18b20_convert_all(owb);

        // Wait 1s, and then wait longer if the conversion isn't done
        vTaskDelay(1000/portTICK_PERIOD_MS);
        ds18b20_wait_for_conversion(ds18b20_probe); // block

        err = ds18b20_read_temp(ds18b20_probe, &temp_probe_value);
        printf("  %.1f    %d errors\n", temp_probe_value, err);
        // FIXME: check errors
    }
}

I have taken care to specify different RMT channels, and I think the pins I'm using for each peripheral or valid. If I disable one, the other works perfectly.

lukecyca avatar Mar 26 '18 23:03 lukecyca