Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC 18F4520 interfaced with 16x2 Display modules

Status
Not open for further replies.

scorrpeio

Full Member level 5
Joined
Dec 26, 2006
Messages
286
Helped
10
Reputation
20
Reaction score
9
Trophy points
1,298
Activity points
3,496
Hello,

I have connected 16x2 LCD module to PIC18F4520.

Pin configuration->
EN - RA1
RW- RA2
RS - RA3

D4-D7 - RD4-RD7

I have written this code...
Code:
void InitialiseDisplay(void)
{
	
	ResetDisplay();
	SendCommandToLCD(0x28);		//4 bit interface 2 line First Initialise
	Delay(1);
	SendCommandToLCD(0x0C);		//Display cursor off
	Delay(1);
	SendCommandToLCD(0x06);		//Entry Mode
	Delay(1);
	SendCommandToLCD(0x0F);
	Delay(1);
}

void ResetDisplay( void )
{
	Delay(10);
	TRISA = 0x00;	//Set RA1 - RA3 as o/p 
	TRISD = 0x00;	//Set port D as o/p 
	Delay(1);
	
	PIN_ENABLE_LCD = 0;	
	PIN_RW_LCD     = 0;
 	PIN_RS_LCD     = 0;

	//SendCommandToLCD(0x02);		
	SendCommandToLCD(0x03);		//First Initialise
	Delay(10);
	SendCommandToLCD(0x03);		//Second Initialise
	Delay(1);
	SendCommandToLCD(0x03);		//Third Initialise
	Delay(1);
	SendCommandToLCD(0x02);		
	Delay(1);

}

void SendCommandToLCD( unsigned int uiCommand )
{
	DATA_LCD = uiCommand >> 4;  //Send MSB nibble
	PIN_ENABLE_LCD = 1;	
	//Delay(15);
	PIN_ENABLE_LCD = 0;	

	DATA_LCD = uiCommand & 0x0F; //Send LSB nibble
	PIN_ENABLE_LCD = 1;	
	//Delay(15);
	PIN_ENABLE_LCD = 0;	

	Delay(1);
}

void SendDataToLCD	( unsigned int uiData )
{
	DATA_LCD = uiData >> 4;  //Send MSB nibble
	PIN_RS_LCD     = 1;	
	PIN_ENABLE_LCD = 1;
	PIN_ENABLE_LCD = 0;
	PIN_RS_LCD     = 0;		

	DATA_LCD = uiData & 0x0F; //Send LSB nibble
	PIN_RS_LCD     = 1;	
	PIN_ENABLE_LCD = 1;
	PIN_ENABLE_LCD = 0;
	PIN_RS_LCD     = 0;	

	Delay(1);

}

void Delay			( unsigned int uiIndex1 )
{
	unsigned int uiIndex;
	for( uiIndex = 1000; uiIndex > 0; uiIndex-- )
	{
		
		for( ; uiIndex1 > 0;  uiIndex1-- )
		{
				//do nothing
		}
			
	}
	
}

I took this link as reference...

LCD Commands and Instructions: LCD Tutorial for interfacing with Microcontrollers : 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes

However, when I see output on screen, the 4-5 vertical lines blink 2 times and then nothing happens.

As per the code, i should get the blinking cursor. This is my first time to program LCD, so no idea if I am doing rite or wrong.

Can you please tell me, where did I do mistake?
 

void lcd_init(void)
{
P0=0;
LCDE="1";
delay_ms(500);
lcd_clear();
lcd_write_cmd(0x38);//www.e-shinedisplay.com
lcd_write_cmd(0x0f);//显示开关控制:显示ON,光标ON,闪烁ON
lcd_write_cmd(0x06);//光标输入方式增量移位
lcd_write_cmd(0x80);
//lcd_write_cmd(0x0c);
//lcd_clear();
}
 

thnx for reply...
but the code you sent, is already implemented.
 

I do not use 'C', so this is just an idea.The first thing I noticed in the send command function, there is no delay between the upper and lower nibble. ( or checking of R/W line if you use that), this is also the same in the send data function.


I do not know if this will help **broken link removed**
 
I have tried most of the things I got on google...
but the problem persists.
Anybody have got such problem before?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top