#include <xc.h>
#pragma config FOSC=HS
#pragma config WDTE=OFF
#pragma config BOREN=OFF
char txt[] = {"hello world from the other side of mars"};
void delayUs(int x)
{
while(x--);
}
void delayMs(int x)
{
while(x--)
delayUs(1000);
}
void LCDcmd(char cmd)
{
PORTB = cmd;
RC1 = 0;
RC0 = 1;
RC0 = 0;
delayMs(5);
}
void LCDdata(char dat)
{
PORTB = dat;
RC1 = 1;
RC0 = 1;
RC0 = 0;
RC1 = 0;
delayMs(5);
}
void LCDgoto( char col, char row)
{
unsigned char tmp = 0x80;
if(row) tmp+=0x40;
tmp+= col;
LCDcmd(tmp);
}
void LCDstring(char * str)
{
while(*str !=0)
LCDdata(*str++);
}
void LCDinit(void)
{
TRISB = 0;
TRISC = 0;
delayMs(40);
PORTB = 0x30;
RC0 = 1;
RC0 = 0;
delayMs(15);
PORTB = 0x30;
RC0 = 1;
RC0 = 0;
delayMs(5);
PORTB = 0x30;
RC0 = 1;
RC0 = 0;
LCDcmd(0x38);
LCDcmd(0xD);
LCDcmd(6);
LCDcmd(1);
}
void main(void)
{
LCDinit();
LCDstring(txt);
while (1)
{
LCDcmd(0x18);
delayMs(300);
}
}