最近在学习TFT显示,看了原子哥的源代码和手册,然后我试做用库函数的方法来移植,结果驱动不上啊,我用的驱动程序是从原子哥那个程序直接考过来的,而且相关的两个函数也是直接考过来的,可是就是驱动不上,不知道问题出在哪里,看哪个代码都看了很多遍,基本上都看懂了,可是问题还是不知道出在哪里,在线调试的时候,发现原子哥那个程序读出屏的驱动型号为B505而不是9320,不知道为什么???????现在把我初始化屏的程序附上我修改的部分:
//初始化LCD
void LCD_Init(void)
{
//初始化端口
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
//初始化数据口
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
delay_ms(50); // delay 50 ms
LCD_WriteReg(0x0000,0x0001);
delay_ms(50); // delay 50 ms
DeviceCode = LCD_ReadReg(0x0000);
if(DeviceCode==0x9325||DeviceCode==0x9328)//ILI9325
{
.....................//这里面的代码都没有改过
}
LCD_LED_SET;//点亮背光
//LCD_Clear(BLACK);
}
读寄存器的程序为:
//读寄存器
u16 LCD_ReadReg(u8 LCD_Reg)
{
u16 t;
//GPIO初始化参数
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
LCD_RS_SET;
LCD_CS_CLR;
//读取数据(读寄存器时,并不需要读2次)
LCD_RD_CLR;
delay_ms(1);//FOR 8989,延时5us
LCD_RD_SET;
t=DATAIN;
LCD_CS_SET;
//重新初始化端口
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
return t;
}
其他的都没有改啊!希望大家帮帮我,这个事情弄的我很郁闷啊! |