我使用F429 的FMC 驱动 原子的7寸液晶屏 。为什么 清屏 各种颜 {MOD}都能全屏刷新。 显示图片或是显示文字都会中间一部分消失了 ?甚至显示的部分还严重缺 {MOD}。。
这个屏和代码在 F407芯片上都工作正常
[mw_shl_code=c,true]初始化lcd 函数 [/mw_shl_code]
[mw_shl_code=c,true]//初始化lcd
//该初始化函数可以初始化各种ILI93XX液晶,但是其他函数是基于ILI9320的!!!
//在其他型号的驱动芯片上没有测试!
void LCD_Init(void)
{
vu32 i=0;
GPIO_InitTypeDef GPIO_InitStructure;
FMC_NORSRAMInitTypeDef FMC_NORSRAMInitStructure;
FMC_NORSRAMTimingInitTypeDef readWriteTiming;
FMC_NORSRAMTimingInitTypeDef writeTiming;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG, ENABLE);//使能PB,PD,PE,PF,PG时钟
RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC,ENABLE);//使能FMC时钟
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;//PB15 推挽输出,控制背光
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//普通输出模式
// GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
// GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化 //PB15 推挽输出,控制背光
GPIO_InitStructure.GPIO_Pin = (3<<0)|(3<<4)|(7<<8)|(3<<14);//PD0,1,4,5,8,9,10,14,15 AF OUT
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOD, &GPIO_InitStructure);//初始化
GPIO_InitStructure.GPIO_Pin = (0X1FF<<7);//PE7~15,AF OUT
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOE, &GPIO_InitStructure);//初始化
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;//PF12,FMC_A3
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOF, &GPIO_InitStructure);//初始化
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;//PG12,FMC_NE1
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//复用输出
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//上拉
GPIO_Init(GPIOD, &GPIO_InitStructure);//初始化
GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FMC);//PD0,AF12
GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FMC);//PD1,AF12
GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FMC);//PD15,AF12
GPIO_PinAFConfig(GPIOE,GPIO_PinSource7,GPIO_AF_FMC);//PE7,AF12
GPIO_PinAFConfig(GPIOE,GPIO_PinSource8,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource9,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource10,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource11,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource12,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource13,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource14,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource15,GPIO_AF_FMC);//PE15,AF12
GPIO_PinAFConfig(GPIOF,GPIO_PinSource3,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource7,GPIO_AF_FMC);
readWriteTiming.FMC_AddressSetupTime = 0X6; //地址建立时间(ADDSET)为6个HCLK 1/168M=6ns*6=36ns
readWriteTiming.FMC_AddressHoldTime = 0x00; //地址保持时间(ADDHLD)模式A未用到
readWriteTiming.FMC_DataSetupTime = 0x5; //数据保存时间为6个HCLK =6*6=36ns
readWriteTiming.FMC_BusTurnAroundDuration = 0x00;
readWriteTiming.FMC_CLKDivision = 0x00;
readWriteTiming.FMC_DataLatency = 0x00;
readWriteTiming.FMC_AccessMode = FMC_AccessMode_A; //模式A
writeTiming.FMC_AddressSetupTime = 0x6; //地址建立时间(ADDSET)为6个HCLK =36ns
writeTiming.FMC_AddressHoldTime = 0x00; //地址保持时间(A
writeTiming.FMC_DataSetupTime = 0x5; //数据保存时间为6ns*6个HCLK=36ns
writeTiming.FMC_BusTurnAroundDuration = 0x00;
writeTiming.FMC_CLKDivision = 0x00;
writeTiming.FMC_DataLatency = 0x00;
writeTiming.FMC_AccessMode = FMC_AccessMode_A; //模式A
FMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM1;// 这里我们使用NE1 ,也就对应BTCR[6],[7]。///?
FMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable; // 不复用数据地址
FMC_NORSRAMInitStructure.FMC_MemoryType = FMC_MemoryType_SRAM;// FMC_MemoryType_SRAM; //SRAM
FMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_NORSRAM_MemoryDataWidth_16b;//存储器数据宽度为16bit
FMC_NORSRAMInitStructure.FMC_BurstAccessMode = FMC_BurstAccessMode_Disable;// FMC_BurstAccessMode_Disable;
FMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;
FMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;
FMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;
FMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;
FMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable; // 存储器写使能
FMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;
FMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Enable; // 读写使用不同的时序
FMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;
FMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &readWriteTiming; //读写时序
FMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &writeTiming; //写时序
FMC_NORSRAMInit(&FMC_NORSRAMInitStructure); //初始化FMC配置
FMC_NORSRAMCmd(FMC_Bank1_NORSRAM1, ENABLE); // 使能BANK1
delay_ms(100);
while(i<0X1FFF)
{
if(LCD_RD_DATA()&0x0001)break;//等待控制器准备好
i++;
}
lcddev.setxcmd=LCD_CUR_X; //设置写X坐标指令
lcddev.setycmd=LCD_CUR_Y; //设置写Y坐标指令
lcddev.wramcmd=LCD_PIXELS; //设置写入GRAM的指令
lcddev.width=800; //设置宽度
lcddev.height=480; //设置高度
LCD_Scan_Dir(L2R_U2D); //设置默认扫描方向.
LCD_SetDisplayLayer(0); //显示层为0
LCD_SetOperateLayer(0); //操作层也为0
LCD_EndXSet(799); //x终点坐标为800
LCD_BackLightSet(10); //背光设置为最亮
LCD_Clear(BLACK);
}[/mw_shl_code]
一周热门 更多>