Discussion in "8051 Discussion Forum" started by    nordic    Mar 27, 2014.
Thu Mar 27 2014, 02:47 pm
#1
Hello, could someone help me with the code for TFT LCD ILI9481. My microcontroller is C8051f022. When I start the program the LCD do nothing. This is my first program with TFT,
This is my code
#include "c8051F020.h"
/* CS is to ground */

sbit WR = P0^5;	// Write signal pin
sbit RD	= P0^4;	// Read signal pin
sbit RS	= P0^6;	// Register Select signal pin
#define RESET   P7	// Reset signal pin
#define BUS_16 // 16 bit mode
#define LCD_DATA_PORTH P5 // high eight data ports, using only high eight 8-bit mode DB9 - DB15
#define LCD_DATA_PORTL P4 // low eight data ports DB0 - DB8
sbit LED1 = P3^1;
sbit LED2 = P3^2;
sbit LED3 = P3^3;

void delay_20ms(void)
{
		TMOD &=0xF0;
		TMOD |=0x01;

		ET0=1;
		TH0=0xBE;
		TL0=0xE6;
		TR0=1;
		while(TF0==0);
		ET0=0;
		TF0=0;
	
}


void delay_50ms(void)
{
		TMOD &=0xF0;
		TMOD |=0x01;

		ET0=1;
		TH0=0x5D;
		TL0=0x3E;
		TR0=1;
		while(TF0==0);
		ET0=0;
		TF0=0;
	
}


void Port_IO_Init()
{

    P3MDOUT   = 0x0E;
    XBR2      = 0x40;
}

void lcd_write_bus (char VH, char VL) // write data in parallel function
{
	LCD_DATA_PORTH=VH;	
	LCD_DATA_PORTL=VL;		
	WR=0;
	WR=1; 

}


void LCD_ILI9481_CMD (char VH, char VL) // send command
{
	RS=0;
	lcd_write_bus(VH, VL);
}

void LCD_ILI9481_INDEX(char VH,char VL)	// send data
{
    RS=1;
	lcd_write_bus(VH,VL);
}


void ILI9481_CPT_Initial_Code(void)
{

RESET = 1;
delay_50ms();
RESET = 0;
delay_50ms();
RESET = 1;
WR = 1;
RD = 1;
delay_50ms();
delay_50ms();

LCD_ILI9481_CMD(0x00, 0x11); // Exit sleep mode
delay_20ms();

LCD_ILI9481_CMD(0x00, 0xD0);    //Power setting
LCD_ILI9481_INDEX(0x00,0x07);  // 1xVci
LCD_ILI9481_INDEX(0x00,0x42);
LCD_ILI9481_INDEX(0x00,0x18);

LCD_ILI9481_CMD(0x00,0xD1);	 // Vcom control
LCD_ILI9481_INDEX(0x00,0x00);
LCD_ILI9481_INDEX(0x00,0x07);//07
LCD_ILI9481_INDEX(0x00,0x10);

LCD_ILI9481_CMD(0x00,0xD2);	// Power setting for normal mode 
LCD_ILI9481_INDEX(0x00,0x01);
LCD_ILI9481_INDEX(0x00,0x02);

LCD_ILI9481_CMD(0x00,0xC0);	// Panel driving settings
LCD_ILI9481_INDEX(0x00,0x10);
LCD_ILI9481_INDEX(0x00,0x3B);
LCD_ILI9481_INDEX(0x00,0x00);
LCD_ILI9481_INDEX(0x00,0x02);
LCD_ILI9481_INDEX(0x00,0x11);

LCD_ILI9481_CMD(0x00,0xC5);		// Frame rate and inversion control
LCD_ILI9481_INDEX(0x00,0x03);	// 72 Hz

LCD_ILI9481_CMD(0x00,0xC8);		// Gamma settings
LCD_ILI9481_INDEX(0x00,0x00);
LCD_ILI9481_INDEX(0x00,0x32);
LCD_ILI9481_INDEX(0x00,0x36);
LCD_ILI9481_INDEX(0x00,0x45);
LCD_ILI9481_INDEX(0x00,0x06);
LCD_ILI9481_INDEX(0x00,0x16);
LCD_ILI9481_INDEX(0x00,0x37);
LCD_ILI9481_INDEX(0x00,0x75);
LCD_ILI9481_INDEX(0x00,0x77);
LCD_ILI9481_INDEX(0x00,0x54);
LCD_ILI9481_INDEX(0x00,0x0C);
LCD_ILI9481_INDEX(0x00,0x00);

LCD_ILI9481_CMD(0x00,0x36);		// set address mode
LCD_ILI9481_INDEX(0x00,0x0A);	

LCD_ILI9481_CMD(0x00,0x3A);		// set pixel format
LCD_ILI9481_INDEX(0x00,0x55);

LCD_ILI9481_CMD(0x00,0x2A);		// set column address
LCD_ILI9481_INDEX(0x00,0x00);
LCD_ILI9481_INDEX(0x00,0x00);
LCD_ILI9481_INDEX(0x00,0x01);
LCD_ILI9481_INDEX(0x00,0x3F);

LCD_ILI9481_CMD(0x00,0x2B);		// set page address
LCD_ILI9481_INDEX(0x00,0x00);
LCD_ILI9481_INDEX(0x00,0x00);
LCD_ILI9481_INDEX(0x00,0x01);
LCD_ILI9481_INDEX(0x00,0xE0);

delay_50ms();
delay_50ms();
delay_50ms();

LCD_ILI9481_CMD(0x00,0x29);
LCD_ILI9481_CMD(0x00,0x2C);
}


void ILI9481_Clear(char VH,char VL)
{
	int i,j;

    for(i=0;i<480;i++)
	 {
	  for (j=0;j<320;j++)
	   	{
        	 LCD_ILI9481_CMD(VH,VL);
	    }

	  }

}


void main()
{
	
	Port_IO_Init();
	LED1 = 0;
	


	ILI9481_CPT_Initial_Code();
	ILI9481_Clear(0xff, 0xff);
		while (1)
		{
			ILI9481_Clear(0xf8,0x00); // red
			//delayms(2000);
	   		ILI9481_Clear(0x07,0xE0); // green
		   //delayms(2000);
	    	ILI9481_Clear(0x00,0x1f); // blue
			
		LED1=1;			
		} 


}


Mon Mar 31 2014, 11:34 am
#2
Can you provide link to exact module datasheet? Looks like you are using MCU80 16-bit mode? Am I right? Where did you get the initialization sequence?
Mon Mar 31 2014, 09:43 pm
#3
This is the datasheet for ILI9481 http://www.allshore.com/pdf/ILITEKILI9481.pdf, and for MCU c8051f022 http://www.silabs.com/Support%20Documents/TechnicalDocs/C8051F02x.pdf . Yes, I'm using 16bit mode. I find different source code and write for my case.
Mon Mar 31 2014, 10:39 pm
#4
I was asking datasheet of LCD you're using not LCD controller. Coz the thing is LCD manufacturers use ILI in their modules sometimes in a different mode than you think. The mode pins of ILI are configured differently sometimes. So provide link to LCD datasheet.
Mon Mar 31 2014, 10:49 pm
#5
I don't know what LCD I use, because I bought module with LCD and ILI controller, and I see only the exit pins of ILI.
Tue Apr 01 2014, 11:12 am
#6
Check markings on your LCD.. it must have written LCD name on it. The reason why I am asking about it is.. coz it might be running in a different mode than you think. As you also said everyone uses different code for LCD it is coz of the same reason. ILI can be put in different modes by LCD manufacturers.
Tue Apr 01 2014, 01:13 pm
#7
Look the attached files, that is my LCD and I didn't see where its name is. Is it possible that the delay function, could make problems. If that's possible, how can I make a delay function.
Wed Apr 02 2014, 10:10 am
#8
We only support jpg, png and gif image files. if you are attaching any other format than this please zip it first and then attach.
Wed Apr 02 2014, 10:59 am
#9
This is my LCD
Attachment
Wed Apr 02 2014, 12:04 pm
#10
After lot of searches on google and reading lot of forums.. I think you are using wrong LCD driver. HY-TFT320 uses SSD1289 controller instead of ILI9481.

3.2-inch TFT Color LCD Module is a TFT LCD Screen Module , 40pins interface ,16 bit, not just a LCD break but include the Touch , SD card and Flash design. So it's a powerful extension module for your project.
This item is 240374PQ . It's a 65K color , 320*240 (resolution),3.2 inch TFT LCD screen.The LCD has a wide viewing angle , the contrast is also very suitable.
The Screen include a controller SSD1289, it's a support 8/16bit data interface , easy to drive by many MCU like STM32 ,AVR and 8051.
It is designed with a touch controller in it . The touch IC is ADS7843 , and touch interface is included in the 40 pins breakout. It is the version of product only with touch screen and touch controller.
Pin definition:
The pins named with "D_" is the touch bus , the pins named with "SD_" is SD bus, the pins named with "F_" is Flash bus.
It is work at 3.3v DC, if you need to connect the module with the 5v voltage I/O , you need to add the 30k and 20k resistors to reduce voltage. It support that it can default use the 16 bit mode

http://www.amazon.co.uk/HY-TFT320-inch-Screen-module-interface/dp/B00CW8PNVE



I also checked on one more wiki site.. it says the same, LCD Driver SSD1289
Datasheet:
Attachment

Reference: http://www.electrodragon.com/w/Category:3.2_TFT_LCD

Just look at the link mentioned above and I am sure using the right LCD controller driver should solve your problem.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

WilliamErync
Sun May 05 2024, 02:35 am
Danielnof
Sat May 04 2024, 11:12 pm
oriminna
Sat May 04 2024, 08:28 pm
scaneraNom
Sat May 04 2024, 02:21 am
gtaletrzua
Fri May 03 2024, 10:55 am
Clydehet
Wed May 01 2024, 06:44 pm
Davidoried
Wed May 01 2024, 06:11 pm
KevinTab
Sun Apr 28 2024, 05:35 am