参照原子哥的例程改的ili9486的初始化函数,在自己画的板上运行,ID显示不出来,也没有显示内容,求助啊求助啊。大神们帮我看看函数有没有问题吧
void LCD_Init(void)
{
vu32 i=0;
GPIO_InitTypeDef GPIO_InitStructure;
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
FSMC_NORSRAMTimingInitTypeDef readWriteTiming;
FSMC_NORSRAMTimingInitTypeDef writeTiming;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG, ENABLE);//ê1ÄüPD,PE,PF,PGê±Öó
RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC,ENABLE);//ê1ÄüFSMCê±Öó
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;//PB15 íÆíìêä3ö,¿ØÖƱ31a
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//ÆÕí¨êä3öÄ£ê½
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//éÏà-
GPIO_Init(GPIOB, &GPIO_InitStructure);//3õê¼»ˉ //PB15 íÆíìêä3ö,¿ØÖƱ31a
GPIO_SetBits(GPIOB,GPIO_Pin_15);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_14|GPIO_Pin_15;//PD0,1,4,5,8,9,10,14,15 AF OUT
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//éÏà-
GPIO_Init(GPIOD, &GPIO_InitStructure);//3õê¼»ˉ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15;//PE7~15,AF OUT
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//éÏà-
GPIO_Init(GPIOE, &GPIO_InitStructure);//3õê¼»ˉ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; //LCD_RST
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_Init(GPIOG, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;//PF12,FSMC_A6
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_Init(GPIOD, &GPIO_InitStructure);//3õê¼»ˉ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;//PF12,FSMC_A6
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_Init(GPIOG, &GPIO_InitStructure);//3õê¼»ˉ
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;//PF12,FSMC_A6
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//¸′óÃêä3ö
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_Init(GPIOF, &GPIO_InitStructure);//3õê¼»ˉ
GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FSMC);//PD0,AF12
GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FSMC);//PD1,AF12
GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FSMC);//PD15,AF12
GPIO_PinAFConfig(GPIOE,GPIO_PinSource7,GPIO_AF_FSMC);//PE7,AF12
GPIO_PinAFConfig(GPIOE,GPIO_PinSource8,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource9,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource10,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource11,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource12,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource13,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource14,GPIO_AF_FSMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource15,GPIO_AF_FSMC);//PE15,AF12
GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FSMC);//WR
GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FSMC);//RD
GPIO_PinAFConfig(GPIOF,GPIO_PinSource12,GPIO_AF_FSMC);//RS
GPIO_PinAFConfig(GPIOG,GPIO_PinSource12,GPIO_AF_FSMC);//CS
readWriteTiming.FSMC_AddressSetupTime = 0XF; //μØÖ·½¨á¢ê±¼ä£¨ADDSET£©Îa16¸öHCLK 1/168M=6ns*16=96ns
readWriteTiming.FSMC_AddressHoldTime = 0x00; //μØÖ·±£3Ö걼䣨ADDHLD£©Ä£ê½AÎ′óÃμ½
readWriteTiming.FSMC_DataSetupTime = 60; //êy¾Y±£′æê±¼äÎa60¸öHCLK =6*60=360ns
readWriteTiming.FSMC_BusTurnAroundDuration = 0x00;
readWriteTiming.FSMC_CLKDivision = 0x00;
readWriteTiming.FSMC_DataLatency = 0x00;
readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A; //Ä£ê½A
writeTiming.FSMC_AddressSetupTime =9; //μØÖ·½¨á¢ê±¼ä£¨ADDSET£©Îa9¸öHCLK =54ns
writeTiming.FSMC_AddressHoldTime = 0x00; //μØÖ·±£3Ö걼䣨A
writeTiming.FSMC_DataSetupTime = 8; //êy¾Y±£′æê±¼äÎa6ns*9¸öHCLK=54ns
writeTiming.FSMC_BusTurnAroundDuration = 0x00;
writeTiming.FSMC_CLKDivision = 0x00;
writeTiming.FSMC_DataLatency = 0x00;
writeTiming.FSMC_AccessMode = FSMC_AccessMode_A; //Ä£ê½A
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4;// ÕaàïÎòÃÇê1óÃNE4 £¬ò2¾í¶Ôó|BTCR[6],[7]¡£
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; // 2»¸′óÃêy¾YμØÖ·
FSMC_NORSRAMInitStructure.FSMC_MemoryType =FSMC_MemoryType_SRAM;// FSMC_MemoryType_SRAM; //SRAM
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//′æ′¢Æ÷êy¾Y¿í¶èÎa16bit
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode =FSMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait=FSMC_AsynchronousWait_Disable;
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; // ′æ′¢Æ÷D′ê1Äü
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; // ¶áD′ê1óÃ2»í¬μÄê±Dò
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &readWriteTiming; //¶áD′ê±Dò
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &writeTiming; //D′ê±Dò
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //3õê¼»ˉFSMCÅäÖÃ
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE); // ê1ÄüBANK1
delay_ms(50); // delay 50 ms
LCD_WriteReg(0x0000,0x0001);
delay_ms(50); // delay 50 ms
lcddev.id = LCD_ReadReg(0x0000);
LCD_WR_REG(0XD3); //读取ID
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id=LCD_RD_DATA();
lcddev.id<<=8;
lcddev.id|=LCD_RD_DATA();
LCD_WR_REG(0x11); //参数初始化
delay_ms(120);
LCD_WR_REG(0x13);
delay_ms(120);
LCD_WR_REG(0XF9);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x08);
LCD_WR_REG(0xC0);
LCD_WR_DATA(0x19);//VREG1OUT POSITIVE
LCD_WR_DATA(0x1a);//VREG2OUT NEGATIVE
LCD_WR_REG(0xC1);
LCD_WR_DATA(0x45);//VGH,VGL VGH>=14V.
LCD_WR_DATA(0x00);
LCD_WR_REG(0xC2);
LCD_WR_DATA(0x33);
LCD_WR_REG(0XC5);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x28);//VCM_REG[7:0]. <=0X80.
LCD_WR_REG(0xB1);
LCD_WR_DATA(0xB0);//0XB0 =70HZ, <=0XB0.
LCD_WR_DATA(0x11);
LCD_WR_REG(0xB4);
LCD_WR_DATA(0x02); //2
LCD_WR_REG(0xB6);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x42);//0 GS SS SM ISC[3:0];
LCD_WR_DATA(0x3B);
LCD_WR_REG(0xB7);
LCD_WR_DATA(0x07);
LCD_WR_REG(0xE0);
LCD_WR_DATA(0x1F);
LCD_WR_DATA(0x25);
LCD_WR_DATA(0x22);
LCD_WR_DATA(0x0B);
LCD_WR_DATA(0x06);
LCD_WR_DATA(0x0A);
LCD_WR_DATA(0x4E);
LCD_WR_DATA(0xC6);
LCD_WR_DATA(0x39);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x00);
LCD_WR_REG(0XE1);
LCD_WR_DATA(0x1F);
LCD_WR_DATA(0x3F);
LCD_WR_DATA(0x3F);
LCD_WR_DATA(0x0F);
LCD_WR_DATA(0x1F);
LCD_WR_DATA(0x0F);
LCD_WR_DATA(0x46);
LCD_WR_DATA(0x49);
LCD_WR_DATA(0x31);
LCD_WR_DATA(0x05);
LCD_WR_DATA(0x09);
LCD_WR_DATA(0x03);
LCD_WR_DATA(0x1C);
LCD_WR_DATA(0x1A);
LCD_WR_DATA(0x00);
LCD_WR_REG(0XF1);
LCD_WR_DATA(0x36);
LCD_WR_DATA(0x04);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x3C);
LCD_WR_DATA(0x0F);
LCD_WR_DATA(0x0F);
LCD_WR_DATA(0xA4);
LCD_WR_DATA(0x02);
LCD_WR_REG(0XF2);
LCD_WR_DATA(0x18);
LCD_WR_DATA(0xA3);
LCD_WR_DATA(0x12);
LCD_WR_DATA(0x02);
LCD_WR_DATA(0x32);
LCD_WR_DATA(0x12);
LCD_WR_DATA(0xFF);
LCD_WR_DATA(0x32);
LCD_WR_DATA(0x00);
LCD_WR_REG(0XF4);
LCD_WR_DATA(0x40);
LCD_WR_DATA(0x00);
LCD_WR_DATA(0x08);
LCD_WR_DATA(0x91);
LCD_WR_DATA(0x04);
LCD_WR_REG(0XF8);
LCD_WR_DATA(0x21);
LCD_WR_DATA(0x04);
LCD_WR_REG(0x36);
LCD_WR_DATA(0x48);
LCD_WR_REG(0x3A);
LCD_WR_DATA(0x55);
LCD_WR_REG(0x11);
delay_ms(120);
LCD_WR_REG(0x29);
LCD_WR_REG(0x002C);
LCD_Display_Dir(0);
LCD_LED=1;
LCD_Clear(RED);
}
一周热门 更多>