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.

[SOLVED] LCD display not working properly

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
Hi...

I have interfaced the LCD with PIC18F4520 as...

EN - RA1
RW- RA2
RS - RA3

D4-D7 - RD0-RD3

The code I wrote, goes as follows...
Code:
#define PIN_ENABLE_LCD 	      PORTAbits.RA5  
#define PIN_RW_LCD 		PORTAbits.RA2  
#define PIN_RS_LCD 		PORTAbits.RA3  
#define DATA_LCD 	PORTD

void InitialiseDisplay(void)
{
	ADCON1 = 0x0F;  			// Disable Analog INput
	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;	
	PIN_ENABLE_LCD = 0;	
	Delay(1);

	DATA_LCD = uiCommand & 0x0F; //Send LSB nibble
	PIN_ENABLE_LCD = 1;	
	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;
	Delay(1);
	PIN_ENABLE_LCD = 0;
	PIN_RS_LCD     = 0;		

	DATA_LCD = uiData & 0x0F; //Send LSB nibble
	PIN_RS_LCD     = 1;	
	PIN_ENABLE_LCD = 1;
	Delay(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 have called InitialiseDisplay() function in the main().

However, when I see the output on the screen...I could see this... ||| ||
blinks for few seconds and the disappears and then nothing happens.
I have sent the command of blinking cursor...so it keeps on blinking on the screen, but it seems that there is bug in the code.
Can anyone plz tell me what goes wrong with this code?
 

Actually, it is already made 0 in the function ResetDisplay(), so I didnt use it again.

I still tried your way, but it didnt work.
 

is it in MikroC or what is the Editor ?
 

I am using MPLAB 8.1 and MPLAB C18 C compiler.
 

Before initializing, you should see black boxes in the first line of the display. Else the problem seems like your display is damaged. Try a new display.
 
@ckshivaram

I dont have externally connected pull ups on the port pins.
I have tried using 10k pot. I turned the pot in either direction but none of the time display contrast changed. I guess the pot is not working, though I am not sure of it.

@nandu015
I can see the boxes but they are very light in color or fading.
 

hi can u help me in keypad interfacing..i have 4x3 keypad and im using zilog specifically Z8f6421..thank you

why this requiremen has come in this thread.. start a new thread and delete it here.. This thread is running for some other problem and solution .. dont mix your requirement here
 

Hi....

Thank you for your advice.

I made another circuit for LCD using LCD JHD 162A. When I set the pot connected to pin3 of lcd, I could see the black boxes in upper horizontal line.
And when I programmed the pic using above program without any modification, I got the blinking cursor display on the third position from left.
So, it is now working. Thank you again to all for your guidance.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top