// Write a nibble to the LCD
// may have to adjust delays to suit the processor and clock
void lcdNibble(int n)
{
int lcd=LCDdata;
__delay_us(800);
LCDdata = (lcd&0xfff0) | ((n & 0x0f)); // send out lower Nibble
Nop(); // Wait E Pulse width time (min 230ns)
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
LCDstatus.E=1; // take clock E high
Nop(); // Wait E Pulse width time (min 230ns)
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
Nop();
LCDstatus.E=0;
__delay_us(800);
}
// Write a Control Command to the LCD
// This is written as two nibbles
void lcdCmd(int c)
{
LCDstatus.RS=0; // Take RS pin low for command
lcdNibble(c >>4); // Makeup Upper Nibble
lcdNibble(c); // Makeup Lower Nibble
}