- I (398) GP_HW: LCD Task started
- I (2148) GP_HW: queue receive
- Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
- Core 0 register dump:
- PC : 0x4037b2e8 PS : 0x00060d34 A0 : 0x8037adf6 A1 : 0x3fc9d820
- 0x4037b2e8: spinlock_acquire at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_hw_support/include/spinlock.h:131
- (inlined by) xPortEnterCriticalTimeout at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:473
- A2 : 0x3fc9dc20 A3 : 0xffffffff A4 : 0x147108eb A5 : 0x00060d23
- A6 : 0xb33fffff A7 : 0x0000cdcd A8 : 0x8037b2e8 A9 : 0x3fc9d800
- A10 : 0x00000000 A11 : 0x53cb9a98 A12 : 0x5f746567 A13 : 0x0000000c
- A14 : 0x00060023 A15 : 0x00000003 SAR : 0x00000004 EXCCAUSE: 0x00000005
- EXCVADDR: 0x00000000 LBEG : 0x400556d5 LEND : 0x400556e5 LCOUNT : 0xfffffffe
- 0x400556d5: strlen in ROM
- 0x400556e5: strlen in ROM
- Backtrace: 0x4037b2e5:0x3fc9d820 0x4037adf3:0x3fc9d850 0x42009001:0x3fc9d890 0x4037b08d:0x3fc9d910
- 0x4037b2e5: spinlock_acquire at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_hw_support/include/spinlock.h:130
- (inlined by) xPortEnterCriticalTimeout at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:473
- 0x4037adf3: vPortEnterCritical at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h:567
- (inlined by) xQueueReceive at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/queue.c:1549
- 0x42009001: lcd_task at C:/Users/damia/Desktop/SSW/SW/ssw_esp/espidf/ssw2opta/main/main.c:76
- 0x4037b08d: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
- Core 1 register dump:
- PC : 0x40378cf2 PS : 0x00060934 A0 : 0x82002c39 A1 : 0x3fc9b550
- 0x40378cf2: esp_cpu_wait_for_intr at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_hw_support/cpu.c:64
- A2 : 0x00000000 A3 : 0x00000000 A4 : 0x3fc995a0 A5 : 0x3fc99580
- A6 : 0x40375d98 A7 : 0x00000001 A8 : 0x8200ba2a A9 : 0x3fc9b510
- 0x40375d98: ipc_task at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_system/esp_ipc.c:53
- A10 : 0x00000000 A11 : 0x00000000 A12 : 0x3fc99580 A13 : 0x3fc99560
- A14 : 0x00000001 A15 : 0x3fc9b724 SAR : 0x00000000 EXCCAUSE: 0x00000005
- EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
- Backtrace: 0x40378cef:0x3fc9b550 0x42002c36:0x3fc9b570 0x4037c025:0x3fc9b590 0x4037b08d:0x3fc9b5b0
- 0x40378cef: xt_utils_wait_for_intr at C:/Espressif/frameworks/esp-idf-v5.3/components/xtensa/include/xt_utils.h:82
- (inlined by) esp_cpu_wait_for_intr at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_hw_support/cpu.c:55
- 0x42002c36: esp_vApplicationIdleHook at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_system/freertos_hooks.c:58
- 0x4037c025: prvIdleTask at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/tasks.c:4344 (discriminator 1)
- 0x4037b08d: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
I've been using ESP-IDF for a while but facing problems that I cannot solve myself anymore.
I'm woking in ESP IDF V5.3.1 with a custom Board based on ESP32-S3-1 N8.
Connected to my board I have an LCD Screen controlled via I2C over a PCF8574 IO expander. I wrote the lib for that myself, using the latest I2C Master driver.
My issue is, that my code (or the driver itself?) seems to be messing with RTOS queues, when I transmit I2C data and try to read from a queue, the ESP crashes (see error log below).
I have also attached my code as well as my I2C Master config. Interestingly, when I rem,ove all I2C related commands, the queue works falwlessly, on the other hand the Screen (and thus all I2C commands) work flawlessly when no queue is being used.
Unfortunately, I need both.
I have ensured,m that enough stack and heap are available. I have also tried a dynamically allocated queue. I have also tried making the queue more lightweight by passing pointers in the queue.
Could the latest I2C driver at fault? What can I do? Sadly, I'm at the end of my knowledge.
Thanks for reading.
- #define QUEUE_LENGTH 3
- #define ITEM_SIZE sizeof(lcd_data)
- StaticQueue_t xQueueBuffer;
- uint8_t ucQueueStorage[QUEUE_LENGTH * ITEM_SIZE];
- QueueHandle_t lcd_queue;
- rtc_pcf8563 lcd;
- void lcd_task(void *args);
- void app_main(void)
- {
- gpio_init();
- i2c_init();
- esp_err_t ret;
- ret = nvs_flash_init();
- if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
- {
- ESP_ERROR_CHECK(nvs_flash_erase());
- ret = nvs_flash_init();
- }
- ESP_ERROR_CHECK(ret);
- // init LCD queue (will be used to send data to LCD print task)
- lcd_queue = xQueueCreateStatic(QUEUE_LENGTH, // The number of items the queue can hold.
- ITEM_SIZE, // The size of each item in the queue
- &(ucQueueStorage[0]), // The buffer that will hold the items in the queue.
- &xQueueBuffer); // The buffer that will hold the queue structure.
- if (lcd_queue == NULL)
- ESP_LOGE(TAG, "queuecreate failed");
- TaskHandle_t lcd_tsk_hdl;
- xTaskCreate(lcd_task, "LCD_TSK", 5000, NULL, tskIDLE_PRIORITY, &lcd_tsk_hdl);
- lcd_data info = {
- .x_pos = 0,
- .y_pos = 0,
- .msg = "testmsg",
- };
- xQueueSend(lcd_queue, &info, portMAX_DELAY);
- vTaskDelay(portMAX_DELAY);
- }
- void lcd_task(void *args)
- {
- ESP_LOGI(TAG, "LCD Task started");
- lcd_init(&lcd, LCD_ADDR, bus_handle);
- while (lcd_begin(&lcd, LCD_COLS, LCD_ROWS) != ESP_OK)
- {
- ESP_LOGE(TAG, "LCD init fail");
- vTaskDelay(5000 / portTICK_PERIOD_MS);
- }
- // Turn on the backlight
- lcd_set_backlight(&lcd, true);
- // Print a message
- vTaskDelay(1);
- lcd_set_cursor(&lcd, 0, 0);
- vTaskDelay(1);
- lcd_print(&lcd, LCD_START_MSG);
- // vTaskDelay(2000 / portTICK_PERIOD_MS);
- lcd_data lcd_buf;
- while (1)
- {
- ESP_LOGI(TAG, "queue receive");
- if (xQueueReceive(lcd_queue, &lcd_buf, portMAX_DELAY))
- // ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
- ESP_LOGI(TAG, "queue event");
- ESP_LOGI(TAG, "%s", lcd_buf.msg);
- vTaskDelay(1);
- lcd_clear(&lcd);
- vTaskDelay(1);
- lcd_set_cursor(&lcd, lcd_buf.x_pos, lcd_buf.y_pos);
- vTaskDelay(1);
- lcd_print(&lcd, lcd_buf.msg);
- }
- }
- i2c_master_bus_config_t i2c_mst_config = {
- .i2c_port = I2C_NUM_0,
- .sda_io_num = GPIO_NUM_6,
- .scl_io_num = GPIO_NUM_5,
- .clk_source = I2C_CLK_SRC_DEFAULT,
- .glitch_ignore_cnt = 7,
- .intr_priority = 0,
- .trans_queue_depth = 0,
- .flags.enable_internal_pullup = true, // enable internal pullups
- };
- i2c_master_bus_handle_t bus_handle;
- void lcd_init(i2c_lcd_pcf8574_handle_t *lcd, uint8_t i2c_addr, i2c_master_bus_handle_t bus_hdl)
- {
- lcd->i2c_addr = i2c_addr;
- lcd->backlight = true; // sometimes not supported (PCF5874 P3 is NC on some modules)
- lcd->entrymode = ENTRYMODE_LEFT2RIGHT; // Init the LCD with an internal reset
- lcd->displaycontrol = DISPLAY_ON & ~CURSOR_ON & ~CURSOR_BLINK;
- lcd->bus_hdl = bus_hdl;
- }