hi,
dont use c18 library, just use my code.before using my code,define the RS RW E and Data pins that you use.I wrote this code for 8 bit mood.in this code,only you have to convert your data to a string.thats all
#include <stdio.h>
#include <P18CXXX.h>
#include <delays.h>
#include <timers.h>
#pragma code page // This code make sure the program starts from 0x0004, not from 0x0000
#pragma config WDT = OFF
#define RS PORTEbits.RE0
#define dirRS TRISEbits.TRISE0
#define RW PORTEbits.RE1
#define dirRW TRISEbits.TRISE1
#define E PORTEbits.RE2
#define dirE TRISEbits.TRISE2
#define DATALCD PORTD
#define dirDATA TRISD
#define LCDBusy PORTDbits.RD7
void LCDdata (unsigned char);
void busylcd(void);
void LCDinit (void);
void LCDDelay( void );
void lcdcmd(unsigned char);
void stringtoLCD(unsigned char *m);
unsigned char * itoa (unsigned int value, unsigned char * string);
unsigned char dataString[10];
void main (void) // main function
{
int integer=650;
unsigned char *biginin;
biginin=&dataString[0];
TRISD = 0;
PORTD = 0;
TRISB = 0; // Port,pin direction configuration
PORTB = 0;
TRISC = 0;
PORTC = 0;
TRISCbits.TRISC7 = 1; // make sure this pin is input
ADCON1=7;
dirRS = 0;
LCDinit();
while (1) // this is how to make a never ending loop.
{
lcdcmd(0x1);
lcdcmd(0x2);
itoa (integer, biginin);
stringtoLCD(dataString);
}
}
//////////////////////////////////////////////////////////////////////////////////////
//LCD finctions------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////
void LCDdata (unsigned char value)
{
busylcd();
TRISD = 0;
DATALCD = value;
RS=1;
RW=0;
E=1;
LCDDelay();
E=0;
}
//--------------------------------------------------------------------------------------
void LCDinit(void)
{
TRISE=0;
lcdcmd(0x38); //set 8-bit mode and 2 lines
lcdcmd(0x10); //cursor move & shift left
lcdcmd(0x06); //entry mode = increment
lcdcmd(0x0d); //display on - cursor blink on
lcdcmd(0x01); //clear display
}
//-------------------------------------------------------------------------------------
void busylcd(void)
{
RS=0;
RW=1;
TRISD=255;
E=0;
LCDDelay();
E=1;
while(LCDBusy==1){
E=0;
LCDDelay();
E=1;
}
}
//-------------------------------------------------------------------------------------
void lcdcmd(unsigned char temp)
{
busylcd();
RS=0;
RW=0;
TRISD=0;
DATALCD=temp;
E=1;
LCDDelay();
E=0;
}
//--------------------------------------------------------------------------------------
void LCDDelay(void)
{
int i=0;
for (i=0;i<250;i++);
}
//---------------------------------------------------------------------------------------
void stringtoLCD(unsigned char *m)
{
unsigned char i;
i = 0;
while(m != 0)
{
LCDdata(m);
i++;
}
}