论坛新人,找了个看似合理的地方放个求答贴,如有冒犯,请告知。
1.未解决问题,想问问各位大哥有没有点子解决
2.问题现象:
//显示了24大写英文字符和单个字符不对;
//观察和个人猜测:
//显示字符和刷单色不对,看起来像是显示的字符和刷的单色像堆箱子一样平行于长边,垂直叠在一起了;
//通过设置横竖屏显示字符,发现屏幕显示,不能改变条纹重叠的方向,可以改变字符显示方向,比如横屏是横向显示,竖屏是纵向,有图;
24字符
单字符 I
//猜测:图中红色方框是屏幕,绿色方框是实际显示的位置,屏幕上显示24英文只显示一串ABCDEFGHIJKLMNO就显示满了,但实际上还有一半没显示到,并且是沿着箭头方向一直重叠显示,导致显示成一坨去了,但现在不知道改哪里。
3.推测是LTDC的参数或屏幕寄存器初始化不对,但因为不知道具体是什么寄存器和写入的是什么数据,在下附上相关文件,希望有大哥能指点一下小弟迷津,也可以给一份这个寄存器含义表让小弟自个去琢磨,谢谢!
4.备注
///////////////////////显示字符函数////////////////////////////
/**
* @brief 显示字符串
* @param x,y : 起始坐标
* @param width,height: 区域大小
* @param size : 选择字体 12/16/24/32
* @param p : 字符串首地址
* @param color : 字体颜色
* @retval 无
*/
//24字符显示
lcd_show_string(10, 40, 240, 32, 32, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", BLACK);
//I字符显示
lcd_show_string(10, 40, 240, 32, 32, "I", BLACK);
///////////////////////部分代码////////////////////////////
/**
* @brief LTDC初始化函数
* @param 无
* @retval 无
*/
void ltdc_init(void) {
uint16_t ltdcid = 0;
ltdcid = ltdc_panelid_read(); /* 读取LCD面板ID */
//另一块正常
lcdltdc.pwidth = 480; /* 面板宽度,单位:像素 */
lcdltdc.pheight = 854; /* 面板高度,单位:像素 */
lcdltdc.hbp = 30; /* 水平后廊 */
lcdltdc.hfp = 12; /* 水平前廊 */
lcdltdc.hsw = 6; /* 水平同步宽度 */
lcdltdc.vbp = 30; /* 垂直后廊 */
lcdltdc.vfp = 12; /* 垂直前廊 */
lcdltdc.vsw = 1; /* 垂直同步宽度 */
ltdc_clk_set(396, 3, RCC_PLLSAIDIVR_2); /* 设置像素时钟 */
lcddev.width = lcdltdc.pwidth; /* 设置lcddev的宽度参数 */
lcddev.height = lcdltdc.pheight; /* 设置lcddev的宽度参数 */
///* 定义颜色像素格式,用RGB565 */
//#define LTDC_PIXFORMAT LTDC_PIXFORMAT_RGB565
#if LTDC_PIXFORMAT == LTDC_PIXFORMAT_ARGB8888 || LTDC_PIXFORMAT == LTDC_PIXFORMAT_RGB888
g_ltdc_framebuf[0] = (uint32_t*) <dc_lcd_framebuf;
lcdltdc.pixsize = 4; /* 每个像素占4个字节 */
#else
g_ltdc_framebuf[0] = (uint32_t*)<dc_lcd_framebuf;
// g_ltdc_framebuf[1] = (uint32_t*)<dc_lcd_framebuf1;
lcdltdc.pixsize = 2; /* 每个像素占2个字节 */
#endif
/* LTDC配置 */
g_ltdc_handle.Instance = LTDC;
g_ltdc_handle.Init.HSPolarity = LTDC_HSPOLARITY_AL; /* 水平同步极性 */
g_ltdc_handle.Init.VSPolarity = LTDC_VSPOLARITY_AL; /* 垂直同步极性 */
g_ltdc_handle.Init.DEPolarity = LTDC_DEPOLARITY_AL; /* 数据使能极性 */
g_ltdc_handle.State = HAL_LTDC_STATE_RESET;
g_ltdc_handle.Init.PCPolarity = LTDC_PCPOLARITY_IPC; /* 像素时钟极性 */
g_ltdc_handle.Init.HorizontalSync = lcdltdc.hsw - 1; /* 水平同步宽度 */
g_ltdc_handle.Init.VerticalSync = lcdltdc.vsw - 1; /* 垂直同步宽度 */
g_ltdc_handle.Init.AccumulatedHBP = lcdltdc.hsw + lcdltdc.hbp - 1; /* 水平同步后沿宽度 */
g_ltdc_handle.Init.AccumulatedVBP = lcdltdc.vsw + lcdltdc.vbp - 1; /* 垂直同步后沿高度 */
g_ltdc_handle.Init.AccumulatedActiveW = lcdltdc.hsw + lcdltdc.hbp + lcdltdc.pwidth - 1; /* 有效宽度 */
g_ltdc_handle.Init.AccumulatedActiveH = lcdltdc.vsw + lcdltdc.vbp + lcdltdc.pheight - 1; /* 有效高度 */
g_ltdc_handle.Init.TotalWidth = lcdltdc.hsw + lcdltdc.hbp + lcdltdc.pwidth + lcdltdc.hfp - 1; /* 总宽度 */
g_ltdc_handle.Init.TotalHeigh = lcdltdc.vsw + lcdltdc.vbp + lcdltdc.pheight + lcdltdc.vfp - 1; /* 总高度 */
g_ltdc_handle.Init.Backcolor.Red = 0; /* 屏幕背景层红色部分 */
g_ltdc_handle.Init.Backcolor.Green = 0; /* 屏幕背景层绿色部分 */
g_ltdc_handle.Init.Backcolor.Blue = 0; /* 屏幕背景色蓝色部分 */
HAL_LTDC_Init(&g_ltdc_handle);
/* 层配置 */
ltdc_layer_parameter_config(0, (uint32_t)g_ltdc_framebuf[0], LTDC_PIXFORMAT, 255, 0, 6, 7, 0X000000);/* 第一层参数配置 */
ltdc_layer_window_config(0, 0, 0, lcdltdc.pwidth, lcdltdc.pheight); /* 层窗口配置,以LCD面板坐标系为基准,不要随便修改! */
//ltdc_layer_parameter_config(1,(uint32_t)g_ltdc_framebuf[1],LTDC_PIXFORMAT,127,0,6,7,0X000000); /* 层参数配置 */
//ltdc_layer_window_config(1,0,0,lcdltdc.pwidth,lcdltdc.pheight); /* 层窗口配置,以LCD面板坐标系为基准,不要随便修改! */
ltdc_display_dir(0); /* 默认竖屏 */
ltdc_select_layer(0); /* 选择第1层 */
LTDC_BL(1); /* 点亮背光 */
ltdc_clear(0XFFFFFFFF); /* 清屏 */
}
/**
* @brief 初始化LCD
* @note 该初始化函数可以初始化各种型号的LCD(详见本.c文件最前面的描述)
* @param 无
* @retval 无
*/
void lcd_init(void) {
LCD_GPIO_Init();
FMC_NORSRAM_TimingTypeDef fmc_read_handle;
FMC_NORSRAM_TimingTypeDef fmc_write_handle;
g_sram_handle.Instance = FMC_NORSRAM_DEVICE;
g_sram_handle.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
g_sram_handle.Init.NSBank = FMC_NORSRAM_BANK1; /* 使用NE1 */
g_sram_handle.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; /* 地址/数据线不复用 */
g_sram_handle.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; /* SRAM */
g_sram_handle.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16; /* 16位数据宽度 */
g_sram_handle.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE; /* 是否使能突发访问,仅对同步突发存储器有效,此处未用到 */
g_sram_handle.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; /* 等待信号的极性,仅在突发模式访问下有用*/
g_sram_handle.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; /* 存储器是在等待周期之前的一个时钟周期还是等待周期期间使能NWAIT */
g_sram_handle.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE; /* 存储器写使能 */
g_sram_handle.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; /* 等待使能位,此处未用到 */
g_sram_handle.Init.ExtendedMode = FMC_EXTENDED_MODE_ENABLE; /* 读写使用不同的时序 */
g_sram_handle.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE; /* 是否使能同步传输模式下的等待信号,此处未用到 */
g_sram_handle.Init.WriteBurst = FMC_WRITE_BURST_DISABLE; /* 禁止突发写 */
g_sram_handle.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ASYNC;
/* FMC读时序控制寄存器 */
fmc_read_handle.AddressSetupTime = 0x0F; /* 地址建立时间(ADDSET)为15个HCLK 1/192M = 5.2ns * 15 = 78ns */
fmc_read_handle.AddressHoldTime = 0x00;
fmc_read_handle.DataSetupTime = 0x46; /* 数据保存时间(DATAST)为70个HCLK = 5.2ns * 70 = 364ns */
/* 因为液晶驱动IC的读数据的时候,速度不能太快,尤其是个别奇葩芯片 */
fmc_read_handle.AccessMode = FMC_ACCESS_MODE_A; /* 模式A */
/* FMC写时序控制寄存器 */
fmc_write_handle.AddressSetupTime = 0x0F; /* 地址建立时间(ADDSET)为15个HCLK = 5.2ns * 15 = 78ns */
fmc_write_handle.AddressHoldTime = 0x00;
fmc_write_handle.DataSetupTime = 0x0F; /* 数据保存时间(DATAST)为15个HCLK = 5.2ns * 15 = 78ns */
fmc_write_handle.AccessMode = FMC_ACCESS_MODE_A; /* 模式A */
HAL_SRAM_Init(&g_sram_handle, &fmc_read_handle, &fmc_write_handle);
delay_ms(50);
/* 特别注意, 如果在main函数里面屏蔽串口1初始化, 则会卡死在printf
* 里面(卡死在f_putc函数), 所以, 必须初始化串口1, 或者屏蔽掉下面
* 这行 printf 语句 !!!!!!!
*/
// printf("LCD ID:%x\r\n", lcddev.id); /* 打印LCD ID */
LCD_REGDATA_init();
/* 由于不同屏幕的写时序不同,这里的时序可以根据自己的屏幕进行修改
(若插上长排线对时序也会有影响,需要自己根据情况修改) */
/* 初始化完成以后,提速 */
if (1) { /* 如果是这几个IC, 则设置WR时序为最快 */
/* 重新配置写时序控制寄存器的时序 */
fmc_write_handle.AddressSetupTime = 4;
fmc_write_handle.DataSetupTime = 4;
FMC_NORSRAM_Extended_Timing_Init(g_sram_handle.Extended, &fmc_write_handle, g_sram_handle.Init.NSBank, g_sram_handle.Init.ExtendedMode);
}
lcd_display_dir(1); /* 0默认为竖屏 */
LCD_BL(1); /* 点亮背光 */
lcd_clear(WHITE);
}
void LCD_REGDATA_init(void) {
SPI_LCD_DC(1);
SPI_LCD_CS(1);
SPI_WR_REG(0xFF);
SPI_WR_DATA(0x77);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x13);
SPI_WR_REG(0xEF);
SPI_WR_DATA(0x08);
/*-------------------------------Bank0 Setting--------------------------------*/
/*--------------------------Display Control setting---------------------------*/
SPI_WR_REG(0xFF);
SPI_WR_DATA(0x77);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x10);
SPI_WR_REG(0xC0);
SPI_WR_DATA(0xE9);
SPI_WR_DATA(0x03);
SPI_WR_REG(0xC1);
SPI_WR_DATA(0x11);
SPI_WR_DATA(0x02);
SPI_WR_REG(0xC2);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x08);
SPI_WR_REG(0xCC);
SPI_WR_DATA(0x18);
/*---------------------------Gamma Cluster Setting----------------------------*/
SPI_WR_REG(0xB0);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x0D);
SPI_WR_DATA(0x14);
SPI_WR_DATA(0x0D);
SPI_WR_DATA(0x10);
SPI_WR_DATA(0x05);
SPI_WR_DATA(0x02);
SPI_WR_DATA(0x08);
SPI_WR_DATA(0x08);
SPI_WR_DATA(0x1E);
SPI_WR_DATA(0x05);
SPI_WR_DATA(0x13);
SPI_WR_DATA(0x11);
SPI_WR_DATA(0xA3);
SPI_WR_DATA(0x29);
SPI_WR_DATA(0x18);
SPI_WR_REG(0xB1);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x0C);
SPI_WR_DATA(0x14);
SPI_WR_DATA(0x0C);
SPI_WR_DATA(0x10);
SPI_WR_DATA(0x05);
SPI_WR_DATA(0x03);
SPI_WR_DATA(0x08);
SPI_WR_DATA(0x07);
SPI_WR_DATA(0x20);
SPI_WR_DATA(0x05);
SPI_WR_DATA(0x13);
SPI_WR_DATA(0x11);
SPI_WR_DATA(0xA4);
SPI_WR_DATA(0x29);
SPI_WR_DATA(0x18);
/*-----------------------------End Gamma Setting------------------------------*/
/*------------------------End Display Control setting-------------------------*/
/*-----------------------------Bank0 Setting End-----------------------------*/
/*-------------------------------Bank1 Setting--------------------------------*/
/*--------------------- Power Control Registers Initial ----------------------*/
SPI_WR_REG(0xFF);
SPI_WR_DATA(0x77);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x11);
SPI_WR_REG(0xB0);
SPI_WR_DATA(0x6C);
/*--------------------------------Vcom Setting--------------------------------*/
SPI_WR_REG(0xB1);
SPI_WR_DATA(0x43);
/*------------------------------End Vcom Setting------------------------------*/
SPI_WR_REG(0xB2);
SPI_WR_DATA(0x87);
SPI_WR_REG(0xB3);
SPI_WR_DATA(0x80);
SPI_WR_REG(0xB5);
SPI_WR_DATA(0x47);
SPI_WR_REG(0xB7);
SPI_WR_DATA(0x85);
SPI_WR_REG(0xB8);
SPI_WR_DATA(0x20);
SPI_WR_REG(0xB9);
SPI_WR_DATA(0x10);
SPI_WR_REG(0xC1);
SPI_WR_DATA(0x78);
SPI_WR_REG(0xC2);
SPI_WR_DATA(0x78);
SPI_WR_REG(0xD0);
SPI_WR_DATA(0x88);
/*--------------------End Power Control Registers Initial --------------------*/
delay_ms(100);
/*--------------------------------GIP Setting---------------------------------*/
SPI_WR_REG(0xE0);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x02);
SPI_WR_REG(0xE1);
SPI_WR_DATA(0x08);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x0A);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x07);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x09);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x33);
SPI_WR_DATA(0x33);
SPI_WR_REG(0xE2);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_REG(0xE3);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x33);
SPI_WR_DATA(0x33);
SPI_WR_REG(0xE4);
SPI_WR_DATA(0x44);
SPI_WR_DATA(0x44);
SPI_WR_REG(0xE5);
SPI_WR_DATA(0x0E);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0x10);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0x0A);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0x0C);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_REG(0xE6);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x33);
SPI_WR_DATA(0x33);
SPI_WR_REG(0xE7);
SPI_WR_DATA(0x44);
SPI_WR_DATA(0x44);
SPI_WR_REG(0xE8);
SPI_WR_DATA(0x0D);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0x0F);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0x09);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0x0B);
SPI_WR_DATA(0x60);
SPI_WR_DATA(0xA0);
SPI_WR_DATA(0xA0);
SPI_WR_REG(0xEB);
SPI_WR_DATA(0x02);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0xE4);
SPI_WR_DATA(0xE4);
SPI_WR_DATA(0x44);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x40);
SPI_WR_REG(0xEC);
SPI_WR_DATA(0x02);
SPI_WR_DATA(0x01);
SPI_WR_REG(0xED);
SPI_WR_DATA(0xAB);
SPI_WR_DATA(0x89);
SPI_WR_DATA(0x76);
SPI_WR_DATA(0x54);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0xFF);
SPI_WR_DATA(0xFF);
SPI_WR_DATA(0xFF);
SPI_WR_DATA(0xFF);
SPI_WR_DATA(0xFF);
SPI_WR_DATA(0xFF);
SPI_WR_DATA(0x10);
SPI_WR_DATA(0x45);
SPI_WR_DATA(0x67);
SPI_WR_DATA(0x98);
SPI_WR_DATA(0xBA);
SPI_WR_REG(0xEF);
SPI_WR_DATA(0x08);
SPI_WR_DATA(0x08);
SPI_WR_DATA(0x08);
SPI_WR_DATA(0x45);
SPI_WR_DATA(0x3F);
SPI_WR_DATA(0x54);
SPI_WR_REG(0xFF);
SPI_WR_DATA(0x77);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x13);
SPI_WR_REG(0xE8);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x0E);
/*------------------------------End GIP Setting-------------------------------*/
/*-------------------- Power Control Registers Initial End--------------------*/
/*-------------------------------Bank1 Setting--------------------------------*/
SPI_WR_REG(0xFF);
SPI_WR_DATA(0x77);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_REG(0x11);
delay_ms(120);
SPI_WR_REG(0xFF);
SPI_WR_DATA(0x77);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x13);
SPI_WR_REG(0xE8);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x0C);
delay_ms(10);
SPI_WR_REG(0xE8);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_REG(0xFF);
SPI_WR_DATA(0x77);
SPI_WR_DATA(0x01);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_DATA(0x00);
SPI_WR_REG(0x29);
SPI_WR_REG(0x3a);
SPI_WR_DATA(0x77);
SPI_WR_REG(0x36);
SPI_WR_DATA(0x08);
delay_ms(20);
}
///////////////////////////////////////////////////
最近编辑记录 Open (2024-12-02 13:16:42)
离线
ST7701S没有GRAM吧,都是从STM32 DDR 刷到ST7701S吗?
离线
ST7701S没有GRAM吧,都是从STM32 DDR 刷到ST7701S吗?
你好,我不清楚ST7701S有没有GRAM,现在刷屏用的LTDC RGB565放SDRAM一直刷屏幕里的。
离线
刷纯色正常对吧?
离线
刷纯色正常对吧?
这个显示效果看起来是有问题的,看起来像是没有正确判断水平同步,但简单调节水平同步数值也没有明显效果。
离线
每行可能是 480*4个字节,你现在是多少?
离线
每行可能是 480*4个字节,你现在是多少?
你好,之前是2字节,我刚刚修改了字节,仍是没有明显变化(我刚刚往帖子里加入了代码页,大哥方便看看吗)
离线