ok-home wrote: ↑Thu Apr 11, 2024 1:54 am
Hi
If your queue is empty
Code: Select all
xQueueueReceive(queue, &message, 0)
will return control immediately without delay, you will get a loop without waiting, put
Code: Select all
xQueueueReceive(queue, &message, portMAX_DELAY)
Thanks for your reply! Now gpio_task won't trigger TWDT anymore.
But another problem came out. I have another task named oled_task, which edits the LVGL label to the global variable I mentioned before, running with vTaskDelay(100 / portTICK_PERIOD). It runs normally at first, but after a while it will trigger TWDT, and the screen just display weird things (two question marks "??").
I also found the refresh rate is extremely low (only 2Hz?), while the task is running at 10Hz. (I tried to make a number count in this task, count + 1 & edit the LVGL label to show the count on screen, with vTaskDelay(100 / portTICK_PERIOD), but the number on screen just +5 then +5 then +5 then +5 ...) I'm using a 128*64px monochrome OLED screen driven by SSD1306 bought online, and all components are connected by breadboard and crappy jump wire.
It's annoying to reset the board like every 2 minutes, but I have no idea about any reason of this problem. Could you please explain to me why the task triggered TWDT?
Here's the code:
Code: Select all
static lv_disp_t *disp;
static lv_obj_t *scr;
static lv_obj_t *label;
void oled_task(void *pvParameter) {
uint32_t *variable = (uint32_t*)pvParameter;
for(;;) {
lv_label_set_text_fmt(label, "%d", *variable);
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
esp_err_t oled_init(uint32_t *var) { // will be called in app_main
... // Initalize I2C SSD1306 driver and LVGL
disp = lvgl_port_add_disp(&disp_cfg);
lv_disp_set_rotation(disp, LV_DISP_ROT_180);
scr = lv_disp_get_scr_act(disp);
label = lv_label_create(scr);
lv_label_set_text(label, "Initializing...");
lv_obj_set_align(label, LV_ALIGN_TOP_LEFT);
xTaskCreate(oled_task, "oled_task", 2048, var, 2, NULL);
return ESP_OK;
}
and the backtrace:
Code: Select all
E (128236) task_wdt: Task watchdog got triggered. The following tasks/users did not reset the watchdog in time:
E (128236) task_wdt: - IDLE0 (CPU 0)
E (128236) task_wdt: Tasks currently running:
E (128236) task_wdt: CPU 0: oled_task
E (128236) task_wdt: CPU 1: IDLE1
E (128236) task_wdt: Print CPU 0 (current core) backtrace
Backtrace: 0x42042883:0x3FC9AD70 0x42042CA0:0x3FC9AD90 0x403776A5:0x3FC9ADC0 0x4201F714:0x3FCC5DA0 0x4201E8A1:0x3FCC5DC0 0x42020A81:0x3FCC5DE0 0x4200A175:0x3FCC5E30 0x4037D231:0x3FCC5E50
0x42042883: task_wdt_timeout_handling at C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_system/task_wdt/task_wdt.c:441
0x42042ca0: task_wdt_isr at C:/Espressif/frameworks/esp-idf-v5.2.1/components/esp_system/task_wdt/task_wdt.c:515
0x403776a5: _xt_lowint1 at C:/Espressif/frameworks/esp-idf-v5.2.1/components/xtensa/xtensa_vectors.S:1240
0x4201f714: lv_tlsf_free at C:/Users/littl/Workspace/ESP/measurer/components/lvgl__lvgl/src/misc/lv_tlsf.c:1167
0x4201e8a1: lv_mem_free at C:/Users/littl/Workspace/ESP/measurer/components/lvgl__lvgl/src/misc/lv_mem.c:179
0x42020a81: lv_label_set_text_fmt at C:/Users/littl/Workspace/ESP/measurer/components/lvgl__lvgl/src/widgets/lv_label.c:162
0x4200a175: oled_task at C:/Users/littl/Workspace/ESP/measurer/main/oled.c:21
0x4037d231: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.2.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134