I2C causes panic - Interrupt WDT

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

I2C causes panic - Interrupt WDT

Postby Vader_Mester » Mon May 17, 2021 2:21 pm

Hi All,

A very strange error keeps occuring.

Code: Select all

Guru Meditation Error: Core  0 panic'ed (Interrupt wdt timeout on CPU0). 

Core  0 register dump:
PC      : 0x4008a120  PS      : 0x00060834  A0      : 0x800894ca  A1      : 0x3ffb6ab0
0x4008a120: vListInsert at C:/Users/Bujtor.Bence/esp/esp-idf/components/freertos/list.c:151 (discriminator 1)

A2      : 0x3ffb7f90  A3      : 0x3ffb6e80  A4      : 0x00000000  A5      : 0x00060823
A6      : 0x000000fe  A7      : 0x00000001  A8      : 0x3ffb6e80  A9      : 0x3ffb6e80
A10     : 0x00000018  A11     : 0x00000018  A12     : 0x00000000  A13     : 0x00060823
A14     : 0x000000fe  A15     : 0x00000001  SAR     : 0x00000014  EXCCAUSE: 0x00000005  
EXCVADDR: 0x00000000  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff
The error is traced back to this line inside i2c.c - inside i2c_master_cmd_begin()
https://github.com/espressif/esp-idf/bl ... 2c.c#L1230
Additional trace data:
https://github.com/espressif/esp-idf/bl ... ue.c#L1396
https://github.com/espressif/esp-idf/bl ... ks.c#L3403
https://github.com/espressif/esp-idf/bl ... ist.c#L151


Write function calling i2c_master_cmd_begin():

Code: Select all

esp_err_t I2Cdev_writeBytes(uint8_t devAdd, uint8_t regAddr, uint32_t length, uint8_t *data){
	i2c_cmd_handle_t cmd = {0};

	cmd = i2c_cmd_link_create();
	I2C_CHECK(i2c_master_start(cmd));
	I2C_CHECK(i2c_master_write_byte(cmd, (devAdd << 1) | I2C_MASTER_WRITE, 1));
	I2C_CHECK(i2c_master_write_byte(cmd, regAddr, 1));
	I2C_CHECK(i2c_master_write(cmd, data, (size_t)(length-1), 0));
	I2C_CHECK(i2c_master_write_byte(cmd, data[length-1], 1));
	I2C_CHECK(i2c_master_stop(cmd));
	I2C_CHECK(i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000/portTICK_PERIOD_MS));
	i2c_cmd_link_delete(cmd);
	return ESP_OK;
}
IDF version: v4.4-dev-960-gcf457d412-dirty

Could you please help me find the issue, or give me hint for where to look? It is strange that this happens. I never had problems with I2C before. Also this write function is called several times before we get to here. Interestingly, my code always fails at the exact same point.

EDIT: I'm not using any interrupt in user code. The code only runs a driver initilization of an I2C device. Interrupts that are there are part of I2C driver and FreeRTOS.

Thanks in advance!
Vader(Ben)

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: I2C causes panic - Interrupt WDT

Postby Vader_Mester » Tue May 18, 2021 8:19 am

Ok, I found the issue.
A small section of code enterd a critical section before reading I2C, and probably this have caused it to fail.

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

Who is online

Users browsing this forum: johboh and 165 guests