Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

coding in c for interfacing LCD with PIC24FJ128GA010

Status
Not open for further replies.

malhi

Newbie level 6
Joined
Nov 13, 2008
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,420
pic24fj128ga010

Hi
i am doing my engineering training and i have got one major project on interfacing LCD with 16 bit controller pic24fj128ga010..using MPLAB
i have encounter the problem in coding,
please help me out......i tried for this code, but its not working

#include<p24fj128ga010.h>
sfr ldata=0x00D0
sfr ldata=0x00C0;
#define rs portDbit.0
#define rw portDbit.1
#define en portDbit.2


unsigned char ar[]={"hello"};
unsigned long int i,j,a;

void delay(void);

void delay (void)
{
for(i=0;i<=50;i++)
for(j=1;j>0;j--);
}
void cmd( void )
{
rs=0;
rw=0;
en=1;
delay();
en=0;
delay();
}
void data( void )
{
rs=1;
rw=0;
en=1;
delay();
en=0;
delay();
}
int main()
{
PORTE=0x38;
cmd();
delay();
PORTE=0x0E;
cmd();
delay();
PORTE=0x0001;
cmd();
delay();
PORTE=0x0006;
cmd();
delay();
PORTE=0x0080;
cmd();
delay();
for(a=0;a<6;a++)
{
PORTE=ar[a];
data();
delay();
}
while(1);
return(0);
}
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
47,995
Helped
14,149
Reputation
28,557
Reaction score
12,841
Trophy points
1,393
Location
Bochum, Germany
Activity points
278,361
pic24fj128ga010 input capture

The LCD controller data sheets have a specification for initialization, obviously your keeping neither the timing specification (required delays) nor the recommended method to set the interface reliably to 8-bit mode (sending 0x38 three times).

There may be other errors, too, but I suggest to correct these points first.

When using a full us interface, it's more effective to check the busy flag rather than using long delays required for some instructions, I think.
 

embeddedlover

Full Member level 5
Joined
Aug 10, 2007
Messages
279
Helped
46
Reputation
92
Reaction score
38
Trophy points
1,308
Activity points
3,155
c coding for lcd interfacing with pic24fj128ga010

1.By default the port pins are input, have u configured them as output? If not configure using TRISD register.
2.Try to use some delay before intializing the controller.
3.Try to check out your intialization seq, for this check the LCD manual
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top