MINI开发板液晶驱动时出现的干涉条纹

2019-10-15 04:11发布

MINI板子,自己参照教程,一步一步写液晶驱动,发现总是有干涉条纹,见图(手机拍的照片,不是很清楚)  正常应该如上图  有问题的驱动
折腾很久了,找不到原因。 下面是初始化代码,没有考虑效率问题,都采用函数调用形式,主要是想搞清楚思路,初始化部分代码基本是照抄的,修改了的部分都加了中文注释: [mw_shl_code=c,true]void LCD_Write_Data(uint16_t data) { LCD_RS_SET; LCD_CS_CLR; LCD_WR_CLR; GPIO_Write(GPIOB, data); LCD_WR_SET; LCD_CS_SET; } void LCD_Write_Cmd(uint16_t data) { LCD_RS_CLR; LCD_CS_CLR; LCD_WR_CLR; GPIO_Write(GPIOB, data); LCD_WR_SET; LCD_CS_SET; } uint16_t LCD_Read_Data() { uint16_t data; GPIOB->CRL = 0x88888888; GPIOB->CRH = 0x88888888; GPIOB->ODR = 0x0000; LCD_RS_SET; LCD_CS_CLR; LCD_RD_CLR; data = GPIO_ReadInputData(GPIOB); LCD_RD_SET; LCD_CS_SET; GPIOB->CRL = 0x33333333; GPIOB->CRH = 0x33333333; GPIOB->ODR = 0xFFFF; return data; } void LCD_Init() { GPIO_InitTypeDef gpio; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE); gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_9 | GPIO_Pin_8 | GPIO_Pin_7 | GPIO_Pin_6; gpio.GPIO_Mode = GPIO_Mode_Out_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &gpio); gpio.GPIO_Pin = GPIO_Pin_All; gpio.GPIO_Mode = GPIO_Mode_Out_PP; gpio.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &gpio); GPIO_SetBits(GPIOB, GPIO_Pin_All); LCD_Write_Cmd(0xD3); LCD_Read_Data(); LCD_Read_Data(); lcd.Id = LCD_Read_Data(); lcd.Id <<= 8; lcd.Id |= LCD_Read_Data(); lcd.Width = 240; lcd.Height = 320; lcd.SetXCmd = 0x2A; lcd.SetYCmd = 0x2B; lcd.WriteGRAMCmd = 0x2C; lcd.Dir = 0; //LCD_Backlight_On(); if(lcd.Id == 0x9341) { LCD_Write_Cmd(0xCF); LCD_Write_Data(0x00); LCD_Write_Data(0xC1); LCD_Write_Data(0X30); LCD_Write_Cmd(0xED); LCD_Write_Data(0x64); LCD_Write_Data(0x03); LCD_Write_Data(0X12); LCD_Write_Data(0X81); LCD_Write_Cmd(0xE8); LCD_Write_Data(0x85); LCD_Write_Data(0x10); LCD_Write_Data(0x7A); LCD_Write_Cmd(0xCB); LCD_Write_Data(0x39); LCD_Write_Data(0x2C); LCD_Write_Data(0x00); LCD_Write_Data(0x34); LCD_Write_Data(0x02); LCD_Write_Cmd(0xF7); LCD_Write_Data(0x20); LCD_Write_Cmd(0xEA); LCD_Write_Data(0x00); LCD_Write_Data(0x00); LCD_Write_Cmd(0xC0); //Power control LCD_Write_Data(0x1B); //VRH[5:0] LCD_Write_Cmd(0xC1); //Power control LCD_Write_Data(0x01); //SAP[2:0];BT[3:0] LCD_Write_Cmd(0xC5); //VCM control LCD_Write_Data(0x30); //3F LCD_Write_Data(0x30); //3C LCD_Write_Cmd(0xC7); //VCM control2 LCD_Write_Data(0XB7); LCD_Write_Cmd(0x36); // Memory Access Control LCD_Write_Data(0x08); //设置显示方向 LCD_Write_Cmd(0x3A); LCD_Write_Data(0x55); LCD_Write_Cmd(0xB1); LCD_Write_Data(0x00); LCD_Write_Data(0x1A); LCD_Write_Cmd(0xB6); // Display Function Control LCD_Write_Data(0x0A); LCD_Write_Data(0xA2); LCD_Write_Cmd(0xF2); // 3Gamma Function Disable LCD_Write_Data(0x00); LCD_Write_Cmd(0x26); //Gamma curve selected LCD_Write_Data(0x01); LCD_Write_Cmd(0xE0); //Set Gamma LCD_Write_Data(0x0F); LCD_Write_Data(0x2A); LCD_Write_Data(0x28); LCD_Write_Data(0x08); LCD_Write_Data(0x0E); LCD_Write_Data(0x08); LCD_Write_Data(0x54); LCD_Write_Data(0XA9); LCD_Write_Data(0x43); LCD_Write_Data(0x0A); LCD_Write_Data(0x0F); LCD_Write_Data(0x00); LCD_Write_Data(0x00); LCD_Write_Data(0x00); LCD_Write_Data(0x00); LCD_Write_Cmd(0XE1); //Set Gamma LCD_Write_Data(0x00); LCD_Write_Data(0x15); LCD_Write_Data(0x17); LCD_Write_Data(0x07); LCD_Write_Data(0x11); LCD_Write_Data(0x06); LCD_Write_Data(0x2B); LCD_Write_Data(0x56); LCD_Write_Data(0x3C); LCD_Write_Data(0x05); LCD_Write_Data(0x10); LCD_Write_Data(0x0F); LCD_Write_Data(0x3F); LCD_Write_Data(0x3F); LCD_Write_Data(0x0F); LCD_Write_Cmd(0x2B); //设置X及Y坐标范围 LCD_Write_Data(0x00); LCD_Write_Data(0x00); LCD_Write_Data((lcd.Height - 1) >> 8); LCD_Write_Data((lcd.Height - 1) & 0xFF); LCD_Write_Cmd(0x2A); LCD_Write_Data(0x00); LCD_Write_Data(0x00); LCD_Write_Data((lcd.Width - 1) >> 8); LCD_Write_Data((lcd.Width - 1) & 0xFF); //LCD_Sleep(); LCD_Exit_Sleep(); //退出休眠模式 //LCD_Display_On(); } } void LCD_Sleep(void) { LCD_Write_Cmd(0x28); delay(20000); LCD_Write_Cmd(0x10); } void LCD_Exit_Sleep(void) { LCD_Write_Cmd(0x11); delay(120000); LCD_Write_Cmd(0x29); } void LCD_Backlight_On(void) { GPIO_SetBits(GPIOC, GPIO_Pin_10); } void LCD_Backlight_Off(void) { GPIO_ResetBits(GPIOC, GPIO_Pin_10); } void LCD_Set_Cusor(uint16_t x, uint16_t y) { if(lcd.Id == 0x9341) { LCD_Write_Cmd(lcd.SetXCmd); LCD_Write_Data(x >> 8); LCD_Write_Data(x & 0xFF); LCD_Write_Cmd(lcd.SetYCmd); LCD_Write_Data(y >> 8); LCD_Write_Data(y & 0xFF); } } void LCD_Draw_Point(uint16_t x, uint16_t y) { LCD_Set_Cusor(x, y); LCD_Write_Cmd(lcd.WriteGRAMCmd); LCD_Write_Data(fgColor); } void LCD_Display_On() { LCD_Write_Cmd(0x29); } void LCD_Display_Off() { LCD_Write_Cmd(0x28); }[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
4条回答
netlhx
1楼-- · 2019-10-15 07:50
找到原因了,初始化没有问题。没有清屏,如果使用LCD_Clear_Scree()清屏后就没有问题了!
ricefat
2楼-- · 2019-10-15 09:38
可能是初始化参数设置不合理导致的,你看看网上其他用相同主控的人的参数
netlhx
3楼-- · 2019-10-15 11:47
 精彩回答 2  元偷偷看……
cao57508
4楼-- · 2019-10-15 16:37
厉害呀

一周热门 更多>