Rich (BB code):
#include<P18f458.h>
#define mydata PORTB
#define rs PORTCbits.RC1
#define en PORTCbits.RC3
void lcdcmd(unsigned value);
void lcddata (unsigned value);
void delay(unsigned int t);
void lcdstring(unsigned char *string2lcd);
unsigned char lowbyte, highbyte;
unsigned int result;
unsigned char str_result[10];
unsigned char msg1[] = "MALIK";
void main()
{
lcdcmd(0x38);
delay(15);
lcdcmd(0x00);
delay(15);
lcdcmd(0x0E);
delay(15);
lcdcmd(0x01);
delay(15);
lcdcmd(0x86);
delay(15);
CCP1CON=0x05;
T3CON=0X00;
T1CON=0X00;
TRISB=0;
TRISCbits.TRISC2=1;
CCPR1L=0x00;
CCPR1H=0x00;
while(1)
{
TMR1H=0;
TMR1L=0;
PIR1bits.CCP1IF=0;
while(PIR1bits.CCP1IF==0)
T1CONbits.TMR1ON=1;
PIR1bits.CCP1IF=0;
T1CONbits.TMR1ON=0;
lowbyte=CCPR1H;
highbyte=CCPR1L;
result = highbyte;
result = result << 8;
result = result | lowbyte;
str_result[0] = result/10000 + 48;
str_result[1] = (result/1000)%10 + 48;
str_result[2] = (result/100)%10 + 48;
str_result[3] = (result/10)%10 + 48;
str_result[4] = (result/1)%10 + 48;
str_result[5] = '\0';
PORTB=str_result[0];
//send str_result to lcd print function.
lcdstring(&msg1);
lcdstring(&str_result[0]);
lcdstring(&str_result[1]);
lcdstring(&str_result[2]);
lcdstring(&str_result[3]);
lcdstring(&str_result[4]);
}
}
void lcdcmd(unsigned value)
{
mydata=value;
rs=0;
en=1;
delay(1);
en=0;
}
void lcddata(unsigned value)
{
mydata=value;
rs=1;
en=1;
delay(1);
en=0;
}
void delay(unsigned int t){
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<135;j++);
}
void lcdstring(unsigned char *string2lcd){
while(string2lcd){
lcddata(*string2lcd++);
delay(15);
}
}
its not displaying on LCD .please sort out my mistakes and give me tips what should i do.
Thanks..........!!