#include<p18f4550.h>
//-------vector relocation-----------
extern void _startup (void);
#pragma code _RESET_INTERRUPT_VECTOR = 0x1000
void _reset (void)
{
_asm goto _startup _endasm
}
#pragma code
#pragma code _HIGH_INTERRUPT_VECTOR = 0x1008
void high_ISR (void)
{
}
#pragma code
#pragma code _LOW_INTERRUPT_VECTOR = 0x1018
void low_ISR (void)
{
}
#pragma code
//------------------------------------
//-------------------------------------
void delay(unsigned char x)
{
int i,j;
for(i=0;i<=x;i++)
for(j=0;j<=1275;j++);
}
void lcd(unsigned char x, unsigned char y)
{
PORTB=x;
PORTDbits.RD5=y; // select command register
PORTDbits.RD6=0; // ,make rw low
PORTDbits.RD7=1; // make en high
delay(1);
PORTDbits.RD7=0; // make en low
}
void main()
{
int i,j,k,l,m;
unsigned char a[]={0x38,0x01,0x06,0x0e};
unsigned char b[]={"Welcome "};
unsigned char c[]={"good"};
unsigned char d[]={"morning"};
unsigned char e[]={"to all"};
TRISB=0x00;
TRISD=0x00;
for(i=0;i<=3;i++)
{
lcd(a[i],0);
}
lcd(0x80,0);
for(j=0;j<=6;j++)
{
lcd(b[j],1);
delay(3);
}
lcd(0xc0,0);
for(k=0;k<=3;k++)
{
lcd(c[k],1);
delay(3);
}
lcd(0x94,0);
for(l=0;l<=6;l++)
{
lcd(d[l],1);
delay(3);
}
lcd(0xd4,0);
for(m=0;m<=5;m++)
{
lcd(e[m],1);
delay(3);
}
lcd(0x0c,0);
while(1);
}