GPIO conflicts with I2S interrupt
Posted: Thu Apr 13, 2017 8:19 pm
I have some code where I first setup a simple GPIO interrupt handler to react to GPIO_NUM_0.
Some time later I start the I2S driver via i2s_driver_install(). This results in a LoadProhibited exception, and I can't figure out why. When I remove the GPIO code the issue disappears. Heres the code for the GPIO and the I2S config:
Some time later I start the I2S driver via i2s_driver_install(). This results in a LoadProhibited exception, and I can't figure out why. When I remove the GPIO code the issue disappears. Heres the code for the GPIO and the I2S config:
Code: Select all
void controls_init()
{
gpio_config_t io_conf;
//interrupt of rising edge
io_conf.intr_type = GPIO_PIN_INTR_POSEDGE;
//bit mask of the pins, use GPIO0 here ("Boot" button)
io_conf.pin_bit_mask = (1 << GPIO_NUM_0);
//set as input mode
io_conf.mode = GPIO_MODE_INPUT;
//disable pull-down mode
io_conf.pull_down_en = 0;
//enable pull-up mode
io_conf.pull_up_en = 1;
gpio_config(&io_conf);
//create a queue to handle gpio event from isr
gpio_evt_queue = xQueueCreate(2, sizeof(uint32_t));
//start gpio task
xTaskCreatePinnedToCore(gpio_handler_task, "gpio_handler_task", 2048, NULL, 10, gpio_task, 0);
//install gpio isr service
gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT);
// remove existing handler that may be present
gpio_isr_handler_remove(GPIO_NUM_0);
//hook isr handler for specific gpio pin
gpio_isr_handler_add(GPIO_NUM_0, gpio_isr_handler, (void*) GPIO_NUM_0);
}
Code: Select all
static void init_i2s(renderer_config_t *config)
{
i2s_config_t i2s_config = {
.mode = I2S_MODE_MASTER | I2S_MODE_TX, // Only TX
.sample_rate = config->sample_rate,
.bits_per_sample = config->bit_depth,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // 2-channels
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.dma_buf_count = 14, // number of buffers, 128 max.
.dma_buf_len = 32 * 2, // size of each buffer
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1 // Interrupt level 1
};
i2s_pin_config_t pin_config = {
.bck_io_num = 26,
.ws_io_num = 25,
.data_out_num = 22,
.data_in_num = I2S_PIN_NO_CHANGE // Not used
};
i2s_driver_install(config->i2s_num, &i2s_config, 0, NULL);
i2s_set_pin(config->i2s_num, &pin_config);
}
Code: Select all
Guru Meditation Error of type LoadProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x400811de PS : 0x00060733 A0 : 0x8010ea35 A1 : 0x3ffec030
A2 : 0x3ffb4b74 A3 : 0x00060720 A4 : 0x40082db4 A5 : 0x3ffd8594
A6 : 0x3ffd85b0 A7 : 0x3ffd7d28 A8 : 0x000e0b00 A9 : 0x3ffec010
A10 : 0x3ffb1360 A11 : 0x00060723 A12 : 0x00000000 A13 : 0x00000000
A14 : 0x40082db4 A15 : 0x3ffd8594 SAR : 0x00000008 EXCCAUSE: 0x0000001c
EXCVADDR: 0x000e0b00 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffb
Backtrace: 0x400811de:0x3ffec030 0x4010ea35:0x3ffec050 0x4010ef9f:0x3ffec070 0x4010d078:0x3ffec0a0 0x4010d221:0x3ffec0f0
0x4010d020:0x3ffec110 0x4010cce4:0x3ffec130 0x40111c50:0x3ffec150 0x4010cc41:0x3ffec180 0x401168dc:0x3ffec1a0 0x4011b3f2:0x3ffec200 0x4011b44c:0x3ffec420
0x400811de: esp_intr_disable at /git/esp-idf/components/esp32/./intr_alloc.c:621
0x40082db4: i2s_intr_handler_default at /git/esp-idf/components/driver/./i2s.c:751
0x40082db4: i2s_intr_handler_default at /git/esp-idf/components/driver/./i2s.c:751
0x400811de: esp_intr_disable at /git/esp-idf/components/esp32/./intr_alloc.c:621
0x4010ea35: i2s_stop at /git/esp-idf/components/driver/./i2s.c:751
0x4010ef9f: i2s_driver_install at /git/esp-idf/components/driver/./i2s.c:751