|
我使用ATMEGA8来驱动ILI9327的液晶,使用16位数据线的低8位驱动。高8位全部拉低。在论坛中找到一些别的MCU的代码,但是屏幕一直没有反应,请做过的指点一下。多谢。
void DelayMs(unsigned int Delay)
{
unsigned int s,i;
for(s=Delay;s>0;s--)
for(i=0;i<8125;i++)
_NOP();
}
void ILI9327_CMD(unsigned char Cmd)
{
Clr_Bit(PORTD,7);
Clr_Bit(PORTD,5);
PORTB = Cmd;
DelayMs(5);
Clr_Bit(PORTD,6);
DelayMs(5);
Set_Bit(PORTD,6);
DelayMs(5);
Set_Bit(PORTD,7);
}
void ILI9327_Write(unsigned char Data)
{
Clr_Bit(PORTD,7);
Set_Bit(PORTC,5);
PORTB = Data;
DelayMs(5);
Clr_Bit(PORTD,6);
DelayMs(5);
Set_Bit(PORTD,6);
DelayMs(5);
Set_Bit(PORTD,7);
}
unsigned char ILI9327_Read(void)
{
return 0;
}
void LCD_Clear(unsigned int Data)
{
unsigned int i,s;
ILI9327_CMD(0x2c);
Set_Bit(PORTD,5);
Clr_Bit(PORTD,7);
for(i=0;i<200;i++)
for(s=0;s<400;s++)
ILI9327_Write(Data);
Set_Bit(PORTD,7);
}
void ILI9327_Init(void)
{
Set_Bit(PORTC,4);//复位置高
DelayMs(5);
Clr_Bit(PORTC,4);//复位拉低
DelayMs(10);
Set_Bit(PORTC,4);//复位置高
DelayMs(50);
ILI9327_CMD(0xe9);//while(1);
ILI9327_Write(0x20); //Exit_invert_mode
ILI9327_CMD(0x11); //Exit_sleep_mode
DelayMs(100);
ILI9327_CMD(0xd1);
ILI9327_Write(0x00);
ILI9327_Write(0x71);
ILI9327_Write(0x19);
ILI9327_CMD(0xd0);
ILI9327_Write(0x07);
ILI9327_Write(0x01);
ILI9327_Write(0x08);
ILI9327_CMD(0x36); //Set_address_mode 显示方向
ILI9327_Write(0x48); //从上往下 从右向左
ILI9327_CMD(0x3a); //Set_pixel_format
ILI9327_Write(0x05); //DBI 65K colors
ILI9327_CMD(0xC1);
ILI9327_Write(0x10);
ILI9327_Write(0x10);
ILI9327_Write(0x02);
ILI9327_Write(0x02);
ILI9327_CMD(0xC0);//Set Default Gamma
ILI9327_Write(0x00);
ILI9327_Write(0x35);
ILI9327_Write(0x00);
ILI9327_Write(0x00);
ILI9327_Write(0x01);
ILI9327_Write(0x02);
ILI9327_CMD(0xC5); //Set frame rate
ILI9327_Write(0x04);
ILI9327_CMD(0xD2); //power setting
ILI9327_Write(0x01);
ILI9327_Write(0x44);
ILI9327_CMD(0xC8); //Set Gamma
ILI9327_Write(0x04);
ILI9327_Write(0x67);
ILI9327_Write(0x35);
ILI9327_Write(0x04);
ILI9327_Write(0x08);
ILI9327_Write(0x06);
ILI9327_Write(0x24);
ILI9327_Write(0x01);
ILI9327_Write(0x37);
ILI9327_Write(0x40);
ILI9327_Write(0x03);
ILI9327_Write(0x10);
ILI9327_Write(0x08);
ILI9327_Write(0x80);
ILI9327_Write(0x00);
ILI9327_CMD(0x2A);//Set_column_address
ILI9327_Write(0x00);
ILI9327_Write(0x00); //x1 = 0
ILI9327_Write(0x00);
ILI9327_Write(0xef); //x2 = 239
ILI9327_CMD(0x2b); //Set_page_address
ILI9327_Write(0x00);
ILI9327_Write(0x00); //y1 = 0
ILI9327_Write(0x01);
ILI9327_Write(0x8f); //y2 = 399
ILI9327_CMD(0x29); //display on
ILI9327_CMD(0x2C); //write_memory_start
Set_Bit(PORTD,7);
DelayMs(10);
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|