[已解决]ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
[已解决]ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
问题1)无法驱动RGB屏幕,驱动芯片未知资料上写的ST7701S。一直卡在最后一句,LCD数据线只有PCLK有信号,其他数据线均无反映,所有IO都通过GPIO模式测试过硬件连接至屏幕是正常的。
问题2)SPI信号不正常没有低电平,只有一个瞬态下江针柱,SPI接口用SD卡测试程序测试正常。SPI口原来接的flash口,无法加入设备。
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x2b (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fce3810,len:0x1684
load:0x403c9700,len:0xbe8
load:0x403cc700,len:0x2ea8
entry 0x403c9904
I (29) boot: ESP-IDF v5.0-dirty 2nd stage bootloader
I (30) boot: compile time 21:45:34
I (30) boot: chip revision: v0.1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32s3: Boot SPI Speed : 40MHz
I (44) boot.esp32s3: SPI Mode : DIO
I (48) boot.esp32s3: SPI Flash Size : 16MB
I (53) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (77) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00177000
I (92) boot: End of partition table
I (96) boot_comm: chip revision: 1, min. application chip revision: 0
I (103) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=726fch (468732) map
I (228) esp_image: segment 1: paddr=00082724 vaddr=3fc93600 size=03394h ( 13204) load
I (232) esp_image: segment 2: paddr=00085ac0 vaddr=40374000 size=0a558h ( 42328) load
I (246) esp_image: segment 3: paddr=00090020 vaddr=42000020 size=4f388h (324488) map
I (327) esp_image: segment 4: paddr=000df3b0 vaddr=4037e558 size=0507ch ( 20604) load
I (333) esp_image: segment 5: paddr=000e4434 vaddr=50000000 size=00010h ( 16) load
I (340) boot: Loaded app from partition at offset 0x10000
I (340) boot: Disabling RNG early entropy source...
I (356) octal_psram: vendor id : 0x0d (AP)
I (356) octal_psram: dev id : 0x02 (generation 3)
I (356) octal_psram: density : 0x03 (64 Mbit)
I (361) octal_psram: good-die : 0x01 (Pass)
I (366) octal_psram: Latency : 0x01 (Fixed)
I (371) octal_psram: VCC : 0x01 (3V)
I (377) octal_psram: SRF : 0x01 (Fast Refresh)
I (382) octal_psram: BurstType : 0x01 (Hybrid Wrap)
I (388) octal_psram: BurstLen : 0x01 (32 Byte)
I (394) octal_psram: Readlatency : 0x02 (10 cycles@Fixed)
I (400) octal_psram: DriveStrength: 0x00 (1/1)
I (405) esp_psram: Found 8MB PSRAM device
I (410) esp_psram: Speed: 40MHz
I (414) cpu_start: Pro cpu up.
I (417) cpu_start: Starting app cpu, entry point is 0x40375478
I (0) cpu_start: App cpu up.
I (1155) esp_psram: SPI SRAM memory test OK
D (1155) efuse: In EFUSE_BLK2__DATA4_REG is used 2 bits starting with 0 bit
D (1155) efuse: In EFUSE_BLK2__DATA4_REG is used 8 bits starting with 13 bit
D (1171) clk: RTC_SLOW_CLK calibration value: 3900941
I (1180) cpu_start: Pro cpu start user code
I (1180) cpu_start: cpu freq: 240000000 Hz
I (1180) cpu_start: Application information:
I (1183) cpu_start: Project name: hmi_esp32_blink
I (1189) cpu_start: App version: 1
I (1194) cpu_start: Compile time: Feb 19 2023 21:45:05
I (1200) cpu_start: ELF file SHA256: e3e176e0672d8b9c...
I (1206) cpu_start: ESP-IDF: v5.0-dirty
D (1211) memory_layout: Checking 6 reserved memory ranges:
D (1217) memory_layout: Reserved memory range 0x3c000000 - 0x3e000000
D (1223) memory_layout: Reserved memory range 0x3fc84000 - 0x3fc93600
D (1230) memory_layout: Reserved memory range 0x3fc93600 - 0x3fc97a68
D (1236) memory_layout: Reserved memory range 0x3fceee34 - 0x3fcf0000
D (1243) memory_layout: Reserved memory range 0x40374000 - 0x40383600
D (1249) memory_layout: Reserved memory range 0x600fe000 - 0x600fe010
D (1256) memory_layout: Building list of available memory regions:
D (1262) memory_layout: Available memory region 0x3fc97a68 - 0x3fca0000
D (1269) memory_layout: Available memory region 0x3fca0000 - 0x3fcb0000
D (1275) memory_layout: Available memory region 0x3fcb0000 - 0x3fcc0000
D (1282) memory_layout: Available memory region 0x3fcc0000 - 0x3fcd0000
D (1289) memory_layout: Available memory region 0x3fcd0000 - 0x3fce0000
D (1295) memory_layout: Available memory region 0x3fce0000 - 0x3fce9710
D (1302) memory_layout: Available memory region 0x3fce9710 - 0x3fceee34
D (1309) memory_layout: Available memory region 0x3fcf0000 - 0x3fcf8000
D (1315) memory_layout: Available memory region 0x600fe010 - 0x60100000
I (1322) heap_init: Initializing. RAM available for dynamic allocation:
D (1329) heap_init: New heap initialised at 0x3fc97a68
I (1335) heap_init: At 3FC97A68 len 00051CA8 (327 KiB): D/IRAM
I (1341) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
D (1348) heap_init: New heap initialised at 0x3fcf0000
I (1353) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
D (1359) heap_init: New heap initialised at 0x600fe010
I (1365) heap_init: At 600FE010 len 00001FF0 (7 KiB): RTCRAM
I (1371) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator
D (1379) intr_alloc: Connected src 39 to int 2 (cpu 0)
D (1384) spi_flash: trying chip: issi
D (1388) spi_flash: trying chip: gd
D (1391) spi_flash: trying chip: mxic
D (1395) spi_flash: trying chip: winbond
I (1399) spi_flash: detected chip: winbond
I (1404) spi_flash: flash io: dio
D (1408) cpu_start: calling init function: 0x4203bcc8
D (1413) cpu_start: calling init function: 0x42002934
D (1418) cpu_start: calling init function: 0x42001ebc
D (1423) cpu_start: calling init function: 0x42006770 on core: 0
D (1429) intr_alloc: Connected src 59 to int 3 (cpu 0)
D (1434) cpu_start: calling init function: 0x4203c7c0 on core: 0
I (1440) sleep: Configure to isolate all GPIO pins in sleep state
I (1447) sleep: Enable automatic switching of GPIO sleep configuration
D (1454) cpu_start: calling init function: 0x420026d8 on core: 0
D (1461) intr_alloc: Connected src 79 to int 9 (cpu 0)
I (1465) cpu_start: Starting scheduler on PRO CPU.
D (1471) intr_alloc: Connected src 57 to int 12 (cpu 0)
D (1471) intr_alloc: Connected src 80 to int 2 (cpu 1)
I (1481) cpu_start: Starting scheduler on APP CPU.
D (1481) intr_alloc: Connected src 58 to int 3 (cpu 1)
D (1491) heap_init: New heap initialised at 0x3fce9710
I (1491) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
D (1501) esp_psram: Allocating block of size 32768 bytes
D (1511) intr_alloc: Connected src 43 to int 13 (cpu 0)
D (1511) HMI_ESP32_B_V11: init io_expander: 0
D (1521) aw9523b: mode_reg0: 0xf8
D (1521) aw9523b: mode_reg1: 0xff
D (1521) aw9523b: ctrl_reg: 0x11
I (1531) aw9523b: i2c_address: 0x58, device_id: 0x23
D (1531) HMI_ESP32_B_V11: inited io_expander: 3fcea380
I (1541) app_main: please press power key to start up
I (1541) HMI_ESP32_B_V11: power on
D (2551) ledc: Using clock source 1 (in slow mode), divisor: 0x1f4
D (2551) ledc: In slow speed mode, global clk set: 1
D (2551) ledc: LEDC_PWM CHANNEL 0|GPIO 45|Duty 0100|Time 0
D (2551) HMI_ESP32_B_V11: ledc_initialized!
D (2561) LCD_st7701s_gt911_480x480: Initialize SPI bus
D (2961) LCD_st7701s_gt911_480x480: BSP_LCD_SPI_CS reset
D (3141) LCD_st7701s_gt911_480x480: BSP_LCD_SPI_CS set
I (3141) LCD_st7701s_gt911_480x480: Initialize RGB panel
I (3141) LCD_st7701s_gt911_480x480: esp_lcd_new_rgb_panel
D (3171) intr_alloc: Connected src 24 to int 17 (cpu 0)
D (3171) gdma: new group (0) at 0x3c141244
D (3171) gdma: new pair (0,0) at 0x3c141280
D (3171) gdma: new tx channel (0,0) at 0x3c0d09f8
D (3171) gdma: tx channel (0,0), (4:64) bytes aligned, burst enabled
D (3181) lcd_panel.rgb: new rgb panel(0) @0x3fc98f04, fb0 @0x3c0d0a40, fb1 @0x0, fb_size=460800, bb0 @0x0, bb1 @0x0, bb_size=0
D (3191) lcd_hal: n=4,a=9,b=4,mo=2
以下是接口配置,不知道是不是有啥限制,之前SD口无法使用,折腾几天原来是PSRAM锁住了
#if CONFIG_BSP_LCD_SUB_BOARD_800_480 || CONFIG_BSP_LCD_SUB_BOARD_480_480 \
|| CONFIG_BSP_LCD_ST7701S_GT911_480_480 ||CONFIG_BSP_LCD_RGB_GT911_480_480
#define BSP_LCD_VSYNC (GPIO_NUM_21)
#define BSP_LCD_HSYNC (GPIO_NUM_18)
#define BSP_LCD_DE (GPIO_NUM_0)
#define BSP_LCD_PCLK (GPIO_NUM_26)
#define BSP_LCD_DATA0 (GPIO_NUM_17) // B0
#define BSP_LCD_DATA1 (GPIO_NUM_16) // B1
#define BSP_LCD_DATA2 (GPIO_NUM_15) // B2
#define BSP_LCD_DATA3 (GPIO_NUM_14) // B3
#define BSP_LCD_DATA4 (GPIO_NUM_13) // B4
#define BSP_LCD_DATA5 (GPIO_NUM_12) // G0
#define BSP_LCD_DATA6 (GPIO_NUM_11) // G1
#define BSP_LCD_DATA7 (GPIO_NUM_10) // G2
#define BSP_LCD_DATA8 (GPIO_NUM_9) // G3
#define BSP_LCD_DATA9 (GPIO_NUM_8) // G4
#define BSP_LCD_DATA10 (GPIO_NUM_7) // G5
#define BSP_LCD_DATA11 (GPIO_NUM_6) // R0
#define BSP_LCD_DATA12 (GPIO_NUM_5) // R1
#define BSP_LCD_DATA13 (GPIO_NUM_4) // R2
#define BSP_LCD_DATA14 (GPIO_NUM_3) // R3
#define BSP_LCD_DATA15 (GPIO_NUM_2) // R4
#define BSP_LCD_RST (IO_EXPANDER_PIN_NUM_9)
#define BSP_LCD_SPI_CS (IO_EXPANDER_PIN_NUM_10)
#define BSP_LCD_SPI_SCLK (GPIO_NUM_48) //43)//(IO_EXPANDER_PIN_NUM_2)
#define BSP_LCD_SPI_SDO (GPIO_NUM_47) //44)//(IO_EXPANDER_PIN_NUM_3)
#define BSP_TP_RST (IO_EXPANDER_PIN_NUM_8)
以下是修改的官方例程,只改了LOGOUT、flash大小以及接口配置
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_timer.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_rgb.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_log.h"
#include "lvgl.h"
static const char *TAG = "example";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (18 * 1000 * 1000)
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_PIN_NUM_BK_LIGHT 45
#define EXAMPLE_PIN_NUM_HSYNC 18
#define EXAMPLE_PIN_NUM_VSYNC 21
#define EXAMPLE_PIN_NUM_DE 0
#define EXAMPLE_PIN_NUM_PCLK 26
#define EXAMPLE_PIN_NUM_DATA0 17 // B0
#define EXAMPLE_PIN_NUM_DATA1 16 // B1
#define EXAMPLE_PIN_NUM_DATA2 15 // B2
#define EXAMPLE_PIN_NUM_DATA3 14 // B3
#define EXAMPLE_PIN_NUM_DATA4 13 // B4
#define EXAMPLE_PIN_NUM_DATA5 12 // G0
#define EXAMPLE_PIN_NUM_DATA6 11 // G1
#define EXAMPLE_PIN_NUM_DATA7 10 // G2
#define EXAMPLE_PIN_NUM_DATA8 9 // G3
#define EXAMPLE_PIN_NUM_DATA9 8 // G4
#define EXAMPLE_PIN_NUM_DATA10 7 // G5
#define EXAMPLE_PIN_NUM_DATA11 6 // R0
#define EXAMPLE_PIN_NUM_DATA12 5 // R1
#define EXAMPLE_PIN_NUM_DATA13 4 // R2
#define EXAMPLE_PIN_NUM_DATA14 3 // R3
#define EXAMPLE_PIN_NUM_DATA15 2 // R4
#define EXAMPLE_PIN_NUM_DISP_EN -1
// The pixel number in horizontal and vertical
#define EXAMPLE_LCD_H_RES 480
#define EXAMPLE_LCD_V_RES 480
#define EXAMPLE_LVGL_TICK_PERIOD_MS 2
// we use two semaphores to sync the VSYNC event and the LVGL task, to avoid potential tearing effect
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
SemaphoreHandle_t sem_vsync_end;
SemaphoreHandle_t sem_gui_ready;
#endif
extern void example_lvgl_demo_ui(lv_disp_t *disp);
static bool example_on_vsync_event(esp_lcd_panel_handle_t panel, const esp_lcd_rgb_panel_event_data_t *event_data, void *user_data)
{
BaseType_t high_task_awoken = pdFALSE;
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
if (xSemaphoreTakeFromISR(sem_gui_ready, &high_task_awoken) == pdTRUE) {
xSemaphoreGiveFromISR(sem_vsync_end, &high_task_awoken);
}
#endif
return high_task_awoken == pdTRUE;
}
static void example_lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
{
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
int offsetx1 = area->x1;
int offsetx2 = area->x2;
int offsety1 = area->y1;
int offsety2 = area->y2;
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
xSemaphoreGive(sem_gui_ready);
xSemaphoreTake(sem_vsync_end, portMAX_DELAY);
#endif
// pass the draw buffer to the driver
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
lv_disp_flush_ready(drv);
}
static void example_increase_lvgl_tick(void *arg)
{
/* Tell LVGL how many milliseconds has elapsed */
lv_tick_inc(EXAMPLE_LVGL_TICK_PERIOD_MS);
}
void app_main(void)
{
static lv_disp_draw_buf_t disp_buf; // contains internal graphic buffer(s) called draw buffer(s)
static lv_disp_drv_t disp_drv; // contains callback functions
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
ESP_LOGI(TAG, "Create semaphores");
sem_vsync_end = xSemaphoreCreateBinary();
assert(sem_vsync_end);
sem_gui_ready = xSemaphoreCreateBinary();
assert(sem_gui_ready);
#endif
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
ESP_LOGI(TAG, "Turn off LCD backlight");
gpio_config_t bk_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT
};
ESP_ERROR_CHECK(gpio_config(&bk_gpio_config));
#endif
ESP_LOGI(TAG, "Install RGB LCD panel driver");
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_rgb_panel_config_t panel_config = {
.data_width = 16, // RGB565 in parallel mode, thus 16bit in width
.psram_trans_align = 64,
#if CONFIG_EXAMPLE_USE_BOUNCE_BUFFER
.bounce_buffer_size_px = 10 * EXAMPLE_LCD_H_RES,
#endif
.clk_src = LCD_CLK_SRC_PLL240M,//LCD_CLK_SRC_DEFAULT,
.disp_gpio_num = EXAMPLE_PIN_NUM_DISP_EN,
.pclk_gpio_num = EXAMPLE_PIN_NUM_PCLK,
.vsync_gpio_num = EXAMPLE_PIN_NUM_VSYNC,
.hsync_gpio_num = EXAMPLE_PIN_NUM_HSYNC,
.de_gpio_num = EXAMPLE_PIN_NUM_DE,
.data_gpio_nums = {
EXAMPLE_PIN_NUM_DATA0,
EXAMPLE_PIN_NUM_DATA1,
EXAMPLE_PIN_NUM_DATA2,
EXAMPLE_PIN_NUM_DATA3,
EXAMPLE_PIN_NUM_DATA4,
EXAMPLE_PIN_NUM_DATA5,
EXAMPLE_PIN_NUM_DATA6,
EXAMPLE_PIN_NUM_DATA7,
EXAMPLE_PIN_NUM_DATA8,
EXAMPLE_PIN_NUM_DATA9,
EXAMPLE_PIN_NUM_DATA10,
EXAMPLE_PIN_NUM_DATA11,
EXAMPLE_PIN_NUM_DATA12,
EXAMPLE_PIN_NUM_DATA13,
EXAMPLE_PIN_NUM_DATA14,
EXAMPLE_PIN_NUM_DATA15,
},
.timings = {
.pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
.h_res = EXAMPLE_LCD_H_RES,
.v_res = EXAMPLE_LCD_V_RES,
// The following parameters should refer to LCD spec
.hsync_back_porch = 40,
.hsync_front_porch = 20,
.hsync_pulse_width = 1,
.vsync_back_porch = 8,
.vsync_front_porch = 4,
.vsync_pulse_width = 1,
.flags.pclk_active_neg = true,
},
.flags.fb_in_psram = true, // allocate frame buffer in PSRAM
#if CONFIG_EXAMPLE_DOUBLE_FB
.flags.double_fb = true, // allocate double frame buffer
#endif // CONFIG_EXAMPLE_DOUBLE_FB
};
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle));
ESP_LOGI(TAG, "Register event callbacks");//无法运行到这一行
#if 1
esp_lcd_rgb_panel_event_callbacks_t cbs = {
.on_vsync = example_on_vsync_event,
};
ESP_ERROR_CHECK(esp_lcd_rgb_panel_register_event_callbacks(panel_handle, &cbs, &disp_drv));
ESP_LOGI(TAG, "Initialize RGB LCD panel");
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
ESP_LOGI(TAG, "Turn on LCD backlight");
gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
#endif
ESP_LOGI(TAG, "Initialize LVGL library");
lv_init();
void *buf1 = NULL;
void *buf2 = NULL;
#if CONFIG_EXAMPLE_DOUBLE_FB
ESP_LOGI(TAG, "Use frame buffers as LVGL draw buffers");
ESP_ERROR_CHECK(esp_lcd_rgb_panel_get_frame_buffer(panel_handle, 2, &buf1, &buf2));
// initialize LVGL draw buffers
lv_disp_draw_buf_init(&disp_buf, buf1, buf2, EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES);
#else
ESP_LOGI(TAG, "Allocate separate LVGL draw buffers from PSRAM");
buf1 = heap_caps_malloc(EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), MALLOC_CAP_SPIRAM);
assert(buf1);
buf2 = heap_caps_malloc(EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), MALLOC_CAP_SPIRAM);
assert(buf2);
// initialize LVGL draw buffers
lv_disp_draw_buf_init(&disp_buf, buf1, buf2, EXAMPLE_LCD_H_RES * 100);
#endif // CONFIG_EXAMPLE_DOUBLE_FB
ESP_LOGI(TAG, "Register display driver to LVGL");
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = EXAMPLE_LCD_H_RES;
disp_drv.ver_res = EXAMPLE_LCD_V_RES;
disp_drv.flush_cb = example_lvgl_flush_cb;
disp_drv.draw_buf = &disp_buf;
disp_drv.user_data = panel_handle;
#if CONFIG_EXAMPLE_DOUBLE_FB
disp_drv.full_refresh = true; // the full_refresh mode can maintain the synchronization between the two frame buffers
#endif
lv_disp_t *disp = lv_disp_drv_register(&disp_drv);
ESP_LOGI(TAG, "Install LVGL tick timer");
// Tick interface for LVGL (using esp_timer to generate 2ms periodic event)
const esp_timer_create_args_t lvgl_tick_timer_args = {
.callback = &example_increase_lvgl_tick,
.name = "lvgl_tick"
};
esp_timer_handle_t lvgl_tick_timer = NULL;
ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer));
ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000));
ESP_LOGI(TAG, "Display LVGL Scatter Chart");
example_lvgl_demo_ui(disp);
#endif
while (1) {
// raise the task priority of LVGL and/or reduce the handler period can improve the performance
vTaskDelay(pdMS_TO_TICKS(50));
// The task running lv_timer_handler should have lower priority than that running `lv_tick_inc`
lv_timer_handler();
}
}
问题2)SPI信号不正常没有低电平,只有一个瞬态下江针柱,SPI接口用SD卡测试程序测试正常。SPI口原来接的flash口,无法加入设备。
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x2b (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fce3810,len:0x1684
load:0x403c9700,len:0xbe8
load:0x403cc700,len:0x2ea8
entry 0x403c9904
I (29) boot: ESP-IDF v5.0-dirty 2nd stage bootloader
I (30) boot: compile time 21:45:34
I (30) boot: chip revision: v0.1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32s3: Boot SPI Speed : 40MHz
I (44) boot.esp32s3: SPI Mode : DIO
I (48) boot.esp32s3: SPI Flash Size : 16MB
I (53) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (77) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00177000
I (92) boot: End of partition table
I (96) boot_comm: chip revision: 1, min. application chip revision: 0
I (103) esp_image: segment 0: paddr=00010020 vaddr=3c050020 size=726fch (468732) map
I (228) esp_image: segment 1: paddr=00082724 vaddr=3fc93600 size=03394h ( 13204) load
I (232) esp_image: segment 2: paddr=00085ac0 vaddr=40374000 size=0a558h ( 42328) load
I (246) esp_image: segment 3: paddr=00090020 vaddr=42000020 size=4f388h (324488) map
I (327) esp_image: segment 4: paddr=000df3b0 vaddr=4037e558 size=0507ch ( 20604) load
I (333) esp_image: segment 5: paddr=000e4434 vaddr=50000000 size=00010h ( 16) load
I (340) boot: Loaded app from partition at offset 0x10000
I (340) boot: Disabling RNG early entropy source...
I (356) octal_psram: vendor id : 0x0d (AP)
I (356) octal_psram: dev id : 0x02 (generation 3)
I (356) octal_psram: density : 0x03 (64 Mbit)
I (361) octal_psram: good-die : 0x01 (Pass)
I (366) octal_psram: Latency : 0x01 (Fixed)
I (371) octal_psram: VCC : 0x01 (3V)
I (377) octal_psram: SRF : 0x01 (Fast Refresh)
I (382) octal_psram: BurstType : 0x01 (Hybrid Wrap)
I (388) octal_psram: BurstLen : 0x01 (32 Byte)
I (394) octal_psram: Readlatency : 0x02 (10 cycles@Fixed)
I (400) octal_psram: DriveStrength: 0x00 (1/1)
I (405) esp_psram: Found 8MB PSRAM device
I (410) esp_psram: Speed: 40MHz
I (414) cpu_start: Pro cpu up.
I (417) cpu_start: Starting app cpu, entry point is 0x40375478
I (0) cpu_start: App cpu up.
I (1155) esp_psram: SPI SRAM memory test OK
D (1155) efuse: In EFUSE_BLK2__DATA4_REG is used 2 bits starting with 0 bit
D (1155) efuse: In EFUSE_BLK2__DATA4_REG is used 8 bits starting with 13 bit
D (1171) clk: RTC_SLOW_CLK calibration value: 3900941
I (1180) cpu_start: Pro cpu start user code
I (1180) cpu_start: cpu freq: 240000000 Hz
I (1180) cpu_start: Application information:
I (1183) cpu_start: Project name: hmi_esp32_blink
I (1189) cpu_start: App version: 1
I (1194) cpu_start: Compile time: Feb 19 2023 21:45:05
I (1200) cpu_start: ELF file SHA256: e3e176e0672d8b9c...
I (1206) cpu_start: ESP-IDF: v5.0-dirty
D (1211) memory_layout: Checking 6 reserved memory ranges:
D (1217) memory_layout: Reserved memory range 0x3c000000 - 0x3e000000
D (1223) memory_layout: Reserved memory range 0x3fc84000 - 0x3fc93600
D (1230) memory_layout: Reserved memory range 0x3fc93600 - 0x3fc97a68
D (1236) memory_layout: Reserved memory range 0x3fceee34 - 0x3fcf0000
D (1243) memory_layout: Reserved memory range 0x40374000 - 0x40383600
D (1249) memory_layout: Reserved memory range 0x600fe000 - 0x600fe010
D (1256) memory_layout: Building list of available memory regions:
D (1262) memory_layout: Available memory region 0x3fc97a68 - 0x3fca0000
D (1269) memory_layout: Available memory region 0x3fca0000 - 0x3fcb0000
D (1275) memory_layout: Available memory region 0x3fcb0000 - 0x3fcc0000
D (1282) memory_layout: Available memory region 0x3fcc0000 - 0x3fcd0000
D (1289) memory_layout: Available memory region 0x3fcd0000 - 0x3fce0000
D (1295) memory_layout: Available memory region 0x3fce0000 - 0x3fce9710
D (1302) memory_layout: Available memory region 0x3fce9710 - 0x3fceee34
D (1309) memory_layout: Available memory region 0x3fcf0000 - 0x3fcf8000
D (1315) memory_layout: Available memory region 0x600fe010 - 0x60100000
I (1322) heap_init: Initializing. RAM available for dynamic allocation:
D (1329) heap_init: New heap initialised at 0x3fc97a68
I (1335) heap_init: At 3FC97A68 len 00051CA8 (327 KiB): D/IRAM
I (1341) heap_init: At 3FCE9710 len 00005724 (21 KiB): STACK/DRAM
D (1348) heap_init: New heap initialised at 0x3fcf0000
I (1353) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
D (1359) heap_init: New heap initialised at 0x600fe010
I (1365) heap_init: At 600FE010 len 00001FF0 (7 KiB): RTCRAM
I (1371) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator
D (1379) intr_alloc: Connected src 39 to int 2 (cpu 0)
D (1384) spi_flash: trying chip: issi
D (1388) spi_flash: trying chip: gd
D (1391) spi_flash: trying chip: mxic
D (1395) spi_flash: trying chip: winbond
I (1399) spi_flash: detected chip: winbond
I (1404) spi_flash: flash io: dio
D (1408) cpu_start: calling init function: 0x4203bcc8
D (1413) cpu_start: calling init function: 0x42002934
D (1418) cpu_start: calling init function: 0x42001ebc
D (1423) cpu_start: calling init function: 0x42006770 on core: 0
D (1429) intr_alloc: Connected src 59 to int 3 (cpu 0)
D (1434) cpu_start: calling init function: 0x4203c7c0 on core: 0
I (1440) sleep: Configure to isolate all GPIO pins in sleep state
I (1447) sleep: Enable automatic switching of GPIO sleep configuration
D (1454) cpu_start: calling init function: 0x420026d8 on core: 0
D (1461) intr_alloc: Connected src 79 to int 9 (cpu 0)
I (1465) cpu_start: Starting scheduler on PRO CPU.
D (1471) intr_alloc: Connected src 57 to int 12 (cpu 0)
D (1471) intr_alloc: Connected src 80 to int 2 (cpu 1)
I (1481) cpu_start: Starting scheduler on APP CPU.
D (1481) intr_alloc: Connected src 58 to int 3 (cpu 1)
D (1491) heap_init: New heap initialised at 0x3fce9710
I (1491) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
D (1501) esp_psram: Allocating block of size 32768 bytes
D (1511) intr_alloc: Connected src 43 to int 13 (cpu 0)
D (1511) HMI_ESP32_B_V11: init io_expander: 0
D (1521) aw9523b: mode_reg0: 0xf8
D (1521) aw9523b: mode_reg1: 0xff
D (1521) aw9523b: ctrl_reg: 0x11
I (1531) aw9523b: i2c_address: 0x58, device_id: 0x23
D (1531) HMI_ESP32_B_V11: inited io_expander: 3fcea380
I (1541) app_main: please press power key to start up
I (1541) HMI_ESP32_B_V11: power on
D (2551) ledc: Using clock source 1 (in slow mode), divisor: 0x1f4
D (2551) ledc: In slow speed mode, global clk set: 1
D (2551) ledc: LEDC_PWM CHANNEL 0|GPIO 45|Duty 0100|Time 0
D (2551) HMI_ESP32_B_V11: ledc_initialized!
D (2561) LCD_st7701s_gt911_480x480: Initialize SPI bus
D (2961) LCD_st7701s_gt911_480x480: BSP_LCD_SPI_CS reset
D (3141) LCD_st7701s_gt911_480x480: BSP_LCD_SPI_CS set
I (3141) LCD_st7701s_gt911_480x480: Initialize RGB panel
I (3141) LCD_st7701s_gt911_480x480: esp_lcd_new_rgb_panel
D (3171) intr_alloc: Connected src 24 to int 17 (cpu 0)
D (3171) gdma: new group (0) at 0x3c141244
D (3171) gdma: new pair (0,0) at 0x3c141280
D (3171) gdma: new tx channel (0,0) at 0x3c0d09f8
D (3171) gdma: tx channel (0,0), (4:64) bytes aligned, burst enabled
D (3181) lcd_panel.rgb: new rgb panel(0) @0x3fc98f04, fb0 @0x3c0d0a40, fb1 @0x0, fb_size=460800, bb0 @0x0, bb1 @0x0, bb_size=0
D (3191) lcd_hal: n=4,a=9,b=4,mo=2
以下是接口配置,不知道是不是有啥限制,之前SD口无法使用,折腾几天原来是PSRAM锁住了
#if CONFIG_BSP_LCD_SUB_BOARD_800_480 || CONFIG_BSP_LCD_SUB_BOARD_480_480 \
|| CONFIG_BSP_LCD_ST7701S_GT911_480_480 ||CONFIG_BSP_LCD_RGB_GT911_480_480
#define BSP_LCD_VSYNC (GPIO_NUM_21)
#define BSP_LCD_HSYNC (GPIO_NUM_18)
#define BSP_LCD_DE (GPIO_NUM_0)
#define BSP_LCD_PCLK (GPIO_NUM_26)
#define BSP_LCD_DATA0 (GPIO_NUM_17) // B0
#define BSP_LCD_DATA1 (GPIO_NUM_16) // B1
#define BSP_LCD_DATA2 (GPIO_NUM_15) // B2
#define BSP_LCD_DATA3 (GPIO_NUM_14) // B3
#define BSP_LCD_DATA4 (GPIO_NUM_13) // B4
#define BSP_LCD_DATA5 (GPIO_NUM_12) // G0
#define BSP_LCD_DATA6 (GPIO_NUM_11) // G1
#define BSP_LCD_DATA7 (GPIO_NUM_10) // G2
#define BSP_LCD_DATA8 (GPIO_NUM_9) // G3
#define BSP_LCD_DATA9 (GPIO_NUM_8) // G4
#define BSP_LCD_DATA10 (GPIO_NUM_7) // G5
#define BSP_LCD_DATA11 (GPIO_NUM_6) // R0
#define BSP_LCD_DATA12 (GPIO_NUM_5) // R1
#define BSP_LCD_DATA13 (GPIO_NUM_4) // R2
#define BSP_LCD_DATA14 (GPIO_NUM_3) // R3
#define BSP_LCD_DATA15 (GPIO_NUM_2) // R4
#define BSP_LCD_RST (IO_EXPANDER_PIN_NUM_9)
#define BSP_LCD_SPI_CS (IO_EXPANDER_PIN_NUM_10)
#define BSP_LCD_SPI_SCLK (GPIO_NUM_48) //43)//(IO_EXPANDER_PIN_NUM_2)
#define BSP_LCD_SPI_SDO (GPIO_NUM_47) //44)//(IO_EXPANDER_PIN_NUM_3)
#define BSP_TP_RST (IO_EXPANDER_PIN_NUM_8)
以下是修改的官方例程,只改了LOGOUT、flash大小以及接口配置
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/
#include <stdio.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp_timer.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_rgb.h"
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_log.h"
#include "lvgl.h"
static const char *TAG = "example";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (18 * 1000 * 1000)
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
#define EXAMPLE_PIN_NUM_BK_LIGHT 45
#define EXAMPLE_PIN_NUM_HSYNC 18
#define EXAMPLE_PIN_NUM_VSYNC 21
#define EXAMPLE_PIN_NUM_DE 0
#define EXAMPLE_PIN_NUM_PCLK 26
#define EXAMPLE_PIN_NUM_DATA0 17 // B0
#define EXAMPLE_PIN_NUM_DATA1 16 // B1
#define EXAMPLE_PIN_NUM_DATA2 15 // B2
#define EXAMPLE_PIN_NUM_DATA3 14 // B3
#define EXAMPLE_PIN_NUM_DATA4 13 // B4
#define EXAMPLE_PIN_NUM_DATA5 12 // G0
#define EXAMPLE_PIN_NUM_DATA6 11 // G1
#define EXAMPLE_PIN_NUM_DATA7 10 // G2
#define EXAMPLE_PIN_NUM_DATA8 9 // G3
#define EXAMPLE_PIN_NUM_DATA9 8 // G4
#define EXAMPLE_PIN_NUM_DATA10 7 // G5
#define EXAMPLE_PIN_NUM_DATA11 6 // R0
#define EXAMPLE_PIN_NUM_DATA12 5 // R1
#define EXAMPLE_PIN_NUM_DATA13 4 // R2
#define EXAMPLE_PIN_NUM_DATA14 3 // R3
#define EXAMPLE_PIN_NUM_DATA15 2 // R4
#define EXAMPLE_PIN_NUM_DISP_EN -1
// The pixel number in horizontal and vertical
#define EXAMPLE_LCD_H_RES 480
#define EXAMPLE_LCD_V_RES 480
#define EXAMPLE_LVGL_TICK_PERIOD_MS 2
// we use two semaphores to sync the VSYNC event and the LVGL task, to avoid potential tearing effect
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
SemaphoreHandle_t sem_vsync_end;
SemaphoreHandle_t sem_gui_ready;
#endif
extern void example_lvgl_demo_ui(lv_disp_t *disp);
static bool example_on_vsync_event(esp_lcd_panel_handle_t panel, const esp_lcd_rgb_panel_event_data_t *event_data, void *user_data)
{
BaseType_t high_task_awoken = pdFALSE;
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
if (xSemaphoreTakeFromISR(sem_gui_ready, &high_task_awoken) == pdTRUE) {
xSemaphoreGiveFromISR(sem_vsync_end, &high_task_awoken);
}
#endif
return high_task_awoken == pdTRUE;
}
static void example_lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
{
esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;
int offsetx1 = area->x1;
int offsetx2 = area->x2;
int offsety1 = area->y1;
int offsety2 = area->y2;
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
xSemaphoreGive(sem_gui_ready);
xSemaphoreTake(sem_vsync_end, portMAX_DELAY);
#endif
// pass the draw buffer to the driver
esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
lv_disp_flush_ready(drv);
}
static void example_increase_lvgl_tick(void *arg)
{
/* Tell LVGL how many milliseconds has elapsed */
lv_tick_inc(EXAMPLE_LVGL_TICK_PERIOD_MS);
}
void app_main(void)
{
static lv_disp_draw_buf_t disp_buf; // contains internal graphic buffer(s) called draw buffer(s)
static lv_disp_drv_t disp_drv; // contains callback functions
#if CONFIG_EXAMPLE_AVOID_TEAR_EFFECT_WITH_SEM
ESP_LOGI(TAG, "Create semaphores");
sem_vsync_end = xSemaphoreCreateBinary();
assert(sem_vsync_end);
sem_gui_ready = xSemaphoreCreateBinary();
assert(sem_gui_ready);
#endif
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
ESP_LOGI(TAG, "Turn off LCD backlight");
gpio_config_t bk_gpio_config = {
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1ULL << EXAMPLE_PIN_NUM_BK_LIGHT
};
ESP_ERROR_CHECK(gpio_config(&bk_gpio_config));
#endif
ESP_LOGI(TAG, "Install RGB LCD panel driver");
esp_lcd_panel_handle_t panel_handle = NULL;
esp_lcd_rgb_panel_config_t panel_config = {
.data_width = 16, // RGB565 in parallel mode, thus 16bit in width
.psram_trans_align = 64,
#if CONFIG_EXAMPLE_USE_BOUNCE_BUFFER
.bounce_buffer_size_px = 10 * EXAMPLE_LCD_H_RES,
#endif
.clk_src = LCD_CLK_SRC_PLL240M,//LCD_CLK_SRC_DEFAULT,
.disp_gpio_num = EXAMPLE_PIN_NUM_DISP_EN,
.pclk_gpio_num = EXAMPLE_PIN_NUM_PCLK,
.vsync_gpio_num = EXAMPLE_PIN_NUM_VSYNC,
.hsync_gpio_num = EXAMPLE_PIN_NUM_HSYNC,
.de_gpio_num = EXAMPLE_PIN_NUM_DE,
.data_gpio_nums = {
EXAMPLE_PIN_NUM_DATA0,
EXAMPLE_PIN_NUM_DATA1,
EXAMPLE_PIN_NUM_DATA2,
EXAMPLE_PIN_NUM_DATA3,
EXAMPLE_PIN_NUM_DATA4,
EXAMPLE_PIN_NUM_DATA5,
EXAMPLE_PIN_NUM_DATA6,
EXAMPLE_PIN_NUM_DATA7,
EXAMPLE_PIN_NUM_DATA8,
EXAMPLE_PIN_NUM_DATA9,
EXAMPLE_PIN_NUM_DATA10,
EXAMPLE_PIN_NUM_DATA11,
EXAMPLE_PIN_NUM_DATA12,
EXAMPLE_PIN_NUM_DATA13,
EXAMPLE_PIN_NUM_DATA14,
EXAMPLE_PIN_NUM_DATA15,
},
.timings = {
.pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
.h_res = EXAMPLE_LCD_H_RES,
.v_res = EXAMPLE_LCD_V_RES,
// The following parameters should refer to LCD spec
.hsync_back_porch = 40,
.hsync_front_porch = 20,
.hsync_pulse_width = 1,
.vsync_back_porch = 8,
.vsync_front_porch = 4,
.vsync_pulse_width = 1,
.flags.pclk_active_neg = true,
},
.flags.fb_in_psram = true, // allocate frame buffer in PSRAM
#if CONFIG_EXAMPLE_DOUBLE_FB
.flags.double_fb = true, // allocate double frame buffer
#endif // CONFIG_EXAMPLE_DOUBLE_FB
};
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle));
ESP_LOGI(TAG, "Register event callbacks");//无法运行到这一行
#if 1
esp_lcd_rgb_panel_event_callbacks_t cbs = {
.on_vsync = example_on_vsync_event,
};
ESP_ERROR_CHECK(esp_lcd_rgb_panel_register_event_callbacks(panel_handle, &cbs, &disp_drv));
ESP_LOGI(TAG, "Initialize RGB LCD panel");
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
#if EXAMPLE_PIN_NUM_BK_LIGHT >= 0
ESP_LOGI(TAG, "Turn on LCD backlight");
gpio_set_level(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
#endif
ESP_LOGI(TAG, "Initialize LVGL library");
lv_init();
void *buf1 = NULL;
void *buf2 = NULL;
#if CONFIG_EXAMPLE_DOUBLE_FB
ESP_LOGI(TAG, "Use frame buffers as LVGL draw buffers");
ESP_ERROR_CHECK(esp_lcd_rgb_panel_get_frame_buffer(panel_handle, 2, &buf1, &buf2));
// initialize LVGL draw buffers
lv_disp_draw_buf_init(&disp_buf, buf1, buf2, EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES);
#else
ESP_LOGI(TAG, "Allocate separate LVGL draw buffers from PSRAM");
buf1 = heap_caps_malloc(EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), MALLOC_CAP_SPIRAM);
assert(buf1);
buf2 = heap_caps_malloc(EXAMPLE_LCD_H_RES * 100 * sizeof(lv_color_t), MALLOC_CAP_SPIRAM);
assert(buf2);
// initialize LVGL draw buffers
lv_disp_draw_buf_init(&disp_buf, buf1, buf2, EXAMPLE_LCD_H_RES * 100);
#endif // CONFIG_EXAMPLE_DOUBLE_FB
ESP_LOGI(TAG, "Register display driver to LVGL");
lv_disp_drv_init(&disp_drv);
disp_drv.hor_res = EXAMPLE_LCD_H_RES;
disp_drv.ver_res = EXAMPLE_LCD_V_RES;
disp_drv.flush_cb = example_lvgl_flush_cb;
disp_drv.draw_buf = &disp_buf;
disp_drv.user_data = panel_handle;
#if CONFIG_EXAMPLE_DOUBLE_FB
disp_drv.full_refresh = true; // the full_refresh mode can maintain the synchronization between the two frame buffers
#endif
lv_disp_t *disp = lv_disp_drv_register(&disp_drv);
ESP_LOGI(TAG, "Install LVGL tick timer");
// Tick interface for LVGL (using esp_timer to generate 2ms periodic event)
const esp_timer_create_args_t lvgl_tick_timer_args = {
.callback = &example_increase_lvgl_tick,
.name = "lvgl_tick"
};
esp_timer_handle_t lvgl_tick_timer = NULL;
ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer));
ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000));
ESP_LOGI(TAG, "Display LVGL Scatter Chart");
example_lvgl_demo_ui(disp);
#endif
while (1) {
// raise the task priority of LVGL and/or reduce the handler period can improve the performance
vTaskDelay(pdMS_TO_TICKS(50));
// The task running lv_timer_handler should have lower priority than that running `lv_tick_inc`
lv_timer_handler();
}
}
Last edited by 末班车上的乘客 on Wed Feb 22, 2023 2:45 am, edited 1 time in total.
-
- Posts: 27
- Joined: Mon Oct 10, 2022 2:47 am
Re: ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
你好,基于你的问题描述,想再请你确认以下信息:
1. 问题一:“一直卡在最后一句”是指程序在输出上述 log 后就循环卡死,程序在后续是否还有 log 输出?
2. 问题二:“SPI 信号”是指用于屏幕初始化的 SPI 接口吗?当前 SPI 接口是采用硬件还是软件模拟?
3. 补充:麻烦提供开发板原理图、当前 ESP-IDF 的 commit ID,如果可以的话最好提供一下工程代码。
4. 附件:为适配过 ST7701S 的工程代码,可以参考一下。
1. 问题一:“一直卡在最后一句”是指程序在输出上述 log 后就循环卡死,程序在后续是否还有 log 输出?
2. 问题二:“SPI 信号”是指用于屏幕初始化的 SPI 接口吗?当前 SPI 接口是采用硬件还是软件模拟?
3. 补充:麻烦提供开发板原理图、当前 ESP-IDF 的 commit ID,如果可以的话最好提供一下工程代码。
4. 附件:为适配过 ST7701S 的工程代码,可以参考一下。
- Attachments
-
- ST7701S_RGB_2_1_480_480.zip
- (18.81 KiB) Downloaded 854 times
Re: ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
这论坛没有技术支持在盯着吗?NXP的回复基本不超过24小时,唯一一次超过24小时的是人家挂测了一天并把实测数据贴出来了
我买的是这款屏:https://item.taobao.com/item.htm?spm=a1 ... 1midmmeb9f
有大佬帮忙验证以下我这硬件接法能行吗
自定义工程能跑到这一行
uint32_t lcd_hal_cal_pclk_freq(lcd_hal_context_t *hal, uint32_t src_freq_hz, uint32_t expect_pclk_freq_hz, int lcd_clk_flags)
{
// lcd_clk = module_clock_src / (n + b / a)
// pixel_clk = lcd_clk / mo
uint32_t mo = src_freq_hz / expect_pclk_freq_hz / LCD_LL_CLK_FRAC_DIV_N_MAX + 1;
if (mo == 1 && !(lcd_clk_flags & LCD_HAL_PCLK_FLAG_ALLOW_EQUAL_SYSCLK)) {
mo = 2;
}
uint32_t n = src_freq_hz / expect_pclk_freq_hz / mo;
uint32_t a = 0;
uint32_t b = 0;
// delta_hz / expect_pclk_freq_hz <==> b / a
uint32_t delta_hz = src_freq_hz / mo - expect_pclk_freq_hz * n;
// fractional divider
if (delta_hz) {
uint32_t gcd = _gcd(expect_pclk_freq_hz, delta_hz);
a = expect_pclk_freq_hz / gcd;
b = delta_hz / gcd;
// normalize div_a and div_b
uint32_t d = a / LCD_LL_CLK_FRAC_DIV_AB_MAX + 1;
a /= d;
b /= d;
}
HAL_EARLY_LOGD("lcd_hal", "n=%d,a=%d,b=%d,mo=%d", n, a, b, mo);//跑到这一行
官方例程卡死在这
esp_err_t esp_lcd_new_rgb_panel(const esp_lcd_rgb_panel_config_t *rgb_panel_config, esp_lcd_panel_handle_t *ret_panel)
{
....
// install DMA service
rgb_panel->flags.stream_mode = !rgb_panel_config->flags.refresh_on_demand;
ret = lcd_rgb_panel_create_trans_link(rgb_panel);
ESP_GOTO_ON_ERROR(ret, err, TAG, "install DMA failed");ESP_LOGD(TAG, "start gpio config...");//这行log有
// configure GPIO
ret = lcd_rgb_panel_configure_gpio(rgb_panel, rgb_panel_config); ESP_LOGD(TAG, "in esp_lcd_new_rgb_panel");//这行log无
我买的是这款屏:https://item.taobao.com/item.htm?spm=a1 ... 1midmmeb9f
有大佬帮忙验证以下我这硬件接法能行吗
自定义工程能跑到这一行
uint32_t lcd_hal_cal_pclk_freq(lcd_hal_context_t *hal, uint32_t src_freq_hz, uint32_t expect_pclk_freq_hz, int lcd_clk_flags)
{
// lcd_clk = module_clock_src / (n + b / a)
// pixel_clk = lcd_clk / mo
uint32_t mo = src_freq_hz / expect_pclk_freq_hz / LCD_LL_CLK_FRAC_DIV_N_MAX + 1;
if (mo == 1 && !(lcd_clk_flags & LCD_HAL_PCLK_FLAG_ALLOW_EQUAL_SYSCLK)) {
mo = 2;
}
uint32_t n = src_freq_hz / expect_pclk_freq_hz / mo;
uint32_t a = 0;
uint32_t b = 0;
// delta_hz / expect_pclk_freq_hz <==> b / a
uint32_t delta_hz = src_freq_hz / mo - expect_pclk_freq_hz * n;
// fractional divider
if (delta_hz) {
uint32_t gcd = _gcd(expect_pclk_freq_hz, delta_hz);
a = expect_pclk_freq_hz / gcd;
b = delta_hz / gcd;
// normalize div_a and div_b
uint32_t d = a / LCD_LL_CLK_FRAC_DIV_AB_MAX + 1;
a /= d;
b /= d;
}
HAL_EARLY_LOGD("lcd_hal", "n=%d,a=%d,b=%d,mo=%d", n, a, b, mo);//跑到这一行
官方例程卡死在这
esp_err_t esp_lcd_new_rgb_panel(const esp_lcd_rgb_panel_config_t *rgb_panel_config, esp_lcd_panel_handle_t *ret_panel)
{
....
// install DMA service
rgb_panel->flags.stream_mode = !rgb_panel_config->flags.refresh_on_demand;
ret = lcd_rgb_panel_create_trans_link(rgb_panel);
ESP_GOTO_ON_ERROR(ret, err, TAG, "install DMA failed");ESP_LOGD(TAG, "start gpio config...");//这行log有
// configure GPIO
ret = lcd_rgb_panel_configure_gpio(rgb_panel, rgb_panel_config); ESP_LOGD(TAG, "in esp_lcd_new_rgb_panel");//这行log无
Re: ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
关闭看门狗后就一直停着了
Re: ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
gpio26被锁住了,应该是这崩了。
static esp_err_t lcd_rgb_panel_configure_gpio(esp_rgb_panel_t *panel, const esp_lcd_rgb_panel_config_t *panel_config)
{
...
if (panel_config->vsync_gpio_num >= 0) {
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[panel_config->vsync_gpio_num], PIN_FUNC_GPIO);
gpio_set_direction(panel_config->vsync_gpio_num, GPIO_MODE_OUTPUT);
esp_rom_gpio_connect_out_signal(panel_config->vsync_gpio_num,
lcd_periph_signals.panels[panel_id].vsync_sig, false, false);
}ESP_LOGD(TAG, "start gpio config...");
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[panel_config->pclk_gpio_num], PIN_FUNC_GPIO);ESP_LOGD(TAG, "in lcd_rgb_panel_configure_gpio");
static esp_err_t lcd_rgb_panel_configure_gpio(esp_rgb_panel_t *panel, const esp_lcd_rgb_panel_config_t *panel_config)
{
...
if (panel_config->vsync_gpio_num >= 0) {
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[panel_config->vsync_gpio_num], PIN_FUNC_GPIO);
gpio_set_direction(panel_config->vsync_gpio_num, GPIO_MODE_OUTPUT);
esp_rom_gpio_connect_out_signal(panel_config->vsync_gpio_num,
lcd_periph_signals.panels[panel_id].vsync_sig, false, false);
}ESP_LOGD(TAG, "start gpio config...");
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[panel_config->pclk_gpio_num], PIN_FUNC_GPIO);ESP_LOGD(TAG, "in lcd_rgb_panel_configure_gpio");
Re: ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
处理完GPIO26后,屏幕能够点亮了。狂补RGB知识中。
- Attachments
-
- IMG_20230220_222916R.jpg (4.11 MiB) Viewed 6069 times
Re: ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
SPI还是有问题,SPI接口接连
#define BSP_LCD_SPI_CS (IO_EXPANDER_PIN_NUM_10)
#define BSP_LCD_SPI_SCLK (GPIO_NUM_48) //43)//(IO_EXPANDER_PIN_NUM_2)
#define BSP_LCD_SPI_SDO (GPIO_NUM_47) //44)//(IO_EXPANDER_PIN_NUM_3)
#define BSP_LCD_SPI_NUM (SPI3_HOST)
----------------------------------------------------------------------------------------------------------------------------
esp_err_t lcd_config(esp_io_expander_handle_t handle)
{
ESP_LOGD(TAG, "Initialize SPI bus");
const spi_bus_config_t buscfg = {
.sclk_io_num = BSP_LCD_SPI_SCLK,
.mosi_io_num = BSP_LCD_SPI_SDO,
.miso_io_num = GPIO_NUM_NC,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = 4096
};
ESP_LOGD(TAG, "handle:%x", handle);
ESP_LOGD(TAG, "buscfg: %x, %x, %x", buscfg.sclk_io_num, buscfg.mosi_io_num);
BSP_ERROR_CHECK_RETURN_ERR(spi_bus_initialize(BSP_LCD_SPI_NUM, &buscfg, SPI_DMA_CH_AUTO));
ESP_LOGD(TAG, "spi_bus_initialize finished");
spi_device_handle_t spi;
spi_device_interface_config_t devcfg={
#ifdef CONFIG_LCD_OVERCLOCK
.clock_speed_hz=26*1000*1000, //Clock out at 26 MHz
#else
.clock_speed_hz=10*1000*1000, //Clock out at 10 MHz
#endif
.mode=0, //SPI mode 0
.spics_io_num = GPIO_NUM_NC, //CS pin
.queue_size= 7, //We want to be able to queue 7 transactions at a time
.pre_cb=lcd_spi_pre_transfer_callback, //Specify pre-transfer callback to handle D/C line
};
ESP_LOGD(TAG, "spi_bus_add_device");
BSP_ERROR_CHECK_RETURN_ERR(spi_bus_add_device(BSP_LCD_SPI_NUM, &devcfg, &spi));
while (!handle) {
ESP_LOGI(TAG, "waiting for io_expander init: %x", handle);
vTaskDelay(pdMS_TO_TICKS(20));
}
BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_dir(io_expander, BSP_LCD_RST, IO_EXPANDER_OUTPUT));
BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_level(io_expander, BSP_LCD_RST, 0));
vTaskDelay(pdMS_TO_TICKS(10));
BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_level(io_expander, BSP_LCD_RST, 1));
vTaskDelay(pdMS_TO_TICKS(120));
//BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_dir(handle, BSP_LCD_SPI_CS, IO_EXPANDER_OUTPUT));
//BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_level(handle, BSP_LCD_SPI_CS, 0));
//BSP_ERROR_CHECK_RETURN_ERR(lcd_cmd(spi, 0x29, false));
//BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_level(handle, BSP_LCD_SPI_CS, 1));
//vTaskDelay(pdMS_TO_TICKS(150));
BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_level(handle, BSP_LCD_SPI_CS, 0));
ESP_LOGD(TAG, "BSP_LCD_SPI_CS reset");
for (uint8_t i = 0; LCD_CONFIG_CMD.data_bytes != 0xff; i++)
{
BSP_ERROR_CHECK_RETURN_ERR(lcd_cmd(spi, LCD_CONFIG_CMD.cmd, false));
ESP_LOGD(TAG, "i: %d, bytes: %d", i, LCD_CONFIG_CMD.data_bytes);
BSP_ERROR_CHECK_RETURN_ERR(lcd_data(spi, LCD_CONFIG_CMD.data, LCD_CONFIG_CMD.data_bytes &0x7F));
}
BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_level(handle, BSP_LCD_SPI_CS, 1));
vTaskDelay(pdMS_TO_TICKS(120));
//BSP_ERROR_CHECK_RETURN_ERR(lcd_cmd(spi, 0x29, false));
//vTaskDelay(pdMS_TO_TICKS(20));
BSP_ERROR_CHECK_RETURN_ERR(spi_bus_remove_device(spi));
//spi_device_release_bus(spi);
BSP_ERROR_CHECK_RETURN_ERR(esp_io_expander_set_level(handle, BSP_LCD_SPI_CS, 1));
ESP_LOGD(TAG, "BSP_LCD_SPI_CS set");
return ESP_OK;
}
Re: ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
您好,论坛这边是用于爱好者讨论问题和分享成果的。如果您那边有项目对答疑时间有要求的话,请移步到乐鑫的客户支持系统:sales@espressif.com 获取支持。
如果问题已解决,请修改标题。
谢谢。
如果问题已解决,请修改标题。
谢谢。
Re: [已解决]ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
显示屏问题已解决,GPIO47,GPIO48,无法作为SPI问题正在查。论坛回复的ST7701S项目GPIO0无输出,这个暂时不查了
Re: [已解决]ESP32S3驱动RGB屏幕问题,求助这个项目干了3周了!
老哥可以分享下硬件连线图吗?目前也在搞这个RGB屏幕,没有头绪,万分谢谢
Who is online
Users browsing this forum: No registered users and 70 guests