You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ESP32+ILI9341+LVGL v8.3无法显示图像,触发内核崩溃求助

ESP32 + LVGL v8.3 + ILI9341 触发 Guru Meditation Error (LoadProhibited) 无法显示UI

我正在使用LVGL v8.3库在ESP32开发板的ILI9341显示屏上显示UI,已按要求连接ILI9341与XPT2046触摸屏的对应引脚,并且在platformio.ini中完成了驱动配置,但运行代码时出现以下报错:

D (1272) intr_alloc: Connected src 16 to int 12 (cpu 0)
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

已检查引脚连接和驱动配置,仍无法正常显示图像,以下是完整代码:

#include "lvgl/lvgl.h"
#include "lvgl_esp32_drivers/lvgl_helpers.h"
#include "lvgl/examples/lv_examples.h"
#include "ili9341.h"
#include "xpt2046.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#define LCD_WIDTH 320
#define LCD_HEIGHT 240

static void btn_event_cb(lv_event_t * e)
{
    lv_event_code_t code = lv_event_get_code(e);
    lv_obj_t * btn = lv_event_get_target(e);
    if(code == LV_EVENT_CLICKED) {
        static uint8_t cnt = 0;
        cnt++;

        /*Get the first child of the button which is the label and change its text*/
        lv_obj_t * label = lv_obj_get_child(btn, 0);
        lv_label_set_text_fmt(label, "Button: %d", cnt);
    }
}

void lv_example_get_started_1(void)
{
    lv_obj_t * btn = lv_btn_create(lv_scr_act());     /*Add a button the current screen*/
    lv_obj_set_pos(btn, 10, 10);                            /*Set its position*/
    lv_obj_set_size(btn, 120, 50);                          /*Set its size*/
    lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_ALL, NULL);           /*Assign a callback to the button*/

    lv_obj_t * label = lv_label_create(btn);          /*Add a label to the button*/
    lv_label_set_text(label, "Button");                     /*Set the labels text*/
    lv_obj_center(label);
}

static void display_task(void *arg)
{
  // Initialize the display
  lv_init();
  lv_example_get_started_1();

  // Update the display continuously
  while (1) {
    lv_tick_inc(portTICK_PERIOD_MS);
    lv_task_handler();
    vTaskDelay(portTICK_PERIOD_MS);
  }
}

void configure_drivers()
{
  lvgl_driver_init();
  
  static lv_disp_draw_buf_t draw_buf;
  static lv_color_t buf1[LCD_WIDTH * LCD_HEIGHT / 10];                        /*Declare a buffer for 1/10 screen size*/
  lv_disp_draw_buf_init(&draw_buf, buf1, NULL, LCD_WIDTH * LCD_HEIGHT / 10);  /*Initialize the display buffer.*/

  // Set the display and touch screen drivers in LVGL
  lv_disp_drv_t disp_drv;
  lv_disp_drv_init(&disp_drv);
  disp_drv.flush_cb  = ili9341_flush;
  disp_drv.draw_buf = &draw_buf;        /*Assign the buffer to the display*/
  disp_drv.hor_res = LCD_WIDTH;   /*Set the horizontal resolution of the display*/
  disp_drv.ver_res = LCD_HEIGHT;   /*Set the vertical resolution of the display*/
  lv_disp_drv_register(&disp_drv);
  /*
  lv_indev_drv_t indev_drv;
  lv_indev_drv_init(&indev_drv);
  indev_drv.type = LV_INDEV_TYPE_POINTER;
  indev_drv.read_cb = xpt2046_read;
  lv_indev_drv_register(&indev_drv);
  */
}


extern "C" void app_main()
{
  // Create a task to handle the display
  xTaskCreate(display_task, "display", 8192, NULL, 5, NULL);
}

环境信息

  • PlatformIO
  • ESP-IDF 4.4.2
  • LVGL v8.3

恳请协助排查问题。

内容的提问来源于stack exchange,提问作者Cristóbal Felipe Fica Urzúa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 19:05:19