NHD-3.5-640480EF-MSXP Initialisation sequence
Hello,
i currently try to get the NHD-3.5-640480EF-MSXP running with an ESP32P4 Rev1.3 (waveshare dev board). I managed to get the read commands running and receiveing a feedback from the Display. For first tests i want to color the screen in red but i don't get any results on the screen and no Error in the Logs...
My current code:
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "esp_err.h"
#include "esp_heap_caps.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_io.h"
#include "esp_lcd_mipi_dsi.h"
#include "esp_ldo_regulator.h"
#include "driver/gpio.h"
static const char *TAG = "NHD_DSI";
#define LCD_H_RES 640
#define LCD_V_RES 480
#define LCD_HSYNC 120
#define LCD_HBP 120
#define LCD_HFP 120
#define LCD_VSYNC 5
#define LCD_VBP 12
#define LCD_VFP 25
#define MIPI_DSI_DPI_CLK_MHZ 2
#define MIPI_DSI_LANE_NUM 2
#define MIPI_DSI_LANE_BITRATE_MBPS 500
#define PIN_NUM_LCD_RST 52
static void fl7703ni_init_sequence(esp_lcd_panel_io_handle_t io)
{
ESP_LOGI(TAG,"Sending FL7703NI init sequence");
//SW Reset
ESP_ERROR_CHECK(esp_lcd_panel_io_tx_param(io,0x01,NULL,0));
vTaskDelay(pdMS_TO_TICKS(120));
// 1. Unlock Command List
uint8_tunlock_cmds[]={0xF1,0x12,0x87};
ESP_ERROR_CHECK(esp_lcd_panel_io_tx_param(io,0xB9,unlock_cmds,sizeof(unlock_cmds)));
// 2. SETMIPI (BAh) - 2-Lane Configuration
uint8_tmipi_cfg[]={0x31,0x61,0x06,0xF9,0xFF,0x0A};
ESP_ERROR_CHECK(esp_lcd_panel_io_tx_param(io,0xBA,mipi_cfg,sizeof(mipi_cfg)));
uint8_tcol_data=0x70; // 24-bit color (RGB888)
ESP_ERROR_CHECK(esp_lcd_panel_io_tx_param(io,0x3A,&col_data,1));
//read ID of Display
uint8_tid[3]={0};
esp_err_tret=esp_lcd_panel_io_rx_param(io,0x04,id,3);
ESP_LOGI(TAG,"Display gefunden! ID: %02X%02X%02X",id[0],id[1],id[2]);
//read Mode of Display
uint8_tmode[1]={0};
ret=esp_lcd_panel_io_rx_param(io,0x0A,mode,1);
ESP_LOGI(TAG,"Display gefunden! Mode: %02X",mode[0]);
//read COLMODE config
uint8_tcolmode[1]={0};
ret=esp_lcd_panel_io_rx_param(io,0x0C,colmode,1);
ESP_LOGI(TAG,"COLMODE: %02X",colmode[0]);
//read MADCTR config
uint8_tmadctr[1]={0};
ret=esp_lcd_panel_io_rx_param(io,0x0B,madctr,1);
ESP_LOGI(TAG,"MADCTR: %02X",madctr[0]);
//read RDDIM config
uint8_tRDDIM[1]={0};
ret=esp_lcd_panel_io_rx_param(io,0x0D,RDDIM,1);
ESP_LOGI(TAG,"RDDIM: %02X",RDDIM[0]);
//read RDDSM config
uint8_tRDDSM[1]={0};
ret=esp_lcd_panel_io_rx_param(io,0x0E,RDDSM,1);
ESP_LOGI(TAG,"RDDSM: %02X",RDDSM[0]);
//Sleep Out
ESP_ERROR_CHECK(esp_lcd_panel_io_tx_param(io,0x11,NULL,0));
vTaskDelay(pdMS_TO_TICKS(120));
//Display ON
ESP_ERROR_CHECK(esp_lcd_panel_io_tx_param(io,0x29,NULL,0));
vTaskDelay(pdMS_TO_TICKS(50));
}
static void fill_rgb888(uint8_t *buf, size_t pixels, uint8_t r, uint8_t g, uint8_t b)
{
for(size_ti=0;i<pixels;i++){
buf[i*3+0]=r;
buf[i*3+1]=g;
buf[i*3+2]=b;
}
}
void app_main(void)
{
ESP_LOGI(TAG,"Starting panel init");
// Hardware reset
gpio_set_direction(PIN_NUM_LCD_RST, GPIO_MODE_OUTPUT);
gpio_set_pull_mode(PIN_NUM_LCD_RST, GPIO_PULLUP_ONLY);
gpio_set_level(PIN_NUM_LCD_RST,1);
vTaskDelay(pdMS_TO_TICKS(120));
gpio_set_level(PIN_NUM_LCD_RST,0);
vTaskDelay(pdMS_TO_TICKS(120));
gpio_set_level(PIN_NUM_LCD_RST,1);
ESP_LOGI(TAG,"Hardware reset done on GPIO %d",PIN_NUM_LCD_RST);
vTaskDelay(pdMS_TO_TICKS(120));
esp_ldo_channel_handle_tldo_mipi_phy=NULL;
esp_ldo_channel_config_tldo_cfg={
.chan_id = 3,
.voltage_mv = 2500,
};
ESP_ERROR_CHECK(esp_ldo_acquire_channel(&ldo_cfg,&ldo_mipi_phy));
esp_lcd_dsi_bus_handle_tmipi_dsi_bus=NULL;
esp_lcd_dsi_bus_config_tbus_config={
.bus_id = 0,
.num_data_lanes = MIPI_DSI_LANE_NUM,
.phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT,
.lane_bit_rate_mbps = MIPI_DSI_LANE_BITRATE_MBPS,
};
ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config,&mipi_dsi_bus));
ESP_LOGI(TAG,"DSI bus created");
esp_lcd_panel_io_handle_tmipi_dbi_io=NULL;
esp_lcd_dbi_io_config_tdbi_config={
.virtual_channel = 0,
.lcd_cmd_bits = 8,
.lcd_param_bits = 8,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus,&dbi_config,&mipi_dbi_io));
ESP_LOGI(TAG,"DBI IO created");
esp_lcd_panel_handle_tmipi_dpi_panel=NULL;
esp_lcd_dpi_panel_config_tdpi_config={
.virtual_channel = 0,
.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT,
.dpi_clock_freq_mhz = MIPI_DSI_DPI_CLK_MHZ,
.in_color_format = LCD_COLOR_FMT_RGB888,
.video_timing = {
.h_size = LCD_H_RES,
.v_size = LCD_V_RES,
.hsync_back_porch = LCD_HBP,
.hsync_pulse_width = LCD_HSYNC,
.hsync_front_porch = LCD_HFP,
.vsync_back_porch = LCD_VBP,
.vsync_pulse_width = LCD_VSYNC,
.vsync_front_porch = LCD_VFP,
},
.flags.use_dma2d = true,
.num_fbs = 1,
};
ESP_ERROR_CHECK(esp_lcd_new_panel_dpi(mipi_dsi_bus,&dpi_config,&mipi_dpi_panel));
ESP_LOGI(TAG,"DPI panel created");
ESP_ERROR_CHECK(esp_lcd_panel_init(mipi_dpi_panel));
ESP_LOGI(TAG,"Panel init done");
fl7703ni_init_sequence(mipi_dbi_io);
uint8_t*fb=heap_caps_malloc(LCD_H_RES*LCD_V_RES*3, MALLOC_CAP_DMA | MALLOC_CAP_SPIRAM);
if(fb==NULL){
ESP_LOGE(TAG,"Failed to allocate framebuffer");
return;
}
ESP_LOGI(TAG,"Framebuffer allocated");
while(1){
ESP_LOGI(TAG,"Fill RED");
fill_rgb888(fb,LCD_H_RES*LCD_V_RES,0xFF,0x00,0x00);
ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(mipi_dpi_panel,0,0,LCD_H_RES,LCD_V_RES,fb));
vTaskDelay(pdMS_TO_TICKS(2000));
}
}
0
-
The issue was addressed over a call and email.
It was a hardware issue which was resolved after swapping a bad jumper with a good one.
0
Please sign in to leave a comment.
Comments
1 comment