#include <htc.h>#include <pic.h>
__CONFIG (0x3F32);#define rs RC4#define e RC5#define lcd_data PORTBvoid send_config(unsignedchar data);void delay(unsignedlong data);void send_string(constchar*s);void lcd_clr(void);void lcd_goto(unsignedchar data);void send_char(unsignedchar data);unsignedchar location=1;void main(void){
TRISB =0b00000000;
TRISC =0b10000000;
send_config(0b00000001);//clear display at lcd
send_config(0b00000010);//lcd return to home
send_config(0b00000110);//entry mode-cursor increase 1
send_config(0b00001100);//display on, cursor off and cursor blink off
send_config(0b00111000);//function set
lcd_clr();
lcd_goto(0);
send_string("ND2/11/CME");
lcd_goto(20);
send_string("MKJB");
delay(200000);
lcd_clr();}void send_config(unsignedchar data){
rs=0;
lcd_data = data;
e=1;
delay(50);
e=0;
delay(50);}void lcd_clr(void){
send_config(0x01);
delay(600);}void delay(unsignedlong data){for(;data>0;data--);}void lcd_goto(unsignedchar data)//set the location of the lcd cursor{//if the given value is (0-15) the if(data<16)//cursor will be at the upper line{//if the given value is (20-35) the
send_config(0x80+data);//cursor will be at the lower line}//location of the lcd cursor(2X16):else// -----------------------------------------------------{// | |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15| |
data=data-20;// | |20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35| |
send_config(0xc0+data);// ----------------------------------------------------- }}void send_string(constchar*s)//send a string to display in the lcd{unsignedchar i=0;while(s &&*s)send_char (*s++);}void send_char(unsignedchar data)//send lcd character{
rs=1;//set lcd to display mode
lcd_data=data;//lcd data port = data
e=1;//pulse e to confirm the data
delay(10);
e=0;
delay(10);}
You probably need to add a delay before starting to send information to the LCD to give it's own processor time to start up. Also check the delays during configuration, the data sheet tells you the minimum delays or. as you are using 8-bit mode you can poll the 'busy' signal to see when the LCD can accept more data.